Example #1
0
            private int[] StringToIntWordList(string data, int wordLength, char space)
            {
                List <int> byteArray = new List <int>();
                string     temp      = data;

                temp = temp.PadRight(wordLength * 2, space);


                char[] charArray = temp.ToCharArray();
                string word      = "";

                for (int i = 0; i < charArray.Length; i++)
                {
                    word = string.Format("{1}{0}", charArray[i++], charArray[i]);
                    byteArray.Add(int.Parse(PLCUtils.HexToDec(PLCUtils.StringToHex(word))));
                }

                return(byteArray.ToArray());
            }
Example #2
0
        public List <int> PanelInfoToHex(string pnlInfo)
        {
            if (pnlInfo == null)
            {
                return(null);
            }

            List <int> hexData = new List <int>();

            if (pnlInfo.Length % 2 != 0)
            {
                pnlInfo += " ";
            }

            for (int i = 0; i < pnlInfo.Length; i += 2)
            {
                string temp  = PLCUtils.AsciiToHex(pnlInfo.Substring(i, 2));
                int    iTemp = Convert.ToInt32(PLCUtils.HexToDec(temp));
                hexData.Add(iTemp);
            }

            return(hexData);
        }