public string WriteMsg()
        {
            UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0');
            UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0');
            UserDataAll += Iden_F1.GetHexStr();
            if (List_RTUParam != null)
            {
                foreach (RTUParam rp in List_RTUParam)
                {
                    UserDataAll += rp.GetHexStr();
                }
            }

            byte[]             UserDataBytesAllTmp;
            WaterBaseMessage[] MsgListTmp;
            string             msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp);

            if (msg == "")
            {
                UserDataBytesAll = UserDataBytesAllTmp;
                MsgList          = MsgListTmp;
            }
            else
            {
                if (ShowLog)
                {
                    logHelper.Error(msg);
                }
            }
            return(msg);
        }
Пример #2
0
        public string WriteMsg()
        {
            UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0');
            UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0');
            UserDataAll += Iden_F1.GetHexStr();
            Identifier_45 iden = new Identifier_45();

            iden.AlarmStateV = "0".PadLeft(32, '0');
            iden.AlarmStateV = (isUsed ? "1" : "0").PadRight(10, '0').PadLeft(32, '0');
            UserData        += iden.GetHexStr();

            byte[]             UserDataBytesAllTmp;
            WaterBaseMessage[] MsgListTmp;
            string             msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp);

            if (msg == "")
            {
                UserDataBytesAll = UserDataBytesAllTmp;
                MsgList          = MsgListTmp;
            }
            else
            {
                if (ShowLog)
                {
                    logHelper.Error(msg);
                }
            }
            return(msg);
        }
Пример #3
0
        public string WriteMsg()
        {
            UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0');
            UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0');
            UserDataAll += Iden_F1.GetHexStr();
            for (int i = 0; i < stateDec.Length; i++)
            {
                if (States.Count > i)
                {
                    UserDataAll += States[i].ToString("X").PadLeft(4, '0');
                }
                else
                {
                    UserDataAll += "0000";
                }
            }

            byte[]             UserDataBytesAllTmp;
            WaterBaseMessage[] MsgListTmp;
            string             msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp);

            if (msg == "")
            {
                UserDataBytesAll = UserDataBytesAllTmp;
                MsgList          = MsgListTmp;
            }
            else
            {
                if (ShowLog)
                {
                    logHelper.Error(msg);
                }
            }
            return(msg);
        }
Пример #4
0
        public string WriteMsg()
        {
            UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0');
            UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0');
            UserDataAll += Iden_F1.GetHexStr();
            VersionL     = (byte)HexStringUtility.StrToByteArray(VersionC).Length;
            UserDataAll += VersionL.ToString("X").PadLeft(2, '0');
            UserDataAll += HexStringUtility.StrToHexString(VersionC);

            byte[]             UserDataBytesAllTmp;
            WaterBaseMessage[] MsgListTmp;
            string             msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp);

            if (msg == "")
            {
                UserDataBytesAll = UserDataBytesAllTmp;
                MsgList          = MsgListTmp;
            }
            else
            {
                if (ShowLog)
                {
                    logHelper.Error(msg);
                }
            }
            return(msg);
        }
Пример #5
0
        public string WriteMsg()
        {
            UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0');
            UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0');
            UserDataAll += Iden_F1.GetHexStr();

            int count = Ps.Length < PsOpen.Length ? Ps.Length : PsOpen.Length;

            UserData += count.ToString("X").PadLeft(2, '0');
            string s = "";

            for (int i = 0; i < count; i++)
            {
                if (Ps[i])
                {
                    s = "1" + s;
                }
                else
                {
                    s = "0" + s;
                }
            }
            s         = s.PadLeft(8 * ((count - 1) / 8 + 1), '0');
            UserData += HexStringUtility.BinStringToHexString(s);

            for (int i = 0; i < count; i++)
            {
                if (PsOpen[i] <= 9999)
                {
                    UserData += PsOpen[i].ToString().PadLeft(4, '0');
                }
                else if (PsOpen[i] > 9999)
                {
                    UserData += PsOpen[i].ToString().Substring(PsOpen[i].ToString().Length - 4);
                }
            }

            byte[]             UserDataBytesAllTmp;
            WaterBaseMessage[] MsgListTmp;
            string             msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp);

            if (msg == "")
            {
                UserDataBytesAll = UserDataBytesAllTmp;
                MsgList          = MsgListTmp;
            }
            else
            {
                if (ShowLog)
                {
                    logHelper.Error(msg);
                }
            }
            return(msg);
        }
Пример #6
0
        public string WriteMsg()
        {
            if (Iden_04 == null)
            {
                return("时间步长码出错");
            }
            UserDataAll  = "";
            UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0');
            UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0');

            /*
             * UserDataAll += HexStringUtility.ByteArrayToHexString(new byte[] { 0xF1, 0xF1 });
             * UserDataAll += RemoteStation.PadLeft(10, '0');
             * UserDataAll += StationType.ToString("X").PadLeft(2, '0');
             * */
            UserDataAll += Iden_F1.GetHexStr();

            /*
             * UserDataAll += HexStringUtility.ByteArrayToHexString(new byte[] { 0xF0, 0xF0 });
             * UserDataAll += ObsTime.ToString("yyMMddHHmm").PadLeft(10, '0');
             * */
            UserDataAll += Iden_F0.GetHexStr();
            UserDataAll += Iden_04.GetHexStr();
            if (Idens != null && Idens.Count > 0)
            {
                UserDataAll += Idens[0].GetHexStrHead();
                if (Idens[0].GetKey() != (byte)Identifier_Standard._FF)
                {
                    foreach (Identifier obj in Idens)
                    {
                        UserDataAll += obj.GetHexStr().Substring(4);
                    }
                }
                else
                {
                    foreach (Identifier obj in Idens)
                    {
                        UserDataAll += obj.GetHexStr().Substring(6);
                    }
                }
            }
            else
            {
                return("无有效数据");
            }

            byte[]             UserDataBytesAllTmp;
            WaterBaseMessage[] MsgListTmp;
            string             msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp);

            if (msg == "")
            {
                UserDataBytesAll = UserDataBytesAllTmp;
                MsgList          = MsgListTmp;
            }
            else
            {
                if (ShowLog)
                {
                    logHelper.Error(msg);
                }
            }
            return(msg);
        }