public override void ReceiveMsg(String s) { ModbusMessage message = ModbusMessageHelper.decodeModbusMessage(s); switch (message.MsgType) { case ModbusMessage.MessageType.RESPONSE: decodeResponseMessage(message); break; case ModbusMessage.MessageType.CMD: decodeCmdMessage(message); break; case ModbusMessage.MessageType.REPORT: decodeReportMessage(message); break; case ModbusMessage.MessageType.SET: decodeSetMessage(message); break; case ModbusMessage.MessageType.GET: break; } }
public static String createCmd(String cmd) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("Cmd", cmd); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.CMD), creator.getDataBytes())); }
private void decodeBasicMsg(String s) { ModbusMessage message = ModbusMessageHelper.decodeModbusMessage(s); DeviceType type = EnumHelper.deviceStringToDeviceType((String)message.Data["DeviceType"]); BaseVirtualDevice device = (BaseVirtualDevice)VirtualDeviceFactory.createVirtualDevice(type, true); device.IsVirt = true; device.CurrentDeviceType = type; /* * if (type == DeviceType.Dispen) * { * String subType = (String)message.Data["SubType"]; * if ("PeiYangMin".Equals(subType)) * { * ((AutoDispenVirtualDevice)device).SubType = AutoDispenVirtualDevice.AutoDispenType.PeiYangMin; * } * else * { * ((AutoDispenVirtualDevice)device).SubType = AutoDispenVirtualDevice.AutoDispenType.ShenKongBan; * } * }*/ device.IdentifyID = (String)message.Data["IdentifyID"]; device.Code = (String)message.Data["Code"]; device.IP = (String)message.Data["IP"]; device.Name = (String)message.Data["Name"]; device.SerialID = (String)message.Data["SerialID"]; device.MySocket = mySocket; device.DeviceManager = deviceManager; device.init(); deviceManager.addDevice(device); }
public override void ReceiveMsg(String s) { ModbusMessage message = ModbusMessageHelper.decodeModbusMessage(s); //switch (message.MsgType) { } }
public static String createOKResponse() { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("Result", "OK"); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.RESPONSE), creator.getDataBytes())); }
public static String createStopMsg(int moduleNum) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "Stop"); creator.addKeyPair("moduleNum", moduleNum.ToString()); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createODReport(String OD) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("ReportType", "OD"); creator.addKeyPair("OD", OD); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.REPORT), creator.getDataBytes())); }
public static String createSetMode(String s) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "Mode"); creator.addKeyPair("Mode", s); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createDeployStatus(String LHS_PlateStatus) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "LHS_PlateStatus"); creator.addKeyPair("LHS_PlateStatus", LHS_PlateStatus); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createSetLight(String pwm, String allightText) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "Light"); creator.addKeyPair("Light_pwm", pwm); creator.addKeyPair("Light_allighText", allightText); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createSetSystem(String Mode, String Command) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "System"); creator.addKeyPair("Sys_Mode", Mode); creator.addKeyPair("Sys_Command", Command); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createCodeReport(String Add_Num, String Rem_Num) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("ReportType", "Code"); creator.addKeyPair("Add_Num", Add_Num); creator.addKeyPair("Rem_Num", Rem_Num); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.REPORT), creator.getDataBytes())); }
public static String createSetMianJiLowAndUpp(String Lower, String Upper) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "MianJiShaiXuan"); creator.addKeyPair("MianJi_Max", Upper); creator.addKeyPair("MianJi_Min", Lower); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createWeiZhiConfirmMsg(String LHS_LiquidPosition, String LHS_DischargePosition) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "weiZhiSheZhi"); creator.addKeyPair("LHS_LiquidPosition", LHS_LiquidPosition); creator.addKeyPair("LHS_DischargePosition", LHS_DischargePosition); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createSuDuConfirmMsg(String LHS_LiquidRate, String LHS_DischargeRate) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "suDuSheZhi"); creator.addKeyPair("LHS_LiquidRate", LHS_LiquidRate); creator.addKeyPair("LHS_DischargeRate", LHS_DischargeRate); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createMuBiaoConfirmMsg(String LHS_SuctionPlate, String LHS_TargetPlate, String LHS_Imbitition) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "yiYeWeiZhi"); creator.addKeyPair("LHS_SuctionPlate", LHS_SuctionPlate); creator.addKeyPair("LHS_TargetPlate", LHS_TargetPlate); creator.addKeyPair("LHS_Imbitition", LHS_Imbitition); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createSetMotor(String text_speed, String elecspeed, String slope) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "Motor"); creator.addKeyPair("Motor_text_speed", text_speed); creator.addKeyPair("Motor_elecspeed", elecspeed); creator.addKeyPair("Motor_slope", slope); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createSystemReport(String DeviceInfo, String Status, String Batch_Info) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("ReportType", "System"); creator.addKeyPair("Sys_DeviceInfo", DeviceInfo); creator.addKeyPair("Sys_Status", Status); creator.addKeyPair("Sys_Batch_Info", Batch_Info); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.REPORT), creator.getDataBytes())); }
public static String createResponseMsg(int moduleNum, int tpR, int phR, int doR) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "Response"); creator.addKeyPair("moduleNum", moduleNum.ToString()); creator.addKeyPair("tpR", tpR.ToString()); creator.addKeyPair("phR", phR.ToString()); creator.addKeyPair("doR", doR.ToString()); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.RESPONSE), creator.getDataBytes())); }
public static String createMotorReport(String Status, String text_speed, String elecspeed, String Power) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("ReportType", "Motor"); creator.addKeyPair("Motor_Status", Status); creator.addKeyPair("Motor_text_speed", text_speed); creator.addKeyPair("Motor_elecspeed", elecspeed); creator.addKeyPair("Motor_Power", Power); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.REPORT), creator.getDataBytes())); }
public override void ReceiveMsg(String s) { ModbusMessage message = ModbusMessageHelper.decodeModbusMessage(s); switch (message.MsgType) { case ModbusMessage.MessageType.RESPONSE: decodeResponseMessage(message); break; } }
public override void ReceiveMsg(String s) { ModbusMessage message = ModbusMessageHelper.decodeModbusMessage(s); switch (message.MsgType) { case ModbusMessage.MessageType.SET: decodeSetMessage(message); break; } }
public static String createJianCeZhiReport(int b, float[] v) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("ReportType", "Value"); for (int i = 0; i < v.Length; i++) { creator.addKeyPair("v" + b, v[i].ToString()); b++; } return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.REPORT), creator.getDataBytes())); }
public static String createSetMieJun(String arg1, String arg2, String arg3, String arg4, String arg5) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "MieJunHeQingXi"); creator.addKeyPair("JiaReShiJian", arg1); creator.addKeyPair("QingXiCiShu", arg2); creator.addKeyPair("LengQueShiJian", arg3); creator.addKeyPair("QingXiShiJian", arg4); creator.addKeyPair("ChouQiShiJian", arg5); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
public static String createSettingMsg(int moduleNum, int speed, int temp, int time, int air, int pressure) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "Setting"); creator.addKeyPair("moduleNum", moduleNum.ToString()); creator.addKeyPair("speed", speed.ToString()); creator.addKeyPair("temp", temp.ToString()); creator.addKeyPair("time", time.ToString()); creator.addKeyPair("air", air.ToString()); creator.addKeyPair("pressure", pressure.ToString()); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }
private bool ReceiveBasicMsg(String s) { ModbusMessage message = ModbusMessageHelper.decodeModbusMessage(s); if (message.MsgType == ModbusMessage.MessageType.SET) { String setType = (String)message.Data["SetType"]; if ("BasicInfo".Equals(setType)) { return(true); } } return(false); }
public static String createTHReport(String temperature1, String temperature2, String temperature3, String humidity1, String humidity2) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("ReportType", "TH"); creator.addKeyPair("TH_temperature1", temperature1); creator.addKeyPair("TH_temperature2", temperature2); creator.addKeyPair("TH_temperature3", temperature3); creator.addKeyPair("TH_humidity1", humidity1); creator.addKeyPair("TH_humidity2", humidity2); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.REPORT), creator.getDataBytes())); }
private void handleNotification(object sender, AdsNotificationExEventArgs e) { String s = (String)e.UserData; int handle = handleMap[s]; if (s.Equals("MAIN.MDF_RunningError")) { YunXingChuCuoBiaoZhi = (int)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_online_state")) { } if (s.Equals("MAIN.MDF_Command_response")) { String msg = (String)adsClient.ReadAny(handle, nameDict[s], new int[] { ConstSettings.StringLength }); ModbusMessage message = ModbusMessageHelper.decodeModbusMessage(msg); switch (message.MsgType) { case ModbusMessage.MessageType.RESPONSE: decodeResponseMessage(message); break; case ModbusMessage.MessageType.REPORT: decodeReportMessage(message); break; case ModbusMessage.MessageType.SET: decodeSetMessage(message); break; } } if (s.Equals("MAIN.MDF_Motor_1_cur")) { MDF_Current1 = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_Motor_2_cur")) { MDF_Current2 = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_Motor_3_cur")) { MDF_Current3 = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_Motor_4_cur")) { } }
public static String createKongBanReport(bool YouKongBan, String TiaoMaHao) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("ReportType", "YouKongBan"); String f = ""; if (YouKongBan) { f = "1"; } else { f = "0"; } creator.addKeyPair("Flag", f); if (YouKongBan) { creator.addKeyPair("TiaoMaHao", TiaoMaHao); } return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.REPORT), creator.getDataBytes())); }
public static String createSetTH_1(String tempset, String htempchaval, String ltempchaval, String syso_change, String htempalarmval, String ltempalarmval, String compressormode, String compressorsituation) { ModbusMessageDataCreator creator = new ModbusMessageDataCreator(); creator.addKeyPair("SetType", "TH_1"); creator.addKeyPair("TH_htempchaval", htempchaval); creator.addKeyPair("TH_tempset", tempset); creator.addKeyPair("TH_ltempchaval", ltempchaval); creator.addKeyPair("TH_syso_change", syso_change); creator.addKeyPair("TH_htempalarmval", htempalarmval); creator.addKeyPair("TH_ltempalarmval", ltempalarmval); creator.addKeyPair("TH_compressormode", compressormode); creator.addKeyPair("TH_compressorsituation", compressorsituation); return(ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes())); }