fix NC Staticdata
This commit is contained in:
@@ -408,7 +408,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
lists.Reverse();
|
||||
|
||||
MachNumber = Encoding.ASCII.GetString(lists.ToArray());
|
||||
MachNumber = Encoding.ASCII.GetString(lists.ToArray().Reverse().ToArray());
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
@@ -4288,23 +4288,79 @@ namespace CMS_CORE_Library.S7Net
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
|
||||
|
||||
#if false
|
||||
// prendo 2° valore(num max valori)
|
||||
numByte = memByteRead[1];
|
||||
// poi prendo la stringa...
|
||||
string outVal = "";
|
||||
for (int i = 2; i < numByte + 2; i++)
|
||||
{
|
||||
outVal += Char.ConvertFromUtf32(memByteRead[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Read oly one time every X seconds
|
||||
if (DateTime.Now - Last_Static_Read > new TimeSpan(NC_MIN_SEC_READ_STATIC_DATA * TimeSpan.TicksPerSecond))
|
||||
{
|
||||
//Try to get information
|
||||
try
|
||||
{
|
||||
// completare nuove variabili (matricola macchina, seriale PLC, firmware PLC)
|
||||
S7Language = 0;
|
||||
ConfChannelNo = 1;
|
||||
Last_Static_Read = DateTime.Now;
|
||||
Cnc_name = $"{currPLC.CPU}";
|
||||
// FIXME
|
||||
Cms_MachNumber = "0000"; // matricola macchina, DB604.DBB6720..6723
|
||||
Cnc_SftVersion = "SMC000"; // versione SW del firmware PLC/CNC | DB604.DBB6724..6745
|
||||
Cnc_SeriesNum = "SMC111"; // seriale PLC/CNC | DB604.DBB6746..6763
|
||||
PlcFirmware_SerialNum = "V.0.0.0"; // seriale PLC/CNC | DB604.DBB6764..6767
|
||||
UnitOfMeasure = MILLIMETERS;
|
||||
|
||||
|
||||
List<byte> currMem = new List<byte>();
|
||||
libraryError = MEM_RWByteList(R, 0, STATIC_DATA.MemType, STATIC_DATA.Address, STATIC_DATA.SubAddress, 0, STATIC_DATA.Size, ref currMem);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
if (currMem.Count > 0)
|
||||
{
|
||||
// completare nuove variabili (matricola macchina, seriale PLC, firmware PLC)
|
||||
S7Language = 0;
|
||||
ConfChannelNo = 1;
|
||||
Last_Static_Read = DateTime.Now;
|
||||
Cnc_name = $"{currPLC.CPU}";
|
||||
// decodifico info!
|
||||
byte[] memByteRead = currMem.Skip(0).Take(4).ToArray();
|
||||
int numByte = 0;
|
||||
string outVal = "";
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
outVal += Char.ConvertFromUtf32(memByteRead[i]);
|
||||
}
|
||||
Cms_MachNumber = outVal; // matricola macchina, DB604.DBB6720..6723
|
||||
|
||||
memByteRead = currMem.Skip(4).Take(22).ToArray();
|
||||
outVal = "";
|
||||
numByte = memByteRead[1];
|
||||
for (int i = 2; i < numByte+2; i++)
|
||||
{
|
||||
outVal += Char.ConvertFromUtf32(memByteRead[i]);
|
||||
}
|
||||
Cnc_SftVersion = outVal; // versione SW del firmware PLC/CNC | DB604.DBB6724..6745
|
||||
|
||||
memByteRead = currMem.Skip(26).Take(18).ToArray();
|
||||
outVal = "";
|
||||
numByte = memByteRead[1];
|
||||
for (int i = 2; i < numByte+2; i++)
|
||||
{
|
||||
outVal += Char.ConvertFromUtf32(memByteRead[i]);
|
||||
}
|
||||
Cnc_SeriesNum = outVal; // seriale PLC/CNC | DB604.DBB6746..6763
|
||||
|
||||
memByteRead = currMem.Skip(44).Take(4).ToArray();
|
||||
outVal = "";
|
||||
outVal += Char.ConvertFromUtf32(memByteRead[0]);
|
||||
for (int i = 1; i < 4; i++)
|
||||
{
|
||||
outVal += $"{memByteRead[i]}";
|
||||
}
|
||||
PlcFirmware_SerialNum = outVal; // seriale PLC/CNC | DB604.DBB6764..6767
|
||||
|
||||
UnitOfMeasure = MILLIMETERS;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -4525,8 +4581,12 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
internal static MEMORY_CELL PROCESS_STATUS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 605, 0, 2);
|
||||
|
||||
// Machine number
|
||||
// Machine data
|
||||
internal static MEMORY_CELL STATIC_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 604, 6720, 48);
|
||||
internal static MEMORY_CELL NEW_MATR_MACC = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 604, 6720, 4);
|
||||
internal static MEMORY_CELL VERS_SW_PLC = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 604, 6724, 22);
|
||||
internal static MEMORY_CELL SER_NUM_PLC = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 604, 6746, 22);
|
||||
internal static MEMORY_CELL FIRMWARE_PLC = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 604, 6764, 4);
|
||||
|
||||
// generic machine gauge data
|
||||
internal static MEMORY_CELL MACHINE_GAUGE_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 605, 6, 16);
|
||||
|
||||
Reference in New Issue
Block a user