Exemplo n.º 1
0
        public void RefreshRunNodeUI() //node ui update at run time
        {
            lbl_status.Content = "";
            foreach (UIPacker pk in currentApp().packers)
            {
                foreach (byte naddr in pk.weight_nodes)
                {
                    string    param = "wei_node" + naddr.ToString();
                    Label     lb    = this.FindName(param) as Label;
                    Button    btn   = this.FindName(param.Replace("wei_node", "bucket")) as Button;
                    byte      n     = (byte)(RunMode.StringToId(param));
                    NodeAgent agent = pk.agent;

                    double wt = agent.weight(n);
                    if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT)
                    {
                        lb.Content = agent.weight(n).ToString("F1");
                    }

                    if (agent.GetStatus(n) == NodeStatus.ST_LOST || agent.GetStatus(n) == NodeStatus.ST_DISABLED)
                    {
                        btn.Template = this.FindResource("WeightBarError") as ControlTemplate;
                        btn.ApplyTemplate();
                    }
                    string err = agent.GetErrors(n);
                    if (err != "" && AlertWnd.b_turnon_alert && AlertWnd.b_show_alert)
                    {
                        lbl_status.Content = n.ToString() + ":" + StringResource.str(err.Substring(0, err.IndexOf(';'))) + "\n";
                    }
                }
                if (pk.status == PackerStatus.RUNNING)
                {
                    lbl_speed.Content      = pk.speed.ToString();
                    lbl_lastweight.Content = pk.last_pack_weight.ToString("F1");
                    lbl_totalpack.Content  = pk.total_packs.ToString();

                    RefreshVibUI();
                }
            }
            if (lbl_status.Content.ToString() == "")
            {
                lbl_status.Content    = StringResource.str("normal");
                lbl_status.Foreground = Brushes.Green;
            }
            else
            {
                lbl_status.Foreground = Brushes.Red;
                if (AlertWnd.b_turnon_alert && AlertWnd.b_stop_onalert && (curr_packer.status == PackerStatus.RUNNING))
                {
                    btn_start_click(null, null);
                }
            }
        }
Exemplo n.º 2
0
        private void RefreshNodeUI()
        {
            foreach (UIPacker pk in currentApp().packers)
            {
                foreach (byte naddr in pk.weight_nodes)
                {
                    string    param = "wei_node" + naddr.ToString();
                    Label     lb    = this.FindName(param) as Label;
                    Button    btn   = this.FindName(param.Replace("wei_node", "bucket")) as Button;
                    byte      n     = (byte)(RunMode.StringToId(param));
                    NodeAgent agent = currentApp().packers[pk._pack_id].agent;

                    double wt = agent.weight(n);
                    if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT)
                    {
                        lb.Content = agent.weight(n).ToString("F1");
                    }
                    else
                    {
                        if (wt > WeighNode.MAX_VALID_WEIGHT && wt < 65537)
                        {
                            lb.Content = "ERR";
                        }
                    }

                    if (agent.GetStatus(n) == NodeStatus.ST_LOST || agent.GetStatus(n) == NodeStatus.ST_DISABLED)
                    {
                        btn.Template = this.FindResource("WeightBarError") as ControlTemplate;
                    }
                    if (agent.GetStatus(n) == NodeStatus.ST_IDLE)
                    {
                        if (btn == curr_btn || bSelectAll)
                        {
                            btn.Template = this.FindResource("WeightBarFocus") as ControlTemplate;
                        }
                        else
                        {
                            btn.Template = this.FindResource("WeightBar") as ControlTemplate;
                        }
                    }
                    btn.ApplyTemplate();
                }
            }
            UIPacker p = curr_packer;

            if (p.status == PackerStatus.RUNNING)
            {
                lbl_speed.Content        = p.speed.ToString();
                lbl_lastweight.Content   = p.last_pack_weight.ToString("F1");
                lbl_totalpack.Content    = p.total_sim_packs.ToString();
                lbl_totalweights.Content = p.total_sim_weights.ToString("F1");
            }
        }
Exemplo n.º 3
0
        private void HitCombineNodeUI(CombineEventArgs ce)
        {
            foreach (byte naddr in currentApp().packers[ce.packer_id].weight_nodes)
            {
                string    param = "wei_node" + naddr.ToString();
                Label     lb    = this.FindName(param) as Label;
                Button    btn   = this.FindName(param.Replace("wei_node", "bucket")) as Button;
                byte      n     = (byte)(RunMode.StringToId(param));
                NodeAgent agent = currentApp().packers[ce.packer_id].agent;

                if (!ce.release_addrs.Contains(n))
                {
                    continue;
                }
                double wt = agent.weight(n);
                if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT)
                {
                    lb.Content = agent.weight(n).ToString("F1");
                }

                if (agent.GetStatus(n) == NodeStatus.ST_LOST || agent.GetStatus(n) == NodeStatus.ST_DISABLED)
                {
                    btn.Template = this.FindResource("WeightBarError") as ControlTemplate;
                }
                else
                {
                    if (n != curr_packer.vib_addr)
                    {
                        if (ce.release_addrs.Contains(n))
                        {
                            btn.Template = this.FindResource("WeightBarRelease") as ControlTemplate;
                        }
                        else
                        {
                            btn.Template = this.FindResource("WeightBar") as ControlTemplate;
                            if (agent.GetStatus(n) == NodeStatus.ST_IDLE)
                            {
                                if (btn == curr_btn || bSelectAll)
                                {
                                    btn.Template = this.FindResource("WeightBarFocus") as ControlTemplate;
                                }
                            }
                        }
                    }
                }

                btn.ApplyTemplate();
            }
        }
Exemplo n.º 4
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;
            }
        }