Esempio n. 1
0
        public void UpdateSysConfigUI()
        {
            App      p    = currentApp();
            UIPacker pack = curr_packer;

            this.input_uvar.Content = pack.curr_cfg.upper_var.ToString() + StringResource.str("gram");

            this.input_dvar.Content = pack.curr_cfg.lower_var.ToString() + StringResource.str("gram");

            this.lbl_weight.Content = pack.curr_cfg.target.ToString() + StringResource.str("gram");

            this.prd_no.Content = pack.curr_cfg.product_no.ToString();

            this.operator_no.Content = p.oper;

            this.prd_desc.Content = pack.curr_cfg.product_desc.ToString();

            ImageBrush ib = (this.FindName("ellipseWithImageBrush") as Rectangle).Fill as ImageBrush;
            //load the corresponding picture.
            string path_to_jpg = ProdNum.baseDir + "\\prodpic\\" + StringResource.language + "\\" + pack.curr_cfg.product_desc.ToString() + ".jpg";

            if (File.Exists(path_to_jpg))
            {
                ib.ImageSource = new BitmapImage(new Uri(path_to_jpg));
            }
            else
            {
                ib.ImageSource = new BitmapImage(new Uri(ProdNum.baseDir + "\\prodpic\\default.jpg"));
            }
        }
Esempio n. 2
0
        static internal void InitNewRun(UIPacker p)
        {
            string txtUpdate = "insert into mains (start_date,end_date,operator,product_no,product_desc,target,upper_var,lower_var,weight,pack_num) values ('";

            txtUpdate = txtUpdate + p.rStart.ToString("yyyy-MM-dd HH:mm:ss") + "','" + p.rStart.ToString("yyyy-MM-dd HH:mm:ss") + "','" + (System.Windows.Application.Current as App).oper + "','" + p.curr_cfg.product_no + "(" + p.curr_cfg.product_desc + ")" + "','" + p.curr_cfg.product_desc + "'," + p.curr_cfg.target.ToString() + "," + p.curr_cfg.upper_var.ToString() + "," + p.curr_cfg.lower_var.ToString() + ",0,0)";
            ExecuteQuery(txtUpdate);
        }
Esempio n. 3
0
        //update UI when a packer is hitted
        public void CombineNodeUI(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;

                NodeAgent agent = currentApp().packers[ce.packer_id].agent;

                //update weight first
                double wt = -100000;
                for (int i = 0; i < ce.release_addrs.Length; i++)
                {
                    if (ce.release_addrs[i] == naddr)
                    {
                        wt = ce.release_wts[i];
                        break;
                    }
                }

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

                //update status display
                if (agent.GetStatus(naddr) == NodeStatus.ST_LOST || agent.GetStatus(naddr) == NodeStatus.ST_DISABLED)
                {
                    btn.Template = this.FindResource("WeightBarError") as ControlTemplate;
                }
                else if (naddr != curr_packer.vib_addr)
                {
                    if (ce.release_addrs.Contains(naddr))
                    {
                        btn.Template = this.FindResource("WeightBarRelease") as ControlTemplate;
                    }
                    else
                    {
                        btn.Template = this.FindResource("WeightBar") as ControlTemplate;
                    }
                }
                btn.ApplyTemplate();
            }
            //Update speed information
            UIPacker p = currentApp().packers[ce.packer_id];

            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_packs.ToString();
                RefreshVibUI();
            }
        }
Esempio n. 4
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");
            }
        }
Esempio n. 5
0
 public void KbdData(string param, string data)
 {
     try
     {
         App      p    = Application.Current as App;
         UIPacker pack = curr_packer;
         if (param == "run_uvar")
         {
             pack.curr_cfg.upper_var = double.Parse(data);
             pack.SaveCurrentConfig(4);
         }
         if (param == "run_dvar")
         {
             pack.curr_cfg.lower_var = double.Parse(data);
             pack.SaveCurrentConfig(4);
         }
         if (param == "run_target")
         {
             pack.curr_cfg.target = Double.Parse(data);
             pack.UpdateEachNodeTarget();
             pack.SaveCurrentConfig(1 + 4);
         }
         if (param == "run_operator")
         {
             (Application.Current as App).oper = data;
             pack.SaveCurrentConfig(4);
         }
         if (param == "singlemode")
         {
             if (Password.compare_pwd("user", data))
             {
                 while (lastcall != "")
                 {
                     this.uiTimer_Tick(null, null);
                 }
                 p.SwitchTo("configmenu");
                 return;
             }
             else
             {
                 MessageBox.Show(StringResource.str("invalid_pwd"));
             }
         }
         UpdateSysConfigUI();
     }
     catch (System.Exception e)
     {
         MessageBox.Show("Invalid Parameter");
         return;
     }
 }
Esempio n. 6
0
        private void sub_applyall()
        {
            App       p     = Application.Current as App;
            UIPacker  pack  = curr_packer;
            NodeAgent agent = pack.agent;
            byte      cn    = (byte)curr_node_index;

            bool star = true;

            foreach (byte n in curr_packer.weight_nodes)
            {
                foreach (string reg in apply_regs.Distinct())
                {
                    if (agent.GetStatus(n) == NodeStatus.ST_LOST)
                    {
                        continue;
                    }
                    if (agent.GetStatus(n) == NodeStatus.ST_DISABLED)
                    {
                        continue;
                    }

                    if (n == cn)
                    {
                        continue;
                    }
                    UInt32 val = UInt32.Parse(curr_packer.agent.GetNodeReg(cn, reg));
                    if (!curr_packer.agent.SetNodeReg(n, reg, val))
                    {
                        return;
                    }

                    if (star)
                    {
                        Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, (Action) delegate
                        {
                            txt_oper.Content = StringResource.str("modifying") + " " + n.ToString() + "*";
                        });
                    }
                    else
                    {
                        Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, (Action) delegate
                        {
                            txt_oper.Content = StringResource.str("modifying") + " " + n.ToString();
                        });
                    }
                    star = !star;
                }
            }
            apply_regs.Clear();
        }
Esempio n. 7
0
        internal NodeCombination(UIPacker p)
        {
            packer = p;
            agent = p.agent;
            bRun = false;
            bSimNodeValid = new Dictionary<byte,bool>();
            foreach (byte i in packer.weight_nodes)
                bSimNodeValid[i] = true;
            bSimCombine = false;
            rand = new Random();
            comb_loop = new Thread(new ThreadStart(CombinationLoop));
            comb_loop.IsBackground = true;

        }
Esempio n. 8
0
        public void UpdateNodeUI(byte n)
        {
            App      p    = currentApp();
            UIPacker pack = curr_packer;

            //display the variable based on current setting
            Label  lb   = this.FindName("wei_node" + n) as Label;
            Button btn  = this.FindName("bucket" + n) as Button;
            Button pbtn = this.FindName("pass" + n) as Button;

            string err = pack.agent.GetErrors(n);
            double wt  = -1000;
            string ct  = "";

            if (err == "")
            {
                wt            = pack.agent.weight(n);
                ct            = wt.ToString("F1");
                pbtn.Template = this.FindResource("PassBar") as ControlTemplate;
                pbtn.ToolTip  = "";
                pbtn.ApplyTemplate();
            }
            else
            {
                if (AlertWnd.b_show_alert && AlertWnd.b_turnon_alert)
                {
                    pbtn.Template      = this.FindResource("PassBarError") as ControlTemplate;
                    pbtn.ToolTip       = StringResource.str(err.Substring(0, err.IndexOf(';')));
                    lbl_status.Content = StringResource.str(err.Substring(0, err.IndexOf(';'))) + "\n";
                    lb.Content         = StringResource.str(err.Substring(0, err.IndexOf(';')));//"ERR";
                    pbtn.ApplyTemplate();
                }
            }

            if (pack.agent.GetStatus(n) == NodeStatus.ST_LOST || pack.agent.GetStatus(n) == NodeStatus.ST_DISABLED)
            {
                btn.Template = this.FindResource("WeightBarError") as ControlTemplate;
                btn.ApplyTemplate();
            }
            if (pack.agent.GetStatus(n) == NodeStatus.ST_IDLE)
            {
                btn.Template = this.FindResource("WeightBar") as ControlTemplate;
                btn.ApplyTemplate();
            }
            if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT)
            {
                lb.Content = ct;
            }
        }
Esempio n. 9
0
        public App()
        {
            System.Diagnostics.Process[] pses = System.Diagnostics.Process.GetProcessesByName("ioex-cs");
            if (pses.Length > 0) 
            {
//                System.Diagnostics.Process.GetCurrentProcess().Kill();
//              return;
            }
            
            if (Environment.CommandLine.IndexOf("/debug") > 0)
                NodeAgent.IsDebug = true;
            StringResource.SetLanguage();
            //app_cfg = new XmlConfig(ProdNum.baseDir +"\\app_config.xml");
            app_cfg = new SqlConfig("app");
            app_cfg.LoadConfigFromFile();

            curr_cfg = app_cfg.Current;

            agent = new NodeAgent();
            packers = new List<UIPacker>();
            for (int i = 0; i < Int32.Parse(curr_cfg.Element("machine_number").Value); i++)
            {
                UIPacker p = new UIPacker(i, agent);
                p.agent = agent;
                p.InitConfig();
                packers.Add(p);
            }

            singlewnd = new SingleMode(Int32.Parse(curr_cfg.Element("node_number").Value));
            runwnd = new RunMode(Int32.Parse(curr_cfg.Element("node_number").Value));
            
            
            histwnd = new ProdHistory();
            helpwnd = new Help();
            kbdwnd = new kbd();
            bottomwnd = new BottomWnd();
            alertwnd = new AlertWnd();
            alertwnd.UpdateUI(); //load alert configuration which is in app_config.xml too

            pwdwnd = new PwdWnd();
            engwnd = new EngConfigWnd();
            configwnd = new ConfigMenuWnd();
            prodwnd = new ProdWnd();
            prodnum = new ProdNum();
            

        }
Esempio n. 10
0
        public App()
        {
            System.Diagnostics.Process[] pses = System.Diagnostics.Process.GetProcessesByName("ioex-cs");
            if (pses.Length > 0)
            {
//                System.Diagnostics.Process.GetCurrentProcess().Kill();
//              return;
            }

            if (Environment.CommandLine.IndexOf("/debug") > 0)
            {
                NodeAgent.IsDebug = true;
            }
            StringResource.SetLanguage();
            //app_cfg = new XmlConfig(ProdNum.baseDir +"\\app_config.xml");
            app_cfg = new SqlConfig("app");
            app_cfg.LoadConfigFromFile();

            curr_cfg = app_cfg.Current;

            agent   = new NodeAgent();
            packers = new List <UIPacker>();
            for (int i = 0; i < Int32.Parse(curr_cfg.Element("machine_number").Value); i++)
            {
                UIPacker p = new UIPacker(i, agent);
                p.agent = agent;
                p.InitConfig();
                packers.Add(p);
            }

            singlewnd = new SingleMode(Int32.Parse(curr_cfg.Element("node_number").Value));
            runwnd    = new RunMode(Int32.Parse(curr_cfg.Element("node_number").Value));


            histwnd   = new ProdHistory();
            helpwnd   = new Help();
            kbdwnd    = new kbd();
            bottomwnd = new BottomWnd();
            alertwnd  = new AlertWnd();
            alertwnd.UpdateUI(); //load alert configuration which is in app_config.xml too

            pwdwnd    = new PwdWnd();
            engwnd    = new EngConfigWnd();
            configwnd = new ConfigMenuWnd();
            prodwnd   = new ProdWnd();
            prodnum   = new ProdNum();
        }
Esempio n. 11
0
        public void RefreshVibUI()
        {
            UIPacker p = curr_packer;

            if (p.agent.vibstate == VibStatus.VIB_READY || p.agent.vibstate == VibStatus.VIB_INIDLE)
            {
                main_bucket.Template = this.FindResource("MainBucket") as ControlTemplate;
                main_bucket.ApplyTemplate();
            }
            if (p.agent.vibstate == VibStatus.VIB_WORKING)
            {
                main_bucket.Template = this.FindResource("MainBucketAct") as ControlTemplate;
                main_bucket.ApplyTemplate();

                lbl_status.Content = StringResource.str("waitpack");
            }
        }
Esempio n. 12
0
        public void RefreshNodeUI()
        {
            UIPacker p = curr_packer;

            lbl_status.Content = "";
            foreach (byte n in p.weight_nodes)
            {
                UpdateNodeUI(n);
            }
            if (lbl_status.Content.ToString() != "")
            {
                lbl_status.Foreground = Brushes.Red;
                return;
            }
            lbl_status.Foreground = Brushes.Green;
            RefreshVibUI();
            if (lbl_status.Content.ToString() == "")
            {
                lbl_status.Content = StringResource.str("normal");
            }
        }
Esempio n. 13
0
        static internal void UpdateRecord(UIPacker p)
        {
            string txtUpdate = "update mains set end_date=\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\", weight=\"" + p.total_weights.ToString("F2") + "\", pack_num=\"" + p.total_packs.ToString() + "\" where start_date=\"" + p.rStart.ToString("yyyy-MM-dd HH:mm:ss") + "\"";

            ExecuteQuery(txtUpdate);
        }
Esempio n. 14
0
        static internal void InitNewRun(UIPacker p)
        {
            string txtUpdate = "insert into mains (start_date,end_date,operator,product_no,product_desc,target,upper_var,lower_var,weight,pack_num) values ('";

            txtUpdate = txtUpdate + p.rStart.ToString("yyyy-MM-dd HH:mm:ss") + "','" + p.rStart.ToString("yyyy-MM-dd HH:mm:ss") + "','" + (System.Windows.Application.Current as App).oper + "','" + p.curr_cfg.product_no + "(" + p.curr_cfg.product_desc + ")" + "','" + p.curr_cfg.product_desc + "'," + p.curr_cfg.target.ToString() + "," + p.curr_cfg.upper_var.ToString() + "," + p.curr_cfg.lower_var.ToString() +",0,0)";
            ExecuteQuery(txtUpdate);
        }
Esempio n. 15
0
 static internal void UpdateRecord(UIPacker p)
 {
     string txtUpdate = "update mains set end_date=\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\", weight=\"" + p.total_weights.ToString("F2") + "\", pack_num=\"" + p.total_packs.ToString() + "\" where start_date=\"" + p.rStart.ToString("yyyy-MM-dd HH:mm:ss") + "\"";
     ExecuteQuery(txtUpdate);
 }
Esempio n. 16
0
        void uiTimer_Tick(object sender, EventArgs e)
        {
            lbl_datetime.Content = DateTime.Now.ToLongDateString() + "  " + DateTime.Now.ToLongTimeString();


            if (!this.IsVisible)
            {
                return;
            }
            if (tmlock)
            {
                return;
            }
            tmlock = true;

            UIPacker p = curr_packer;

            if (NodeCombination.q_hits.Count > 0)
            {
                CombineNodeUI(NodeCombination.q_hits.Dequeue());
                tmlock = false;
                return;
            }
            if (p.agent.bNeedRefresh && this.IsVisible)
            {
                p.agent.bNeedRefresh = false;
                lastcall             = "RefreshUI";
            }
            if (lastcall != "")
            {
                if (lastcall == "StartStop")
                {
                    ToggleStartStop();
                    lastcall = "";
                }

                if (lastcall == "UpdatePrdNo")
                {
                    p.LoadPackConfig(p.curr_cfg.product_no, false);
                    UpdateSysConfigUI();
                    Thread.Sleep(2000);
                    lastcall = "";
                }

                if ((lastcall == "RefreshUI"))
                {
                    if (p.status != PackerStatus.RUNNING)
                    {
                        RefreshNodeUI();
                        currentApp().agent.ClearWeights();
                        currentApp().agent.bWeightReady = false;
                    }
                    else
                    {
                        RefreshRunNodeUI();
                    }
                    lastcall = "";
                }
                txt_oper.Visibility = Visibility.Hidden;
                bg_oper.Visibility  = Visibility.Hidden;
                tmlock = false;
                return;
            }
            tmlock = false;
        }
Esempio n. 17
0
        public void KbdData(string param, string data)
        {
            //update the display based on keyboard input
            App  p = Application.Current as App;
            bool bNeedUpdateComb = false; //whether target weight of each node is required

            try
            {
                UIPacker  pack = curr_packer;
                NodeAgent n    = curr_packer.agent;
                if (param == "sub_freq_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "magnet_freq", UInt32.Parse(data));
                    apply_regs.Insert(0, "magnet_freq");
                }
                if (param == "sub_amp_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "magnet_amp", UInt32.Parse(data));
                    apply_regs.Insert(0, "magnet_amp");
                }
                if (param == "sub_time_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "magnet_time", UInt32.Parse(data));
                    apply_regs.Insert(0, "magnet_time");
                }
                if (param == "sub_filter_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "cs_gain_wordrate", UInt32.Parse(data));
                    apply_regs.Insert(0, "cs_gain_wordrate");
                }

                if (param == "wei_otime_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "open_w", UInt32.Parse(data));
                    apply_regs.Insert(0, "open_w");
                }
                if (param == "wei_dtime_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "delay_w", UInt32.Parse(data));
                    apply_regs.Insert(0, "delay_w");
                }
                if (param == "col_dtime_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "delay_s", UInt32.Parse(data));
                    apply_regs.Insert(0, "delay_s");
                }
                if (param == "col_otime_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "open_s", UInt32.Parse(data));
                    apply_regs.Insert(0, "open_s");
                }
                if (param == "openwei_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "delay_f", UInt32.Parse(data));
                    apply_regs.Insert(0, "delay_f");
                }
                if (param == "motor_speed_input")
                {
                    n.SetNodeReg((byte)curr_node_index, "motor_speed", UInt32.Parse(data));
                    apply_regs.Insert(0, "motor_speed");
                }
                if (param == "run_freq")
                {
                    n.SetNodeReg(curr_packer.vib_addr, "magnet_freq", UInt32.Parse(data));
                }
                if (param == "run_time")
                {
                    n.SetNodeReg(curr_packer.vib_addr, "magnet_time", UInt32.Parse(data));
                }

                if (param == "run_amp")
                {
                    n.SetNodeReg(curr_packer.vib_addr, "magnet_amp", UInt32.Parse(data));
                }
                if (param == "autoamp")
                {
                    curr_packer.curr_cfg.target_comb = Double.Parse(data);
                    cb_autoamp.IsChecked             = (curr_packer.curr_cfg.target_comb > 1);
                    bNeedUpdateComb = true;
                }
                if (param == "target")
                {
                    curr_packer.curr_cfg.target = Double.Parse(data);
                    bNeedUpdateComb             = true;
                }
                if (param == "uvar")
                {
                    curr_packer.curr_cfg.upper_var = Double.Parse(data);
                }
                if (param == "dvar")
                {
                    curr_packer.curr_cfg.lower_var = Double.Parse(data);
                }


                ShowStatus("modifying");
                if (bNeedUpdateComb)
                {
                    curr_packer.UpdateEachNodeTarget();
                }
                lastcall = "UpdateUI";
            }
            catch (System.Exception e)
            {
                //MessageBox.Show("Invalid Parameter");
                return;
            }
        }