示例#1
0
        public void KbdData(string param, string data)
        {
            App      p   = Application.Current as App;
            XElement cfg = p.curr_cfg;

            if (param == "entersys")
            {
                if (Password.compare_pwd("admin", data))
                {
                    Process app = new Process();
                    app.StartInfo.FileName  = "Explorer.exe";
                    app.StartInfo.Arguments = "";
                    app.Start();
                    Thread.Sleep(2000);
                    Type   shellType   = Type.GetTypeFromProgID("Shell.Application");
                    object shellObject = System.Activator.CreateInstance(shellType);
                    shellType.InvokeMember("ToggleDesktop", System.Reflection.BindingFlags.InvokeMethod, null, shellObject, null);
                }
                return;
            }
            if (param == "quitlock")
            {
                if (Password.compare_pwd("lock", data))
                {
                    b_lockon = false;
                    Password.set_pwd("lock", "0");
                    b_lockon = false;
                    (Application.Current as App).runwnd.Disable(Visibility.Visible);
                    (Application.Current as App).singlewnd.Disable(Visibility.Visible);
                    UpdateDisplay(true);
                }
            }
            if (param == "enterlock")
            {
                //App should expire after desired packer number reached , data is the actual packer count
                Password.set_pwd("lock_on", data);
                DeleteRegist("lock_on");
                WTRegedit("lock_on", data);
                Password.set_pwd("lock", data);
                p.SaveAppConfig();
                b_lockon = true;
                UpdateDisplay(false);
            }
            if (param.IndexOf("reg_") == 0)
            {
                Button  btn;
                SubNode n = null;
                if (curr_sel == -1)
                {
                    return;
                }
                Byte i = Convert.ToByte(curr_sel);

                if (i < 17)
                {
                    btn = IdToButton(i.ToString());
                    n   = p.agent[i];
                }
                else
                {
                    btn = IdToButton("36");
                    n   = p.agent.missingnode;
                }
                if (n["addr"] != null)
                {
                    param    = param.Remove(0, 4);
                    n[param] = UInt32.Parse(data);
                    Thread.Sleep(1000);


                    btn_refreshreg_Click(null, null);
                }
            }
            if (param.IndexOf("chgnd_") == 0)
            {
                Byte oldaddr = Byte.Parse(param.Remove(0, 6));
                Byte newaddr = Byte.Parse(data);

                Button btn = IdToButton(newaddr.ToString());
                if (btn != null && newaddr < 36) //valid new address
                {
                    if (btn.Visibility != Visibility.Visible)
                    {
                        SubNode oldn;
                        SubNode newn;
                        if (oldaddr == 36)
                        {
                            oldn = p.agent.missingnode;
                        }
                        else
                        {
                            oldn = p.agent[oldaddr];
                        }
                        newn                   = p.agent[newaddr];
                        newaddr               += 0xC0;
                        newn.status            = NodeStatus.ST_IDLE;
                        oldn["test_mode_reg2"] = newaddr;

                        Thread.Sleep(500);
                        newn.status  = NodeStatus.ST_IDLE;
                        newn["addr"] = null;
                        oldn.status  = NodeStatus.ST_LOST;
                        Thread.Sleep(100);
                        if (newn["addr"].HasValue)
                        {
                            MessageBox.Show(StringResource.str("change_addr_success"));
                            return;
                        }
                    }
                }

                MessageBox.Show(StringResource.str("change_addr_fail"));
            }
            if (param != "cali0" && (param.IndexOf("cali") == 0)) //cali1 to cali10
            {
                string msg = StringResource.str("put_poise") + "(" + data + StringResource.str("gram") + ")";

                if (MessageBox.Show(msg, "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    return;
                }
                NodeAgent n = p.agent;
                int       i = RunMode.StringToId(param) - 1;
                if (curr_sel >= 0)
                {
                    n.ClearNodeReg((byte)curr_sel, "cs_mtrl");
                    string cs_mtrl_val = n.GetNodeReg((byte)curr_sel, "cs_mtrl");
                    UInt32 val;
                    if (UInt32.TryParse(cs_mtrl_val, out val))
                    {
                        if (val <= WeighNode.MAX_VALID_WEIGHT)
                        {
                            if (i < 5)
                            {
                                n.SetNodeReg((byte)curr_sel, "poise_weight_gram" + i.ToString(), UInt32.Parse(cs_mtrl_val));
                            }
                            else
                            {
                                n.SetNodeReg((byte)curr_sel, "cs_poise" + (i - 5).ToString(), UInt32.Parse(cs_mtrl_val));
                            }
                            n.Action((byte)curr_sel, "flash");
                            MessageBox.Show(StringResource.str("calidone"));
                            label3_MouseLeftButtonUp(null, null);
                            return;
                        }
                    }
                    MessageBox.Show(StringResource.str("tryagain"));
                }
                return;
            }
        }
示例#2
0
        private void calibrate(string calreg)
        {
            App  p = Application.Current as App;
            Byte i = Convert.ToByte(curr_sel);

            if (curr_sel == -1)
            {
                return;
            }
            if (calreg == "cali0")
            {
                NodeAgent n = p.agent;
                if (curr_sel >= 0)
                {
                    if (MessageBox.Show(StringResource.str("put_empty"), "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                    {
                        return;
                    }

                    n.ClearNodeReg(i, "cs_mtrl");
                    string cs_mtrl_val = n.GetNodeReg(i, "cs_mtrl");
                    UInt32 val         = UInt32.Parse(cs_mtrl_val);
                    if (val <= WeighNode.MAX_VALID_WEIGHT)
                    {
                        n.SetNodeReg(i, "cs_zero", UInt32.Parse(cs_mtrl_val));
                        n.Action(i, "flash");
                        MessageBox.Show(StringResource.str("calidone"));
                        label3_MouseLeftButtonUp(null, null);
                    }
                    else
                    {
                        MessageBox.Show(StringResource.str("tryagain"));
                    }
                }
            }
            if (calreg == "empty")
            {
                NodeAgent n = p.agent;
                if (curr_sel >= 0)
                {
                    n.Action(i, "empty");
                }
                return;
            }
            if (calreg == "cali1")
            {
                KbdData(calreg, "20");
            }
            if (calreg == "cali2")
            {
                KbdData(calreg, "50");
            }
            if (calreg == "cali3")
            {
                KbdData(calreg, "100");
            }
            if (calreg == "cali4")
            {
                KbdData(calreg, "200");
            }
            if (calreg == "cali5")
            {
                KbdData(calreg, "300");
            }
            if (calreg == "cali6")
            {
                KbdData(calreg, "400");
            }
            if (calreg == "cali7")
            {
                KbdData(calreg, "500");
            }
            if (calreg == "cali8")
            {
                KbdData(calreg, "700");
            }
            if (calreg == "cali9")
            {
                KbdData(calreg, "900");
            }
            if (calreg == "cali10")
            {
                KbdData(calreg, "1000");
            }
            //p.WeightAction(i, "query"); //update the readings
        }
示例#3
0
 public void BottomAction(string command)
 {
     agent.Action(bot_addr, command);
 }