示例#1
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");
            }
        }
示例#2
0
        private void title_speed_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (ts_pwd == null)
            {
                return;
            }
            title_cnt++;
            if (title_cnt < 5)
            {
                return;
            }

            TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);
            TimeSpan ts  = ts2.Subtract((TimeSpan)ts_pwd).Duration();

            if (ts.Seconds < 6)
            {
                Reset();
                MessageBox.Show(StringResource.str("pwd_restore_done"));
            }
            title_cnt = 0;
            ts_pwd    = null;
        }
示例#3
0
 private void btn_changeaddr_Click(object sender, RoutedEventArgs e)
 {
     (Application.Current as App).kbdwnd.Init(StringResource.str("enter_newaddr"), "chgnd_" + curr_sel.ToString(), false, KbdData);
 }
示例#4
0
 private void btn_entersys_Click(object sender, RoutedEventArgs e)
 {
     (Application.Current as App).kbdwnd.Init(StringResource.str("enter_system"), "entersys", true, KbdData);
 }
示例#5
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
        }
示例#6
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;
            }
        }
示例#7
0
 private void btnClr_Click(object sender, EventArgs e)
 {
     curr_packer.total_packs = 0;
     MessageBox.Show(StringResource.str("done"));
 }
示例#8
0
        public void UpdateDataGrid(object sender, EventArgs e)
        {
            SetConnection();
            sql_con.Open();

            sql_cmd = sql_con.CreateCommand();
            string   cols        = "select start_date, end_date, operator, product_no, product_desc, target, upper_var, lower_var, weight, pack_num from  mains ";
            DateTime s_dt        = mc_starttime.SelectionStart;
            DateTime e_dt        = mc_endtime.SelectionEnd;
            string   CommandText = cols + String.Format("where start_date>='{0}-{1}-{2} 00:00:00' and end_date<='{3}-{4}-{5} 23:59:59'",
                                                        s_dt.Year, s_dt.Month.ToString("D2"), s_dt.Day.ToString("D2"), e_dt.Year, e_dt.Month.ToString("D2"), e_dt.Day.ToString("D2"));

            if (lb_oper.SelectedIndex >= 0 && lb_oper.SelectedItem.ToString() != "*")
            {
                CommandText += String.Format(" and operator='{0}'", lb_oper.SelectedItem.ToString());
            }
            if (lb_prod.SelectedIndex >= 0 && lb_prod.SelectedItem.ToString() != "*")
            {
                CommandText += String.Format(" and product_desc='{0}'", lb_prod.SelectedItem.ToString());
            }
            if (lb_prodno.SelectedIndex >= 0 && lb_prodno.SelectedItem.ToString() != "*")
            {
                CommandText += String.Format(" and product_no='{0}'", lb_prodno.SelectedItem.ToString());
            }

            DB = new SQLiteDataAdapter(CommandText, sql_con);
            DS.Reset();
            DB.Fill(DS);
            DT = DS.Tables[0];
            double total_sum  = 0;
            UInt32 total_pack = 0;

            foreach (DataRow dr in DT.Rows)
            {
                total_pack += UInt32.Parse(dr["pack_num"].ToString());
                total_sum  += Double.Parse(dr["weight"].ToString());
            }
            this.dataGridView1.DataSource = DT;
            foreach (DataGridViewColumn dcol in dataGridView1.Columns)
            {
                dcol.HeaderText   = StringResource.str(dcol.Name);
                dcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            }
            this.lbl_summary.Text = String.Format("{0}:{1}{6} , {2}:{3} , {4}:{5}{6}", StringResource.str("totalweight"), total_sum.ToString("F1"),
                                                  StringResource.str("totalpacknum"), total_pack.ToString(), StringResource.str("avgweight"), (total_pack == 0 ? "0" :(total_sum / total_pack).ToString("F1")), StringResource.str("gram"));
            sql_con.Close();
        }
示例#9
0
 private void ShowStatus(string msg)
 {
     txt_oper.Content    = StringResource.str(msg);
     txt_oper.Visibility = Visibility.Visible;
     bg_oper.Visibility  = Visibility.Visible;
 }
示例#10
0
        public void SwitchTo(string mode)
        {
            if (mode == "history")
            {
                histwnd.UpdateDisplay();
                histwnd.UpdateList();
                histwnd.Show();
                histwnd.BringToFront();
                return;
            }
            if (mode == "alert")
            {
                alertwnd.UpdateUI();
                alertwnd.Show();
                alertwnd.BringIntoView();
                return;
            }
            if (mode == "bottom")
            {
                bottomwnd.Show();
                bottomwnd.UpdateDisplay();
                bottomwnd.BringIntoView();
                return;
            }
            if (mode == "password")
            {
                pwdwnd.Show();
                pwdwnd.BringIntoView();
                return;
            }
            if (mode == "engineer")
            {
                engwnd.InitDisplay();
                engwnd.Show();
                engwnd.BringIntoView();
                return;
            }

            singlewnd.Hide();
            histwnd.Hide();
            helpwnd.Hide();
            runwnd.Hide();
            alertwnd.Hide();
            bottomwnd.Hide();
            pwdwnd.Hide();
            engwnd.Hide();
            kbdwnd.Hide();
            configwnd.Hide();

            if (mode == "configmenu")
            {
                configwnd.Show();
                configwnd.BringIntoView();
                return;
            }
            if (mode == "product")
            {
                mode = "singlemode";
            }
            if (mode == "runmode")
            {
                runwnd.Show();
                if (runwnd.btn_allstart.Visibility == Visibility.Hidden)
                {
                    MessageBox.Show(StringResource.str("license"));
                }
                runwnd.UpdateSysConfigUI();
                runwnd.BringIntoView();
                return;
            }
            if (mode == "singlemode")
            {
                singlewnd.Show();
                singlewnd.UpdateUI();
                singlewnd.BringIntoView();
                return;
            }
            if (mode == "helpmode")
            {
                helpwnd.Show();
                helpwnd.BringIntoView();
                return;
            }
        }
示例#11
0
 private void node_reg(string regname)
 {
     (Application.Current as App).kbdwnd.Init(StringResource.str("enter_" + regname), regname, false, KbdData);
 }
示例#12
0
 private void pwd_GotFocus(object sender, MouseButtonEventArgs e)
 {
     (Application.Current as App).kbdwnd.Init(StringResource.str("enter_singlemode_pwd"), (sender as PasswordBox).Name, true, KbdData);
 }
示例#13
0
 private void btn_restore_Click(object sender, RoutedEventArgs e)
 {
     RunMode.Reset();
     MessageBox.Show(StringResource.str("pwd_restore_done"));
     btn_return_Click(sender, e);
 }
示例#14
0
 private void new_prd_Click(object sender, RoutedEventArgs e)
 {
     (Application.Current as App).kbdwnd.Init(StringResource.str("input_newprdno"), "", false, new_prd_no_input);
 }
示例#15
0
        private void btn_updatefw_Click(object sender, RoutedEventArgs e)
        {
            SubNode n;

            if (curr_sel == -1)
            {
                return;
            }
            int    lastcurr = curr_sel;
            App    p        = Application.Current as App;
            Button btn;

            for (Byte i = 1; i < 18; i++)
            {
                n = null;
                if (i < 17)
                {
                    btn = IdToButton(i.ToString());
                    n   = p.agent[i];
                }
                else
                {
                    btn = IdToButton("36");
                    n   = p.agent.missingnode;
                }

                if (n is SubNode)
                {
                    n.status      = NodeStatus.ST_IDLE;
                    n["board_id"] = null;
                    Thread.Sleep(100);

                    if (n["board_id"] != null)
                    {
                        if ((curr_sel == n.node_id) || (all_sel == true))
                        {
                            curr_sel     = n.node_id;
                            btn.Template = this.FindResource("roundButtonsel2") as ControlTemplate;
                            btn.ApplyTemplate();
                            btn.Visibility = Visibility.Visible;

                            fwprgs_bar.Visibility = Visibility.Visible;
                            fwprgs_bar.Minimum    = 0;

                            fwprgs_bar.Maximum = (int)(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ioex_cs.Resources.MAIN.BIN").Length / 128);

                            bootloader bl  = new bootloader(n);
                            string     ret = bl.download(fwprogress);
                            btn_updatefw.Content  = StringResource.str("updatefw");
                            fwprgs_bar.Visibility = Visibility.Hidden;
                            if (ret != "")
                            {
                                MessageBox.Show(StringResource.str("updatefwfail") + n.node_id.ToString() + "\r\n" + ret);
                            }
                            curr_sel = lastcurr;
                            continue;
                        }
                    }
                }
            }
            btn_refreshreg_Click(null, null);
            UpdateDisplay(true);
        }
示例#16
0
        public void PackerBoot()
        {
            App p = (Application.Current as App);

            try
            {
                UpdateMessage("App Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\r\n");
                //search for nodes
                //UpdateMessage(StringResource.str("search_newnode"));

                p.agent.missingnode.status  = NodeStatus.ST_IDLE;
                p.agent.missingnode["addr"] = null;

                boot_ok = 0;
                int tryfound;
                //check the availability of each board
                foreach (UIPacker pk in p.packers)
                {
                    foreach (byte n in pk.weight_nodes)
                    {
                        if ((n % 4) == 3)
                        {
                            UpdateMessage("\r\n");
                        }
                        pk.agent.SetStatus(n, NodeStatus.ST_IDLE);
                        tryfound = 3;
                        while ((!pk.agent.search(n)) && (tryfound > 0))
                        {
                            Thread.Sleep(500);
                            tryfound--;
                        }

                        if (tryfound <= 0)
                        {
                            UpdateMessage(StringResource.str("search_node") + n + StringResource.str("fail") + "\t\t");
                        }
                        else
                        {
                            boot_ok++;
                            UpdateMessage(n + ": ver " + pk.agent[n]["fw_rev_uw"].Value.ToString() + "\t\t");
                        }
                    }
                    byte nvib = pk.vib_addr;
                    pk.agent.SetStatus(nvib, NodeStatus.ST_IDLE);
                    tryfound = 3;
                    while ((!pk.agent.search(nvib)) && (tryfound > 0))
                    {
                        Thread.Sleep(500);
                        tryfound--;
                    }
                    if (tryfound <= 0)
                    {
                        UpdateMessage(StringResource.str("search_node") + nvib + StringResource.str("fail") + "\t\t");
                    }
                    else
                    {
                        boot_ok++;
                        UpdateMessage(nvib + ": ver " + pk.agent[nvib]["fw_rev_uw"].Value.ToString() + "\t\t");
                    }
                    Thread.Sleep(2000);
                    if (boot_ok > 0)
                    {
                        //start engine
                        pk.agent.Start();
                        pk.nc.Start();
                        //load config for node
                        UpdateMessage("\r\n" + StringResource.str("init_nodereg"));
                        pk.LoadPackConfig(pk.pkg_confs.cfg_name, true);
                        pk.agent.SetVibIntf(pk.vib_addr, pk.getInterface());

                        NodeAgent.bBootDone = true;
                    }
                }
            }
            catch (Exception ex)
            {
                UpdateMessage(ex.Message);
                boot_ok = 0;
                Thread.Sleep(3000);
            }
        }
示例#17
0
        public void UpdateDisplay(bool refresh)
        {
            SubNode n;
            App     p = Application.Current as App;
            Button  btn;

            if (b_lockon)
            {
                btn_locksys.Style   = this.FindResource("ButtonStyleOff") as Style;
                btn_locksys.Content = StringResource.str("lockon");
            }
            else
            {
                btn_locksys.Style   = this.FindResource("ButtonStyleOn") as Style;
                btn_locksys.Content = StringResource.str("locksystem");
            }
            for (Byte i = 1; i < 18; i++)
            {
                n = null;
                if (i < 17)
                {
                    btn = IdToButton(i.ToString());
                    n   = p.agent[i];
                }
                else
                {
                    btn = IdToButton("36");
                    n   = p.agent.missingnode;
                }

                if (n is SubNode)
                {
                    if (refresh) //refresh all the node status
                    {
                        n.status      = NodeStatus.ST_IDLE;
                        n["board_id"] = null;
                        Thread.Sleep(100);
                    }

                    if (n["board_id"] != null)
                    {
                        if (curr_sel == -1)
                        {
                            curr_sel = n.node_id;
                        }

                        if (curr_sel == n.node_id || all_sel)
                        {
                            if ((n.errlist != "") || (n.status == NodeStatus.ST_LOST))
                            {
                                btn.Template = this.FindResource("roundButtonselerr2") as ControlTemplate;
                            }
                            else
                            {
                                btn.Template = this.FindResource("roundButtonsel2") as ControlTemplate;
                            }
                        }
                        else
                        {
                            if ((n.errlist != "") || (n.status == NodeStatus.ST_LOST))
                            {
                                btn.Template = this.FindResource("roundButtonerr2") as ControlTemplate;
                            }
                            else
                            {
                                btn.Template = this.FindResource("roundButton2") as ControlTemplate;
                            }
                        }
                        btn.ApplyTemplate();
                        btn.Visibility = Visibility.Visible;
                        continue;
                    }
                }
                btn.Visibility = Visibility.Hidden;
            }
        }
示例#18
0
 private void btn_pack_uvar_Click(object sender, RoutedEventArgs e)
 {
     (Application.Current as App).kbdwnd.Init(StringResource.str("enter_uvar"), "uvar", false, KbdData);
 }