Added M156 management for S7Net (2 test!!!)
This commit is contained in:
@@ -1045,9 +1045,10 @@ namespace CMS_CORE_Library.S7Net
|
||||
return PLC_ManageActiveAck(M154_STROBE.Address, M154_STROBE.SubAddress, processId - 1, M154_ACK.Address, M154_ACK.SubAddress, processId - 1, M154_STROBE.MemType, true);
|
||||
}
|
||||
|
||||
|
||||
public override CmsError PLC_RM156Data(ref List<M156InputIsNeededModel> value)
|
||||
{
|
||||
// NB: da verificare se sia corretto o meno come BIT ARRAY...
|
||||
|
||||
byte val = 0;
|
||||
List<byte> vals = new List<byte>();
|
||||
CmsError libraryError = MEM_RWByte(R, true, 0, M156_INPUT_NEEDED.MemType, M156_INPUT_NEEDED.Address, M156_INPUT_NEEDED.SubAddress, 0, ref val);
|
||||
@@ -1060,33 +1061,25 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
bool[] bits = ByteToBits(val);
|
||||
|
||||
for (int processId = 1; processId <= MAX_PROCESS_NUMBER; processId++)
|
||||
// FORZO: 1 solo processo
|
||||
//for (int processId = 1; processId <= MAX_PROCESS_NUMBER; processId++)
|
||||
for (int processId = 1; processId <= 1; processId++)
|
||||
{
|
||||
if (bits[processId - 1])
|
||||
{
|
||||
#if false
|
||||
Item item = new Item()
|
||||
{
|
||||
Path = string.Format("/channel/parameter/r[c{0} , 154]", processId),
|
||||
};
|
||||
try
|
||||
{
|
||||
DataSvc dataSvc = new DataSvc();
|
||||
dataSvc.Read(item);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ManageException(ex);
|
||||
}
|
||||
|
||||
// leggo x compatibilità la risposta standard
|
||||
double responseVal = 0;
|
||||
// Read machine variable
|
||||
libraryError = MEM_RWDouble(R, 0, M156_RESPONSE_MEMORY.MemType, M156_RESPONSE_MEMORY.Address, M156_RESPONSE_MEMORY.SubAddress + (int)processId - 1, ref responseVal);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
// Parse line & get parameters
|
||||
value.Add(new M156InputIsNeededModel()
|
||||
{
|
||||
Process = (uint)processId,
|
||||
Id = vals.ElementAt(processId - 1),
|
||||
Value = Convert.ToDouble(item.Value)
|
||||
});
|
||||
#endif
|
||||
Value = responseVal
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1095,6 +1088,12 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
public override CmsError PLC_WM156Response(int process, double responseVal)
|
||||
{
|
||||
// forzo process a 1...
|
||||
process = 1;
|
||||
CmsError libraryError = MEM_RWDouble(W, 0, M156_RESPONSE_MEMORY.MemType, M156_RESPONSE_MEMORY.Address, M156_RESPONSE_MEMORY.SubAddress + (int)process - 1, ref responseVal);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
// FIXME TODO verifica se endianness vada gestita o meno (qui FALSE)
|
||||
return PLC_WStrobe(false, M156_INPUT_ACK, M156_INPUT_STROBE, (uint)process);
|
||||
}
|
||||
@@ -4823,10 +4822,11 @@ namespace CMS_CORE_Library.S7Net
|
||||
//internal static MEMORY_CELL M155_INPUT_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3015, 1);
|
||||
//internal static MEMORY_CELL M155_INPUT_STROBE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3016, 1);
|
||||
|
||||
internal static MEMORY_CELL M156_INPUT_NEEDED = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4333, 1);
|
||||
internal static MEMORY_CELL M156_INPUT_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4335, 1);
|
||||
internal static MEMORY_CELL M156_INPUT_STROBE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4337, 1);
|
||||
internal static MEMORY_CELL M156_INPUT_ID_LIST = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4339, 8);
|
||||
internal static MEMORY_CELL M156_INPUT_NEEDED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6768, 1);
|
||||
internal static MEMORY_CELL M156_INPUT_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6770, 1);
|
||||
internal static MEMORY_CELL M156_INPUT_STROBE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6772, 1);
|
||||
internal static MEMORY_CELL M156_INPUT_ID_LIST = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6774, 2);
|
||||
internal static MEMORY_CELL M156_RESPONSE_MEMORY = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6776, 4);
|
||||
|
||||
internal static MEMORY_CELL M154_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3042, 1);
|
||||
internal static MEMORY_CELL M154_STROBE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3043, 1);
|
||||
|
||||
Reference in New Issue
Block a user