/// <inheritdoc cref="IGXPacketHandler.ExecuteSendCommand"/> public void ExecuteSendCommand(object sender, string command, Gurux.Communication.GXPacket packet) { ulong id = 0; if (command == "ReadData") { GXDLT645Property prop = sender as GXDLT645Property; id = prop.DataID; } else if (command == "ReadTableRowsCount") { if (m_Items == null) { m_Items = GXDLT645Property.ReadDataID(); } RowIndex = RowCount = 0; GXDLT645Table table = sender as GXDLT645Table; table.ClearRows(); id = table.DataID; } else if (command == "ReadTable" || command == "ReadTableNext") { GXDLT645Table table = sender as GXDLT645Table; ++RowIndex; id = table.DataID + RowIndex; } else { throw new Exception("ExecuteCommand failed. Unknown command: " + command); } packet.AppendData(Device.Parser.ReadValue(id)); }
public void ExecuteSendCommand(object sender, string command, Gurux.Communication.GXPacket packet) { GXModbusProperty prop = sender as GXModbusProperty; bool ascii = (prop.Device as GXModbusDevice).Ascii; UInt16 address = prop.Address; byte functionCode = (byte)prop.Function; if (command == "ModbusRead") { packet.AppendData(GetValue(functionCode, ascii)); packet.AppendData(GetValue(address, ascii)); packet.AppendData(GetValue((UInt16)1, ascii)); } else if (command == "ModbusWrite") { switch (functionCode) { case 1: functionCode = 5; break; case 3: functionCode = 6; break; } WriteFailed = false; packet.AppendData(GetValue(functionCode, ascii)); packet.AppendData(GetValue(address, ascii)); object value = GetWriteData(prop, functionCode); packet.AppendData(GetValue(value, ascii)); } //Read value type if write failed. else if (command == "ModbusFailedWrite") { if (WriteFailed) { packet.AppendData(GetValue(functionCode, ascii)); packet.AppendData(GetValue(address, ascii)); packet.AppendData(GetValue((UInt16)1, ascii)); } } }