Beispiel #1
0
        public void send_basic_info()
        {
            ModbusMessageDataCreator creator = new ModbusMessageDataCreator();

            creator.addKeyPair("SetType", "BasicInfo");
            creator.addKeyPair("DeviceType", EnumHelper.getDeviceTypeString(this.CurrentDeviceType));

            /*
             * if (this.CurrentDeviceType == DeviceType.Dispen)
             * {
             *  if (((autodispendevice)this).subtype == autodispendevice.autodispentype.peiyangmin)
             *      creator.addkeypair("subtype", "peiyangmin");
             *  else
             *      creator.addkeypair("subtype", "shenkongban");
             * }*/
            creator.addKeyPair("IP", this.IP);
            creator.addKeyPair("Name", this.Name);
            creator.addKeyPair("IdentifyID", this.IdentifyID);
            creator.addKeyPair("SerialID", this.SerialID);
            creator.addKeyPair("Code", this.Code);
            String        msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes());
            ModbusMessage mod = ModbusMessageHelper.decodeModbusMessage(msg);

            this.SendMsg(msg);
        }
Beispiel #2
0
        public virtual void decodeResponseMessage(ModbusMessage s)
        {
            ModbusMessageDataCreator creator = new ModbusMessageDataCreator();

            creator.addKeyPair("Result", "OK");
            string msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.RESPONSE), creator.getDataBytes());

            this.SendMsg(msg);
        }
Beispiel #3
0
        /*加入新的数据接口函数*/
        public void SendModBusMsg(ModbusMessage.MessageType type, String key, Object value)
        {
            ModbusMessageDataCreator creator = new ModbusMessageDataCreator();

            creator.addKeyPair(key, (String)value);
            string msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(type), creator.getDataBytes());

            this.SendMsg(msg);
        }
Beispiel #4
0
        public void SendModBusMsg(ModbusMessage.MessageType type, Hashtable htable)
        {
            ModbusMessageDataCreator creator = new ModbusMessageDataCreator();

            foreach (DictionaryEntry de in htable)
            {
                creator.addKeyPair((string)de.Key, (string)de.Value);
            }
            string msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(type), creator.getDataBytes());

            this.SendMsg(msg);
        }
Beispiel #5
0
 public void send_basic_info()
 {
     ModbusMessageDataCreator creator = new ModbusMessageDataCreator();
     creator.addKeyPair("SetType", "BasicInfo");
     creator.addKeyPair("DeviceType", EnumHelper.getDeviceTypeString(this.CurrentDeviceType));
     //if (this.CurrentDeviceType == DeviceType.Dispen)
     //{
     //    if (((AutoDispenTwincatDevice)this).SubType == AutoDispenTwincatDevice.AutoDispenType.PeiYangMin)
     //        creator.addKeyPair("SubType", "PeiYangMin");
     //    else
     //        creator.addKeyPair("SubType", "ShenKongBan");
     //}
     creator.addKeyPair("IP", this.IP);
     creator.addKeyPair("Name", this.Name);
     creator.addKeyPair("IdentifyID", this.IdentifyID);
     creator.addKeyPair("SerialID", this.SerialID);
     creator.addKeyPair("Code", this.Code);
     String msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes());
     adsClient.WriteAny(handleMap[cmdString],msg,new int[]{ConstSettings.StringLength});
 }
Beispiel #6
0
        public void send_basic_info()
        {
            ModbusMessageDataCreator creator = new ModbusMessageDataCreator();

            creator.addKeyPair("SetType", "BasicInfo");
            creator.addKeyPair("DeviceType", EnumHelper.getDeviceTypeString(this.CurrentDeviceType));
            //if (this.CurrentDeviceType == DeviceType.Dispen)
            //{
            //    if (((AutoDispenTwincatDevice)this).SubType == AutoDispenTwincatDevice.AutoDispenType.PeiYangMin)
            //        creator.addKeyPair("SubType", "PeiYangMin");
            //    else
            //        creator.addKeyPair("SubType", "ShenKongBan");
            //}
            creator.addKeyPair("IP", this.IP);
            creator.addKeyPair("Name", this.Name);
            creator.addKeyPair("IdentifyID", this.IdentifyID);
            creator.addKeyPair("SerialID", this.SerialID);
            creator.addKeyPair("Code", this.Code);
            String msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes());

            adsClient.WriteAny(handleMap[cmdString], msg, new int[] { ConstSettings.StringLength });
        }
Beispiel #7
0
 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());
 }
Beispiel #8
0
 /*加入新的数据接口函数*/
 public void SendModBusMsg(ModbusMessage.MessageType type, String key, Object value)
 {
     ModbusMessageDataCreator creator = new ModbusMessageDataCreator();
     creator.addKeyPair(key, (String)value);
     string msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(type), creator.getDataBytes());
     this.SendMsg(msg);
 }
Beispiel #9
0
 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());
 }
Beispiel #10
0
 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());
 }
Beispiel #11
0
 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());
 }
Beispiel #12
0
 public static String createOKResponse()
 {
     ModbusMessageDataCreator creator = new ModbusMessageDataCreator();
     creator.addKeyPair("Result", "OK");
     return ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.RESPONSE), creator.getDataBytes());
 }
Beispiel #13
0
 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());
 }
Beispiel #14
0
 public void SendModBusMsg(ModbusMessage.MessageType type, Hashtable htable)
 {
     ModbusMessageDataCreator creator = new ModbusMessageDataCreator();
     foreach (DictionaryEntry de in htable)
     {
         creator.addKeyPair((string)de.Key, (string)de.Value);
     }
     string msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(type), creator.getDataBytes());
     this.SendMsg(msg);
 }
Beispiel #15
0
 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());
 }
Beispiel #16
0
 public virtual void decodeResponseMessage(ModbusMessage s)
 {
     ModbusMessageDataCreator creator = new ModbusMessageDataCreator();
     creator.addKeyPair("Result", "OK");
     string msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.RESPONSE), creator.getDataBytes());
     this.SendMsg(msg);
 }
Beispiel #17
0
 public void send_basic_info()
 {
     ModbusMessageDataCreator creator = new ModbusMessageDataCreator();
     creator.addKeyPair("SetType", "BasicInfo");
     creator.addKeyPair("DeviceType", EnumHelper.getDeviceTypeString(this.CurrentDeviceType));
     /*
     if (this.CurrentDeviceType == DeviceType.Dispen)
     {
         if (((autodispendevice)this).subtype == autodispendevice.autodispentype.peiyangmin)
             creator.addkeypair("subtype", "peiyangmin");
         else
             creator.addkeypair("subtype", "shenkongban");
     }*/
     creator.addKeyPair("IP", this.IP);
     creator.addKeyPair("Name", this.Name);
     creator.addKeyPair("IdentifyID", this.IdentifyID);
     creator.addKeyPair("SerialID", this.SerialID);
     creator.addKeyPair("Code", this.Code);
     String msg = ModbusMessageHelper.createModbusMessage(ModbusMessage.messageTypeToByte(ModbusMessage.MessageType.SET), creator.getDataBytes());
     ModbusMessage mod = ModbusMessageHelper.decodeModbusMessage(msg);
     this.SendMsg(msg);
 }
Beispiel #18
0
 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());
 }
Beispiel #19
0
 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());
 }