Beispiel #1
0
        public void Send(string cmd_id)
        {
            _sport.DiscardInBuffer();
            _sport.DiscardOutBuffer();
            spbuf.Remove(0, spbuf.Length);

            object o = cmdset.GetField("Navmeter", cmd_id, "sSTR");
            string ret;

            if (o is string)
            {
                ret = o as string;
            }
            else
            {
                return;
            }
            o = cmdset.GetField("Navmeter", cmd_id, "uPAUSE");
            UInt32 delay;

            if (o is UInt32)
            {
                delay = (UInt32)o;
            }
            else
            {
                return;
            }
            o = cmdset.GetField("Navmeter", cmd_id, "sVAR");
            string var;

            if (o is string)
            {
                var = o as string;
            }
            else
            {
                return;
            }
            vars[var] = cmd_id;
            ret       = "Un" + ret.Replace("U", "UU").Replace("\\n", "\n").Replace("\\r", "\r");
            byte[] b = new byte[1];
            foreach (char c in ret.ToCharArray())
            {
                if (c == '^')
                {
                    Thread.Sleep(10);
                }
                else
                {
                    b[0] = (Byte)c;
                    _sport.Write(b, 0, 1);
                    Thread.Sleep(1);
                }
            }
            Thread.Sleep(100);
        }
Beispiel #2
0
        public void Send(string cmdid)
        {
            if (cmdid == "RESET")
            {
                swis.Clear();
            }
            object o = cmdset.GetField("Switch", cmdid, "sSTR");
            string ret;

            if (o is string)
            {
                ret = o as string;
            }
            else
            {
                return;
            }
            string[] cmds = ret.Split(',');
            foreach (string scmd in cmds)
            {
                if (scmd[0] == 'O')
                {
                    string cmd = scmd.Substring(1, scmd.Length - 1);
                    if (swis.ContainsKey(cmd) && (swis[cmd] == true))
                    {
                        continue;
                    }
                    SingleSwitch(true, cmd);
                    swis[cmd] = true;
                }
                if (scmd[0] == 'F')
                {
                    string cmd = scmd.Substring(1, scmd.Length - 1);
                    if (swis.ContainsKey(cmd) && (swis[cmd] == false))
                    {
                        continue;
                    }
                    SingleSwitch(false, cmd);
                    swis[cmd] = false;
                }
            }
        }