/// <summary> /// Creates a new Modbus command based on the element configuration. /// </summary> private ModbusCmd CreateModbusCmd(DeviceTemplateOptions options, ElemGroupConfig elemGroupConfig, ElemConfig elemConfig, int elemIndex) { ModbusCmd modbusCmd = deviceModel.CreateModbusCmd(elemGroupConfig.DataBlock, false); modbusCmd.Name = elemConfig.Name; modbusCmd.Address = (ushort)(elemGroupConfig.Address + elemIndex); modbusCmd.ElemType = elemConfig.ElemType; modbusCmd.ElemCnt = 1; modbusCmd.ByteOrder = ModbusUtils.ParseByteOrder(elemConfig.ByteOrder) ?? options.GetDefaultByteOrder(ModbusUtils.GetDataLength(elemConfig.ElemType)); modbusCmd.CmdNum = 0; modbusCmd.CmdCode = elemConfig.TagCode; modbusCmd.InitReqPDU(); modbusCmd.InitReqADU(deviceModel.Addr, transMode); return(modbusCmd); }