Exemplo n.º 1
0
 internal void pc_cmd(string cmd)
 {
     Logger.SysLog(cmd);
     if (cmd == "H")
     {
         DeviceMgr.Reset();
         return;
     }
     if (cmd == "resi?")
     {
         if (processor.bOn)
         {
             DeviceMgr.Report("resi: " + led_rx.Value + " on");
         }
         else
         {
             DeviceMgr.Report("resi: " + led_rx.Value + " off");
         };
         return;
     }
     Match m;
     //TODO add command list
 }
Exemplo n.º 2
0
        internal void pc_cmd(string cmd)
        {
            Logger.SysLog(cmd);
            if (cmd == "H")
            {
                DeviceMgr.Reset();
                return;
            }
            if (cmd == "resi?")
            {
                if (processor.bOn)
                {
                    DeviceMgr.Report("resi: " + led_ohm.Value + " on");
                }
                else
                {
                    DeviceMgr.Report("resi: " + led_ohm.Value + " off");
                };
                return;
            }
            if (cmd == "current?")
            {
                DeviceMgr.Report("curr: " + led_current.Value);
                return;
            }
            Match m;

            m = resi_set_mode.Match(cmd);
            if (m.Success)
            {
                string rvalue = m.Groups[1].ToString();
                if (Processor.real_title.Contains(rvalue))
                {
                    int i = 0;
                    for (i = 0; i < Processor.real_title.Length; i++)
                    {
                        if (rvalue == Processor.real_title[i])
                        {
                            break;
                        }
                    }
                    if (i >= Processor.real_title.Length)
                    {
                        return;
                    }

                    processor.iReal  = i;
                    processor.iRange = -1; //real case
                }
                else
                {
                    Decimal a;
                    if (!Util.TryDecimalParse(m.Groups[1].ToString(), out a))
                    {
                        return;
                    }
                    int newrange = Processor.CheckRange(a, -1);
                    if (newrange < 0)
                    {
                        return;
                    }
                    processor.iRange     = newrange;
                    processor.resistance = a;
                }
                processor.bOn = (m.Groups[2].ToString() == "on");
                return;
            }
        }
Exemplo n.º 3
0
        internal void pc_cmd(string cmd)
        {
            Logger.SysLog(cmd);
            if (cmd == "resi?")
            {
                if (processor.bOn)
                {
                    DeviceMgr.Report("resi: " + processor.resistance.ToString() + " on");
                }
                else
                {
                    DeviceMgr.Report("resi: " + processor.resistance.ToString() + " off");
                };
                return;
            }
            if (cmd == "current?")
            {
                DeviceMgr.Report("curr: " + led_current.Value);
                return;
            }
            if (cmd == "ZERO")
            {
                Program.mainwnd.processor.ZeroON();
            }
            if (cmd == "H")
            {
                DeviceMgr.Reset();
            }
            Match m;

            m = resi_set_mode.Match(cmd);
            if (m.Success)
            {
                string rvalue   = m.Groups[1].ToString();
                int    newrange = Int32.Parse(m.Groups[3].ToString());
                if (newrange < -1 || newrange > 3)
                {
                    return;
                }

                if (newrange == -1)
                {
                    int i = 0;
                    for (i = 0; i < Processor.real_title.Length; i++)
                    {
                        if (rvalue == Processor.real_title[i])
                        {
                            break;
                        }
                    }
                    if (i >= Processor.real_title.Length)
                    {
                        return;
                    }
                    processor.iRange = -1;
                    processor.iReal  = i;
                }
                else
                {
                    Decimal a;
                    if (!Util.TryDecimalParse(m.Groups[1].ToString(), out a))
                    {
                        return;
                    }
                    processor.iRange     = newrange;
                    processor.resistance = a;
                }
                processor.bOn = (m.Groups[2].ToString() == "on");
            }
            RefreshDisplay(true);
        }
Exemplo n.º 4
0
        internal void pc_cmd(string cmd)
        {
            Logger.SysLog(cmd);
            if (cmd == "*IDN?")
            {
                DeviceMgr.Report("RAYSTING RT" + s_scale + "A");
                return;
            }
            if (cmd == "H")
            {
                DeviceMgr.Reset();
                return;
            }
            if (cmd == "ZERO")
            {
                processor.ZeroON();
                return;
            }
            if (cmd == "curr?")
            {
                if (processor.bOn)
                {
                    DeviceMgr.Report("curr: " + led_current.Value + " on");
                }
                else
                {
                    DeviceMgr.Report("curr: " + led_current.Value + " off");
                }
                return;
            }
            Match m;

            m = resi_set_mode.Match(cmd);
            if (m.Success)
            {
                string  rvalue = m.Groups[1].ToString();
                Decimal a;
                if (!Util.TryDecimalParse(m.Groups[1].ToString(), out a))
                {
                    return;
                }
                if (!IsValidCurrent(a))     //range check
                {
                    return;
                }

                int rng = Int32.Parse(m.Groups[3].ToString());
                if (a > rng)
                {
                    return;
                }
                processor.range   = rng;
                processor.setting = a;
                processor.bOn     = (m.Groups[2].ToString() == "on");
                RefreshDisplay(true);
                cmd = "setting?";
            }
            if (cmd == "setting?")
            {
                if (processor.bOn)
                {
                    DeviceMgr.Report("setting: " + led_setting.Value + " on " + processor.range.ToString());
                }
                else
                {
                    DeviceMgr.Report("setting: " + led_setting.Value + " off " + processor.range.ToString());
                }
                return;
            }
        }