Beispiel #1
0
        /// <summary>
        /// 写入单个寄存器的值
        /// </summary>
        /// <param name="beginAddress">地址</param>
        /// <param name="values">值</param>
        /// <returns></returns>
        public static string DTAddressWriteConvert(int beginAddress, int values)
        {
            string address    = "%01#WDD";
            string writeValue = DecimalConversion.Ten2Hex(values.ToString()).PadLeft(4, '0');

            address  = address + beginAddress.ToString().PadLeft(5, '0') + beginAddress.ToString().PadLeft(5, '0');
            address += writeValue.Substring(2, 2) + writeValue.Substring(0, 2);
            return(address + "**");
        }
Beispiel #2
0
        /// <summary>
        /// 写入多个寄存器的值
        /// </summary>
        /// <param name="beginAddress"></param>
        /// <param name="endAddress"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public static string DTAddressWriteConvert(int beginAddress, List <string> values)
        {
            string address = "%01#WDD";// "%01#RDD0030100309**";

            //string writeValue = DecimalConversion.Ten2Hex(values.ToString()).PadLeft(4, '0');
            address = address + beginAddress.ToString().PadLeft(5, '0') + (beginAddress + values.Count).ToString().PadLeft(5, '0');
            for (int i = 0; i < values.Count; i++)
            {
                string value = DecimalConversion.Ten2Hex(values[i]).PadLeft(4, '0');
                address += value.Substring(2, 2) + value.Substring(0, 2);
            }
            return(address + "**");
        }
Beispiel #3
0
        public static List <string> RuleDatalearning(string data)
        {
            List <string> list = new List <string>();

            for (int i = data.Length - 1; i >= 0; i--)
            {
                string s = data[i].ToString();
                if (s == "1")
                {
                    list.Add(DecimalConversion.Ten2Hex((data.Length - i - 1).ToString()));
                }
            }
            return(list);
        }