Esempio n. 1
0
        public bool GetDInput(int address, ref short[] state)
        {
            bool isOk = false;

            if (address >= 0 && this.InputDAddress >= 0 && this.InputDCount > 0)
            {
                this.updateInputBuffer_D();

                int index = address - this.InputDAddress;
                if (this.inputBuffer_D != null && this.inputBuffer_D.Length > index)
                {
                    string strdata = McCommand.ShortArrayToASCIIString(false, inputBuffer_D);
                    state = McCommand.ASCIIStringToShortArray(strdata, false);
                    isOk  = true;
                }
            }
            return(isOk);
        }
Esempio n. 2
0
        private void read()
        {
            if (mcProtocol == null || !mcProtocol.IsConnected)
            {
                return;
            }

            short[] readData = new short[1];
            var     rtn      = mcProtocol.ExecuteRead("D", 1000, 10, ref readData);

            if (rtn != 0)
            {
                Console.WriteLine("Error code: " + rtn);
            }
            else
            {
                Console.WriteLine("Read success.");
                // Data format convert. All convert function in McCommand
                string strData    = McCommand.ShortArrayToASCIIString(false, readData[0]);
                string intDataStr = McCommand.ShortArrayToInt16String(readData[1]);
            }
        }
Esempio n. 3
0
 public string GetASCIIString(bool reverse)
 {
     return(McCommand.ShortArrayToASCIIString(reverse, this.RawValue));
 }