diff --git a/CMS_CORE_Library/NcThermo.cs b/CMS_CORE_Library/NcThermo.cs
index bec6010..367d74f 100644
--- a/CMS_CORE_Library/NcThermo.cs
+++ b/CMS_CORE_Library/NcThermo.cs
@@ -494,19 +494,6 @@ namespace CMS_CORE_Library
public abstract CmsError PLC_WResetMachineCounters(uint counter);
- /**
- *
- * Read nc softkeys values from PLC
- *
- * Compatibility: Fanuc | Osai | Demo | Siemens
- *
- * Returns an error when an internal or a library error occours
- * Reference to the nc softkey data
- *
- **/
-
- public abstract CmsError PLC_RNcSoftKeys(ref List ncSoftKeys);
-
/**
*
* Read user softkeys values from PLC
@@ -520,19 +507,6 @@ namespace CMS_CORE_Library
public abstract CmsError PLC_RUserSoftKeys(ref List softKeys);
- /**
- *
- * Write Nc softkey interaction into PLC
- *
- * Compatibility: Fanuc | Osai | Demo | Siemens
- *
- * Returns an when an internal or a library error occours
- * Nc softkey id
- *
- **/
-
- public abstract CmsError PLC_WNcSoftKey(uint id);
-
/**
*
* Write user softkey interaction into PLC
@@ -1040,41 +1014,36 @@ namespace CMS_CORE_Library
#region MEMORY Low-level function: single valiable in memory (to override)
- /**
- * Read/Write Boolean variable from/into NC Memory Area (including Siemens Nc)
- *
- * Compatibility: Fanuc | Osai | Demo | Siemens
- *
- *
- * Returns an error when an internal or a library error occours
- * Set True to Write-operation (Also Allowed /)
- * Process to perform operation (If the area is process-indipendent use 0 or )
- * Nc Memory Area. See
- * Siemens Memory Table (Used only in Siemens-Nc)
- * Starting Index of Memory Area
- * Set the Bit to Read-Write. (0..7)
- * Reference to variable to read/Write
- * */
+ ///Read/Write Boolean variable from/into NC Memory Area (including Siemens Nc)
+ ///
+ ///Compatibility: Fanuc | Osai | Demo | Siemens
+ ///
+ ///
+ ///Returns an error when an internal or a library error occours
+ ///Set True to Write-operation (Also Allowed /)
+ ///Set True if endian swap fix needed
+ ///Process to perform operation (If the area is process-indipendent use 0 or )
+ ///Nc Memory Area. See
+ ///Siemens Memory Table (Used only in Siemens-Nc)
+ ///Starting Index of Memory Area
+ ///Set the Bit to Read-Write. (0..7)
+ ///Reference to variable to read/Write
+ public abstract CmsError MEM_RWBoolean(bool bWrite, bool fixEndian, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemBit, ref bool Value);
- public abstract CmsError MEM_RWBoolean(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemBit, ref bool Value);
- /**
- * Read/Write Byte variable from/into NC Memory Area (including Siemens Nc)
- *
- * Compatibility: Fanuc | Osai | Demo | Siemens
- *
- *
- * Returns an error when an internal or a library error occours
- * Set True to Write-operation (Also Allowed /)
- * Process to perform operation (If the area is process-indipendent use 0 or )
- * Nc Memory Area. See
- * Siemens Memory Table (Used only in Siemens-Nc)
- * Starting Index of Memory Area
- * Set to 1 if the Byte is the second of a WORD (only for OSAI Nc)
- * Reference to variable to read/Write
- * */
-
- public abstract CmsError MEM_RWByte(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByte, ref byte Value);
+ ///
+ /// Read-Write a SINGLE Byte inside the NC. In writing-mode the field "Number" is not required
+ ///
+ /// R/W mode
+ /// fix endianness
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public abstract CmsError MEM_RWByte(bool bWrite, bool fixEndian, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByte, ref byte Value);
/**
* Read/Write unsigned 2 Byte (NC: Word:, .NET: ushort) variable from/into NC Memory Area (including Siemens Nc)
@@ -1816,7 +1785,7 @@ namespace CMS_CORE_Library
#region CONSTANTS (Struct and Enum are Static for definition)
- public const int REFRESH_ALL_ALARMS_SFKEY_INDEX = 29;
+ public const int REFRESH_ALL_ALARMS_SFKEY_INDEX = 2;
// Read Write type
/** Write action */
public const bool W = true;
diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs
index 59c1ef7..8cd615b 100644
--- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs
+++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs
@@ -552,8 +552,9 @@ namespace CMS_CORE_Library.S7Net
public override CmsError PLC_RWManageWatchdog()
{
+ // watchdog in memoria WORD --> true x endianness!
bool plcWatchdog = false;
- CmsError libraryError = MEM_RWBoolean(R, 0, NC_WATCHDOG.MemType, NC_WATCHDOG.Address, NC_WATCHDOG.SubAddress, 0, ref plcWatchdog);
+ CmsError libraryError = MEM_RWBoolean(R, true, 0, NC_WATCHDOG.MemType, NC_WATCHDOG.Address, NC_WATCHDOG.SubAddress, 0, ref plcWatchdog);
if (libraryError.IsError())
return libraryError;
@@ -561,7 +562,7 @@ namespace CMS_CORE_Library.S7Net
return PLC_NOT_RUNNING_ERROR;
// tira su il bit...
plcWatchdog = true;
- return MEM_RWBoolean(W, 0, NC_WATCHDOG.MemType, NC_WATCHDOG.Address, NC_WATCHDOG.SubAddress, 0, ref plcWatchdog);
+ return MEM_RWBoolean(W, true, 0, NC_WATCHDOG.MemType, NC_WATCHDOG.Address, NC_WATCHDOG.SubAddress, 0, ref plcWatchdog);
}
///
@@ -598,7 +599,7 @@ namespace CMS_CORE_Library.S7Net
ALARMS_STATUS.Address,
ALARMS_STATUS.SubAddress,
0,
- (ALARMS_STATUS.Size), // status_bytes / 4 + data_word / 2
+ (ALARMS_STATUS.Size), // status_bytes
ref currMem);
if (libraryError.IsError())
@@ -652,8 +653,8 @@ namespace CMS_CORE_Library.S7Net
if (id > ALARMS_NUMBER)
return INCORRECT_PARAMETERS_ERROR;
- // Call restore message
- CmsError libraryError = PLC_WStrobe(ALARM_ACK, ALARM_RESTORATION_STROBE, id);
+ // Call restore message: is a BIT ARRAY --> true!
+ CmsError libraryError = PLC_WStrobe(true, ALARM_ACK, ALARM_RESTORATION_STROBE, id);
if (libraryError.IsError())
return libraryError;
@@ -666,8 +667,8 @@ namespace CMS_CORE_Library.S7Net
if (id > ALARMS_NUMBER)
return INCORRECT_PARAMETERS_ERROR;
- // Call restore message
- CmsError libraryError = PLC_WStrobe(ALARM_ACK, ALARM_REFRESH_STROBE, id);
+ // Call restore message: is a BIT ARRAY --> false!
+ CmsError libraryError = PLC_WStrobe(false, ALARM_ACK, ALARM_REFRESH_STROBE, id);
if (libraryError.IsError())
return libraryError;
@@ -676,7 +677,8 @@ namespace CMS_CORE_Library.S7Net
public override CmsError PLC_WRefreshAllMessages()
{
- return PLC_WNcSoftKey(REFRESH_ALL_ALARMS_SFKEY_INDEX);
+ // imposto come UserSoftKey
+ return PLC_WUserSoftKey(REFRESH_ALL_ALARMS_SFKEY_INDEX);
}
public override CmsError PLC_RPowerOnData(ref PreAndPostPowerOnModel powerOnModel)
@@ -734,7 +736,7 @@ namespace CMS_CORE_Library.S7Net
return INCORRECT_PARAMETERS_ERROR;
// Call restore message
- CmsError libraryError = PLC_WStrobe(PRE_POST_POWER_ON_ACK, PRE_POST_POWER_ON_CLICKED, id);
+ CmsError libraryError = PLC_WStrobe(false, PRE_POST_POWER_ON_ACK, PRE_POST_POWER_ON_CLICKED, id);
if (libraryError.IsError())
return libraryError;
@@ -771,7 +773,7 @@ namespace CMS_CORE_Library.S7Net
{
byte value = 0;
// Read byte from memory
- CmsError libraryError = MEM_RWByte(R, 0, AXIS_RESET_PROCEDURE.MemType, AXIS_RESET_PROCEDURE.Address, AXIS_RESET_PROCEDURE.SubAddress, 0, ref value);
+ CmsError libraryError = MEM_RWByte(R, true, 0, AXIS_RESET_PROCEDURE.MemType, AXIS_RESET_PROCEDURE.Address, AXIS_RESET_PROCEDURE.SubAddress, 0, ref value);
if (libraryError.IsError())
return libraryError;
@@ -792,15 +794,6 @@ namespace CMS_CORE_Library.S7Net
return NO_ERROR;
}
- public override CmsError PLC_RNcSoftKeys(ref List ncSoftKeys)
- {
- CmsError libraryError = PLC_RSoftKeys(NC_SOFTKEYS_VALUE, NC_SOFTKEYS_CLICKABLE, ref ncSoftKeys);
- if (libraryError.IsError())
- return libraryError;
-
- return NO_ERROR;
- }
-
public override CmsError PLC_RUserSoftKeys(ref List softKeys)
{
CmsError libraryError = PLC_RSoftKeys(USER_SOFTKEYS_VALUE, USER_SOFTKEYS_CLICKABLE, ref softKeys);
@@ -846,28 +839,14 @@ namespace CMS_CORE_Library.S7Net
return NO_ERROR;
}
- public override CmsError PLC_WNcSoftKey(uint id)
- {
- // Check id range
- if (id > NC_SOFTKEYS_NUMBER)
- return INCORRECT_PARAMETERS_ERROR;
-
- // Write strobe into memory
- CmsError libraryError = PLC_WStrobe(NC_SOFT_KEYS_ACK, NC_SOFT_KEYS_CLICKED, id);
- if (libraryError.IsError())
- return libraryError;
-
- return NO_ERROR;
- }
-
public override CmsError PLC_WUserSoftKey(uint id)
{
// Check id range
if (id > USER_SOFTKEYS_NUMBER)
return INCORRECT_PARAMETERS_ERROR;
- // Write strobe into memory
- CmsError libraryError = PLC_WStrobe(USER_SOFT_KEYS_ACK, USER_SOFT_KEYS_CLICKED, id);
+ // Write strobe into memory --> check if bitArray
+ CmsError libraryError = PLC_WStrobe(false, USER_SOFT_KEYS_ACK, USER_SOFT_KEYS_CLICKED, id);
if (libraryError.IsError())
return libraryError;
@@ -901,6 +880,8 @@ namespace CMS_CORE_Library.S7Net
public override CmsError PLC_WResetWorkedTimeMachine(uint time)
{
+ //FIXME TODO verificare endianness aree memoria
+
uint actTime = 0;
// Read actual Value
@@ -919,7 +900,7 @@ namespace CMS_CORE_Library.S7Net
//Scrivo il bit
bitValue = true;
nTry = 0;
- libraryError = MEM_RWBoolean(W, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address, MACHINE_RESET_WORKED_TIME.SubAddress, 0, ref bitValue);
+ libraryError = MEM_RWBoolean(W, true, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address, MACHINE_RESET_WORKED_TIME.SubAddress, 0, ref bitValue);
if (libraryError.IsError())
return libraryError;
@@ -928,7 +909,7 @@ namespace CMS_CORE_Library.S7Net
{
Thread.Sleep(50);
nTry += 1;
- libraryError = MEM_RWBoolean(R, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address, MACHINE_RESET_WORKED_TIME.SubAddress, 0, ref bitValue);
+ libraryError = MEM_RWBoolean(R, true, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address, MACHINE_RESET_WORKED_TIME.SubAddress, 0, ref bitValue);
if (libraryError.IsError())
return libraryError;
@@ -938,7 +919,7 @@ namespace CMS_CORE_Library.S7Net
if (bitValue)
{
bitValue = true;
- libraryError = MEM_RWBoolean(W, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address, MACHINE_RESET_WORKED_TIME.SubAddress, 0, ref bitValue);
+ libraryError = MEM_RWBoolean(W, true, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address, MACHINE_RESET_WORKED_TIME.SubAddress, 0, ref bitValue);
if (libraryError.IsError())
return libraryError;
@@ -983,15 +964,16 @@ namespace CMS_CORE_Library.S7Net
public override CmsError PLC_WResetMachineCounters(uint counter)
{
+ // FIXME TODO verifica se endianness vada gestita o meno (qui FALSE)
bool isResettable = false;
- CmsError libraryError = MEM_RWBoolean(R, 0, COUNTER_IS_RESETTABLE.MemType, COUNTER_IS_RESETTABLE.Address, COUNTER_IS_RESETTABLE.SubAddress, (int)(counter - 1), ref isResettable);
+ CmsError libraryError = MEM_RWBoolean(R, false, 0, COUNTER_IS_RESETTABLE.MemType, COUNTER_IS_RESETTABLE.Address, COUNTER_IS_RESETTABLE.SubAddress, (int)(counter - 1), ref isResettable);
if (libraryError.IsError())
return libraryError;
if (!isResettable)
return FUNCTION_NOT_ALLOWED_ERROR;
- libraryError = PLC_WStrobe(COUNTER_IS_RESETTABLE_ACK, COUNTER_IS_RESETTABLE_STROBE, counter);
+ libraryError = PLC_WStrobe(false, COUNTER_IS_RESETTABLE_ACK, COUNTER_IS_RESETTABLE_STROBE, counter);
if (libraryError.IsError())
return libraryError;
@@ -1010,16 +992,16 @@ namespace CMS_CORE_Library.S7Net
public override CmsError PLC_RM154Data(ref List data, ref bool MTCOnOff)
{
- // FIXME TODO - levare?
+ // FIXME TODO - levare? inserito anche endiannes
MTCOnOff = false;
- CmsError libraryError = MEM_RWBoolean(R, 0, M154_SWITCH_ONOFF.MemType, M154_SWITCH_ONOFF.Address, M154_SWITCH_ONOFF.SubAddress, 1, ref MTCOnOff);
+ CmsError libraryError = MEM_RWBoolean(R, true, 0, M154_SWITCH_ONOFF.MemType, M154_SWITCH_ONOFF.Address, M154_SWITCH_ONOFF.SubAddress, 1, ref MTCOnOff);
if (libraryError.IsError())
return libraryError;
byte val = 0;
- libraryError = MEM_RWByte(R, 0, M154_STROBE.MemType, M154_STROBE.Address, M154_STROBE.SubAddress, 0, ref val);
+ libraryError = MEM_RWByte(R, true, 0, M154_STROBE.MemType, M154_STROBE.Address, M154_STROBE.SubAddress, 0, ref val);
if (libraryError.IsError())
return libraryError;
@@ -1053,7 +1035,7 @@ namespace CMS_CORE_Library.S7Net
public override CmsError PLC_W154ManageAck(int processId)
{
- return PLC_ManageActiveAck(M154_STROBE.Address, M154_STROBE.SubAddress, processId - 1, M154_ACK.Address, M154_ACK.SubAddress, processId - 1, M154_STROBE.MemType);
+ return PLC_ManageActiveAck(M154_STROBE.Address, M154_STROBE.SubAddress, processId - 1, M154_ACK.Address, M154_ACK.SubAddress, processId - 1, M154_STROBE.MemType, true);
}
@@ -1061,7 +1043,7 @@ namespace CMS_CORE_Library.S7Net
{
byte val = 0;
List vals = new List();
- CmsError libraryError = MEM_RWByte(R, 0, M156_INPUT_NEEDED.MemType, M156_INPUT_NEEDED.Address, M156_INPUT_NEEDED.SubAddress, 0, ref val);
+ CmsError libraryError = MEM_RWByte(R, true, 0, M156_INPUT_NEEDED.MemType, M156_INPUT_NEEDED.Address, M156_INPUT_NEEDED.SubAddress, 0, ref val);
if (libraryError.IsError())
return libraryError;
@@ -1106,11 +1088,8 @@ namespace CMS_CORE_Library.S7Net
public override CmsError PLC_WM156Response(int process, double responseVal)
{
- //CmsError libraryError = MEM_RWDouble(W, 0, MEMORY_TYPE.Osai_GD, 900 + (process - 1), ref responseVal);
- //if (libraryError.IsError())
- // return libraryError;
-
- return PLC_WStrobe(M156_INPUT_ACK, M156_INPUT_STROBE, (uint)process);
+ // FIXME TODO verifica se endianness vada gestita o meno (qui FALSE)
+ return PLC_WStrobe(false, M156_INPUT_ACK, M156_INPUT_STROBE, (uint)process);
}
public override CmsError PLC_RScadaValue(string memIndex, SCADA_MEM_TYPE memType, ref object value)
@@ -1160,17 +1139,21 @@ namespace CMS_CORE_Library.S7Net
value = val;
}
else
- { // read BYTE
+ {
+ // FIXME TODO verificare endianness (qui true)
+ // read BYTE
byte val = 0;
- libraryError = MEM_RWByte(R, 0, MEMORY_TYPE.Siemens_DB, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), 0, ref val);
+ libraryError = MEM_RWByte(R, true, 0, MEMORY_TYPE.Siemens_DB, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), 0, ref val);
value = val;
}
}
else if (index.Count() == 3 && memType == SCADA_MEM_TYPE.BOOL)
- { // read BOOL
+ {
+ // FIXME TODO verificare endianness, qui false
+ // read BOOL
bool val = false;
- libraryError = MEM_RWBoolean(R, 0, MEMORY_TYPE.Siemens_DB, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), Convert.ToInt32(index[2]), ref val);
+ libraryError = MEM_RWBoolean(R, false, 0, MEMORY_TYPE.Siemens_DB, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), Convert.ToInt32(index[2]), ref val);
value = val;
}
@@ -1214,15 +1197,17 @@ namespace CMS_CORE_Library.S7Net
libraryError = MEM_RWDouble(W, 0, MEMORY_TYPE.Siemens_DB, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), ref val);
}
else
- { // write byte
+ {
+ // write byte
byte val = Convert.ToByte(value);
- libraryError = MEM_RWByte(W, 0, MEMORY_TYPE.Siemens_DB, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), 0, ref val);
+ libraryError = MEM_RWByte(W, true, 0, MEMORY_TYPE.Siemens_DB, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), 0, ref val);
}
}
else if (index.Count() == 3 && memType == SCADA_MEM_TYPE.BOOL)
- { // write BOOL
+ {
+ // write BOOL
bool val = Convert.ToBoolean(value);
- libraryError = MEM_RWBoolean(W, 0, MEMORY_TYPE.Siemens_DB, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), Convert.ToInt32(index[2]), ref val);
+ libraryError = MEM_RWBoolean(W, false, 0, MEMORY_TYPE.Siemens_DB, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), Convert.ToInt32(index[2]), ref val);
}
return libraryError;
@@ -1245,11 +1230,12 @@ namespace CMS_CORE_Library.S7Net
///
/// Write strobe and manage ack from PLC
///
+ /// Apply endianness swap (word=yes, bitArray=no)
///
///
///
///
- private CmsError PLC_WStrobe(MEMORY_CELL ackCell, MEMORY_CELL strobeCell, uint id)
+ private CmsError PLC_WStrobe(bool fixEndian, MEMORY_CELL ackCell, MEMORY_CELL strobeCell, uint id)
{
CmsError libraryError;
bool readValue = false;
@@ -1258,7 +1244,7 @@ namespace CMS_CORE_Library.S7Net
SetupAckStrobeAddresses(ackCell.SubAddress, strobeCell.SubAddress, id, out int ackByte, out int strobeByte, out int alarmBitId);
// Check Strobe
- libraryError = MEM_RWBoolean(R, 0, strobeCell.MemType, strobeCell.Address, strobeByte, alarmBitId, ref readValue);
+ libraryError = MEM_RWBoolean(R, fixEndian, 0, strobeCell.MemType, strobeCell.Address, strobeByte, alarmBitId, ref readValue);
if (libraryError.IsError())
return libraryError;
@@ -1267,7 +1253,7 @@ namespace CMS_CORE_Library.S7Net
return NO_ERROR;
// Check ACK
- libraryError = MEM_RWBoolean(R, 0, ackCell.MemType, ackCell.Address, ackByte, alarmBitId, ref readValue);
+ libraryError = MEM_RWBoolean(R, fixEndian, 0, ackCell.MemType, ackCell.Address, ackByte, alarmBitId, ref readValue);
if (libraryError.IsError())
return libraryError;
@@ -1276,12 +1262,12 @@ namespace CMS_CORE_Library.S7Net
return NO_ERROR;
// Write strobe into memory
- libraryError = MEM_RWBoolean(W, 0, strobeCell.MemType, strobeCell.Address, strobeByte, alarmBitId, ref writeValue);
+ libraryError = MEM_RWBoolean(W, fixEndian, 0, strobeCell.MemType, strobeCell.Address, strobeByte, alarmBitId, ref writeValue);
if (libraryError.IsError())
return libraryError;
// Reset wait ack = 1 and reset the strobe
- libraryError = ResetStrobe(alarmBitId, strobeByte, ackByte, ackCell.MemType);
+ libraryError = ResetStrobe(alarmBitId, strobeByte, ackByte, ackCell.MemType, fixEndian);
if (libraryError.IsError())
return libraryError;
@@ -1290,11 +1276,12 @@ namespace CMS_CORE_Library.S7Net
///
/// Write ack for strobe received from PLC
///
+ /// Apply endianness swap (word=yes, bitArray=no)
///
///
///
///
- private CmsError PLC_WAck(MEMORY_CELL ackCell, MEMORY_CELL strobeCell, uint id)
+ private CmsError PLC_WAck(bool fixEndian, MEMORY_CELL ackCell, MEMORY_CELL strobeCell, uint id)
{
CmsError libraryError;
bool readValue = false;
@@ -1303,7 +1290,7 @@ namespace CMS_CORE_Library.S7Net
SetupAckStrobeAddresses(ackCell.SubAddress, strobeCell.SubAddress, id, out int ackByte, out int strobeByte, out int alarmBitId);
// Check Strobe
- libraryError = MEM_RWBoolean(R, 0, strobeCell.MemType, strobeCell.Address, strobeByte, alarmBitId, ref readValue);
+ libraryError = MEM_RWBoolean(R, fixEndian, 0, strobeCell.MemType, strobeCell.Address, strobeByte, alarmBitId, ref readValue);
if (libraryError.IsError())
return libraryError;
@@ -1311,7 +1298,7 @@ namespace CMS_CORE_Library.S7Net
if (readValue)
{
// abbasso ack se fosse su...
- libraryError = MEM_RWBoolean(W, 0, ackCell.MemType, ackCell.Address, ackByte, alarmBitId, ref writeValue);
+ libraryError = MEM_RWBoolean(W, fixEndian, 0, ackCell.MemType, ackCell.Address, ackByte, alarmBitId, ref writeValue);
if (libraryError.IsError())
return libraryError;
@@ -1319,7 +1306,7 @@ namespace CMS_CORE_Library.S7Net
Thread.Sleep(50);
// Reset wait ack = 1 and reset the strobe
- libraryError = ResetAck(alarmBitId, strobeByte, ackByte, ackCell.MemType);
+ libraryError = ResetAck(alarmBitId, strobeByte, ackByte, ackCell.MemType, fixEndian);
if (libraryError.IsError())
return libraryError;
@@ -1332,12 +1319,12 @@ namespace CMS_CORE_Library.S7Net
///
/// Setup memory for ack/strobe processing
///
- ///
- ///
- ///
- ///
- ///
- /// 1..8
+ /// base addr for ack zone
+ /// base addr for strobe zone
+ /// parameters to set (id 1...n)
+ /// ack byte to use (OUT)
+ /// strobe byte to use (out)
+ /// bit 1..8
private void SetupAckStrobeAddresses(int ackAddress, int strobeAddress, uint id, out int ackByte, out int strobeByte, out int bit)
{
ackByte = ackAddress + (((int)id - 1) / 8);
@@ -1345,7 +1332,7 @@ namespace CMS_CORE_Library.S7Net
bit = (((int)id - 1) % 8);
}
- private CmsError ResetStrobe(int bitId, int strobeByte, int ackByte, MEMORY_TYPE memType)
+ private CmsError ResetStrobe(int bitId, int strobeByte, int ackByte, MEMORY_TYPE memType, bool fixEndian)
{
int n = 600;
bool readValue = false;
@@ -1356,7 +1343,7 @@ namespace CMS_CORE_Library.S7Net
do
{
// Check ACK
- libraryError = MEM_RWBoolean(R, 0, memType, TABLE, ackByte, bitId, ref readValue);
+ libraryError = MEM_RWBoolean(R, fixEndian, 0, memType, TABLE, ackByte, bitId, ref readValue);
if (libraryError.IsError())
return libraryError;
@@ -1364,7 +1351,7 @@ namespace CMS_CORE_Library.S7Net
if (readValue == true)
{
// Reset strobe
- libraryError = MEM_RWBoolean(W, 0, memType, TABLE, strobeByte, bitId, ref writeValue);
+ libraryError = MEM_RWBoolean(W, fixEndian, 0, memType, TABLE, strobeByte, bitId, ref writeValue);
if (libraryError.IsError())
return libraryError;
// Exit from cycle
@@ -1383,14 +1370,14 @@ namespace CMS_CORE_Library.S7Net
if (!ok)
{
// Reset strobe
- libraryError = MEM_RWBoolean(W, 0, memType, TABLE, strobeByte, bitId, ref writeValue);
+ libraryError = MEM_RWBoolean(W, fixEndian, 0, memType, TABLE, strobeByte, bitId, ref writeValue);
if (libraryError.IsError())
return libraryError;
}
return libraryError;
}
- private CmsError ResetAck(int bitId, int strobeByte, int ackByte, MEMORY_TYPE memType)
+ private CmsError ResetAck(int bitId, int strobeByte, int ackByte, MEMORY_TYPE memType, bool fixEndian)
{
int n = 600;
bool readValue = false;
@@ -1404,7 +1391,7 @@ namespace CMS_CORE_Library.S7Net
do
{
// Check Strobe
- libraryError = MEM_RWBoolean(R, 0, memType, TABLE, strobeByte, bitId, ref readValue);
+ libraryError = MEM_RWBoolean(R, fixEndian, 0, memType, TABLE, strobeByte, bitId, ref readValue);
if (libraryError.IsError())
return libraryError;
@@ -1412,7 +1399,7 @@ namespace CMS_CORE_Library.S7Net
if (readValue == false)
{
// Reset strobe
- libraryError = MEM_RWBoolean(W, 0, memType, TABLE, ackByte, bitId, ref writeValue);
+ libraryError = MEM_RWBoolean(W, fixEndian, 0, memType, TABLE, ackByte, bitId, ref writeValue);
if (libraryError.IsError())
return libraryError;
// Exit from cycle
@@ -1433,7 +1420,7 @@ namespace CMS_CORE_Library.S7Net
{
// Reset ack (forced)
writeValue = false;
- libraryError = MEM_RWBoolean(W, 0, memType, TABLE, ackByte, bitId, ref writeValue);
+ libraryError = MEM_RWBoolean(W, fixEndian, 0, memType, TABLE, ackByte, bitId, ref writeValue);
if (libraryError.IsError())
return libraryError;
}
@@ -1441,21 +1428,21 @@ namespace CMS_CORE_Library.S7Net
return libraryError;
}
- private CmsError PLC_ManageActiveAck(int strobeByte, int strobeSubByte, int strobeBit, int ackByte, int ackSubByte, int ackBit, MEMORY_TYPE memType)
+ private CmsError PLC_ManageActiveAck(int strobeByte, int strobeSubByte, int strobeBit, int ackByte, int ackSubByte, int ackBit, MEMORY_TYPE memType, bool fixEndian)
{
int n = 1200; // 30 seconds
bool readValue = false;
bool writeValue = true;
bool ok = false;
// Set ack to 1
- CmsError libraryError = MEM_RWBoolean(W, 0, memType, ackByte, ackSubByte, ackBit, ref writeValue);
+ CmsError libraryError = MEM_RWBoolean(W, fixEndian, 0, memType, ackByte, ackSubByte, ackBit, ref writeValue);
if (libraryError.IsError())
return libraryError;
do
{
// Check strobe
- libraryError = MEM_RWBoolean(R, 0, memType, strobeByte, strobeSubByte, strobeBit, ref readValue);
+ libraryError = MEM_RWBoolean(R, fixEndian, 0, memType, strobeByte, strobeSubByte, strobeBit, ref readValue);
if (libraryError.IsError())
return libraryError;
@@ -1464,7 +1451,7 @@ namespace CMS_CORE_Library.S7Net
{
writeValue = false;
// Reset acknowledge
- libraryError = MEM_RWBoolean(W, 0, memType, ackByte, ackSubByte, ackBit, ref writeValue);
+ libraryError = MEM_RWBoolean(W, fixEndian, 0, memType, ackByte, ackSubByte, ackBit, ref writeValue);
if (libraryError.IsError())
return libraryError;
// Exit from cycle
@@ -1485,7 +1472,7 @@ namespace CMS_CORE_Library.S7Net
{
// Reset acknowledge
writeValue = false;
- libraryError = MEM_RWBoolean(W, 0, memType, ackByte, ackSubByte, ackBit, ref writeValue);
+ libraryError = MEM_RWBoolean(W, fixEndian, 0, memType, ackByte, ackSubByte, ackBit, ref writeValue);
if (libraryError.IsError())
return libraryError;
}
@@ -1498,7 +1485,7 @@ namespace CMS_CORE_Library.S7Net
bool newVal = false;
//Scrivo il dato
- CmsError libraryError = MEM_RWBoolean(W, 0, EXP_CANDY_MEM.MemType, EXP_CANDY_MEM.Address, EXP_CANDY_MEM.SubAddress, 5, ref value);
+ CmsError libraryError = MEM_RWBoolean(W, true, 0, EXP_CANDY_MEM.MemType, EXP_CANDY_MEM.Address, EXP_CANDY_MEM.SubAddress, 5, ref value);
if (libraryError.IsError())
return libraryError;
else
@@ -1519,7 +1506,7 @@ namespace CMS_CORE_Library.S7Net
public override CmsError PLC_RExpiredCandy(ref bool value)
{
- CmsError libraryError = MEM_RWBoolean(R, 0, EXP_CANDY_MEM.MemType, EXP_CANDY_MEM.Address, EXP_CANDY_MEM.SubAddress, 5, ref value);
+ CmsError libraryError = MEM_RWBoolean(R, true, 0, EXP_CANDY_MEM.MemType, EXP_CANDY_MEM.Address, EXP_CANDY_MEM.SubAddress, 5, ref value);
if (libraryError.IsError())
return libraryError;
return NO_ERROR;
@@ -1583,7 +1570,7 @@ namespace CMS_CORE_Library.S7Net
return libraryError;
byte readValues = 0;
- libraryError = MEM_RWByte(R, 0, ACTIVE_CLIENT.MemType, ACTIVE_CLIENT.Address, ACTIVE_CLIENT.SubAddress, 0, ref readValues);
+ libraryError = MEM_RWByte(R, true, 0, ACTIVE_CLIENT.MemType, ACTIVE_CLIENT.Address, ACTIVE_CLIENT.SubAddress, 0, ref readValues);
if (libraryError.IsError())
return libraryError;
@@ -1806,7 +1793,7 @@ namespace CMS_CORE_Library.S7Net
return INCORRECT_PARAMETERS_ERROR;
// Write process number
- libraryError = MEM_RWByte(W, 0, SELECT_PROCESS.MemType, SELECT_PROCESS.Address, SELECT_PROCESS.SubAddress, 0, ref processNum);
+ libraryError = MEM_RWByte(W, true, 0, SELECT_PROCESS.MemType, SELECT_PROCESS.Address, SELECT_PROCESS.SubAddress, 0, ref processNum);
if (libraryError.IsError())
return libraryError;
@@ -1979,7 +1966,7 @@ namespace CMS_CORE_Library.S7Net
CmsError libraryError = NO_ERROR;
// Call ack for config request RISK
- libraryError = PLC_WAck(REQ_CONF_ACK, REQ_CONF_STROBE, 8);
+ libraryError = PLC_WAck(true, REQ_CONF_ACK, REQ_CONF_STROBE, 8);
if (libraryError.IsError())
return libraryError;
@@ -1994,7 +1981,7 @@ namespace CMS_CORE_Library.S7Net
CmsError libraryError = NO_ERROR;
// Call ack for config request RECIPE
- libraryError = PLC_WAck(REQ_CONF_ACK, REQ_CONF_STROBE, 9);
+ libraryError = PLC_WAck(true, REQ_CONF_ACK, REQ_CONF_STROBE, 9);
if (libraryError.IsError())
return libraryError;
@@ -2009,7 +1996,7 @@ namespace CMS_CORE_Library.S7Net
CmsError libraryError = NO_ERROR;
// Call ack for prod update
- libraryError = PLC_WAck(REQ_CONF_ACK, REQ_CONF_STROBE, 4);
+ libraryError = PLC_WAck(true, REQ_CONF_ACK, REQ_CONF_STROBE, 4);
if (libraryError.IsError())
return libraryError;
@@ -2024,7 +2011,7 @@ namespace CMS_CORE_Library.S7Net
CmsError libraryError = NO_ERROR;
// Call ack for prod update
- libraryError = PLC_WAck(REQ_CONF_ACK, REQ_CONF_STROBE, 11);
+ libraryError = PLC_WAck(true, REQ_CONF_ACK, REQ_CONF_STROBE, 11);
if (libraryError.IsError())
return libraryError;
@@ -2039,7 +2026,7 @@ namespace CMS_CORE_Library.S7Net
CmsError libraryError = NO_ERROR;
// Call ack for prod update
- libraryError = PLC_WAck(REQ_CONF_ACK, REQ_CONF_STROBE, 12);
+ libraryError = PLC_WAck(true, REQ_CONF_ACK, REQ_CONF_STROBE, 12);
if (libraryError.IsError())
return libraryError;
@@ -2147,7 +2134,7 @@ namespace CMS_CORE_Library.S7Net
if (confirmUpdate)
{
// Call confirm update
- CmsError libraryError = PLC_WStrobe(PARAMETER_EDIT_ACK, PARAMETER_EDIT_STROBE, 2);
+ CmsError libraryError = PLC_WStrobe(true, PARAMETER_EDIT_ACK, PARAMETER_EDIT_STROBE, 2);
if (libraryError.IsError())
return libraryError;
}
@@ -2155,7 +2142,7 @@ namespace CMS_CORE_Library.S7Net
else
{
// Call cancel update
- CmsError libraryError = PLC_WStrobe(PARAMETER_EDIT_ACK, PARAMETER_EDIT_STROBE, 3);
+ CmsError libraryError = PLC_WStrobe(true, PARAMETER_EDIT_ACK, PARAMETER_EDIT_STROBE, 3);
if (libraryError.IsError())
return libraryError;
}
@@ -2309,7 +2296,7 @@ namespace CMS_CORE_Library.S7Net
if (doReset)
{
// send strobe of NEW WorkOrder / reset QTY
- libraryError = PLC_WStrobe(PROD_ACK, PROD_STROBE, 10);
+ libraryError = PLC_WStrobe(true, PROD_ACK, PROD_STROBE, 10);
if (libraryError.IsError())
return libraryError;
}
@@ -3150,7 +3137,7 @@ namespace CMS_CORE_Library.S7Net
if (mode == 1)
{
// Call confirm update
- CmsError libraryError = PLC_WStrobe(REQ_MODE_ACK, REQ_MODE_STROBE, 6);
+ CmsError libraryError = PLC_WStrobe(true, REQ_MODE_ACK, REQ_MODE_STROBE, 6);
if (libraryError.IsError())
return libraryError;
}
@@ -3158,7 +3145,7 @@ namespace CMS_CORE_Library.S7Net
if (mode == 2)
{
// Call confirm update
- CmsError libraryError = PLC_WStrobe(REQ_MODE_ACK, REQ_MODE_STROBE, 5);
+ CmsError libraryError = PLC_WStrobe(true, REQ_MODE_ACK, REQ_MODE_STROBE, 5);
if (libraryError.IsError())
return libraryError;
}
@@ -3166,7 +3153,7 @@ namespace CMS_CORE_Library.S7Net
if (mode == 3)
{
// Call confirm update
- CmsError libraryError = PLC_WStrobe(REQ_MODE_ACK, REQ_MODE_STROBE, 7);
+ CmsError libraryError = PLC_WStrobe(true, REQ_MODE_ACK, REQ_MODE_STROBE, 7);
if (libraryError.IsError())
return libraryError;
}
@@ -3238,7 +3225,7 @@ namespace CMS_CORE_Library.S7Net
#region NC Low-level function: single valiable in memory
//Read-Write a Boolean-Value inside the NC.
- public override CmsError MEM_RWBoolean(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemBit, ref bool Value)
+ public override CmsError MEM_RWBoolean(bool bWrite, bool fixEndian, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemBit, ref bool Value)
{
//Check if the NC is Connected
CmsError libraryError = CheckConnection();
@@ -3254,7 +3241,7 @@ namespace CMS_CORE_Library.S7Net
ushort pow = (ushort)Math.Pow(2, MemBit);
//Read the Byte where is the bit
- libraryError = MEM_RWByte(R, Process, MemType, MemTable, MemIndex, 0, ref bValue);
+ libraryError = MEM_RWByte(R, fixEndian, Process, MemType, MemTable, MemIndex, 0, ref bValue);
if (libraryError.IsError())
return libraryError;
@@ -3266,7 +3253,7 @@ namespace CMS_CORE_Library.S7Net
else
bValue = (byte)(bValue & ~(1 << MemBit));
- libraryError = MEM_RWByte(W, Process, MemType, MemTable, MemIndex, 0, ref bValue);
+ libraryError = MEM_RWByte(W, fixEndian, Process, MemType, MemTable, MemIndex, 0, ref bValue);
if (libraryError.IsError())
return libraryError;
}
@@ -3282,7 +3269,8 @@ namespace CMS_CORE_Library.S7Net
///
/// Read-Write a SINGLE Byte inside the NC. In writing-mode the field "Number" is not required
///
- ///
+ /// R/W mode
+ /// fix endianness
///
///
///
@@ -3290,7 +3278,7 @@ namespace CMS_CORE_Library.S7Net
///
///
///
- public override CmsError MEM_RWByte(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByte, ref byte Value)
+ public override CmsError MEM_RWByte(bool bWrite, bool fixEndian, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByte, ref byte Value)
{
//Check if the NC is Connected
CmsError libraryError = CheckConnection();
@@ -3304,9 +3292,14 @@ namespace CMS_CORE_Library.S7Net
libraryError = null;
- // attenzione endianness! invertire byte...
- int fixIndex = MemIndex % 2 == 0 ? MemIndex + 1 : MemIndex - 1;
+ // attenzione endianness! inverte byte se richiesto...
+ int fixIndex = MemIndex;
+ if (fixEndian)
+ {
+ fixIndex = MemIndex % 2 == 0 ? MemIndex + 1 : MemIndex - 1;
+ }
+ // vere operazioni R/W
if (bWrite)
{
// try/catch
@@ -4732,14 +4725,14 @@ namespace CMS_CORE_Library.S7Net
internal static MEMORY_CELL USER_SOFTKEYS_VALUE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6552, 16);
internal static MEMORY_CELL USER_SOFTKEYS_CLICKABLE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6568, 16);
internal static MEMORY_CELL USER_SOFT_KEYS_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6584, 16);
- internal static MEMORY_CELL USER_SOFT_KEYS_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6616, 16);
+ internal static MEMORY_CELL USER_SOFT_KEYS_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6600, 16);
internal static MEMORY_CELL ALARMS_STATUS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 14, 128);
internal static MEMORY_CELL ALARMS_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 142, 1024);
internal static MEMORY_CELL ALARM_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2190, 128);
internal static MEMORY_CELL ALARM_RESTORATION_STROBE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2318, 128);
- internal static MEMORY_CELL ALARM_REFRESH_STROBE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2446, 128);
+ internal static MEMORY_CELL ALARM_REFRESH_STROBE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2318, 128);