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") + "','" + Program.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); }
public void UpdateSysConfigUI() { UIPacker pack = curr_packer; this.input_uvar.Text = pack.curr_cfg.upper_var.ToString() + StringResource.str("gram"); this.input_dvar.Text = pack.curr_cfg.lower_var.ToString() + StringResource.str("gram"); this.lbl_weight.Text = pack.curr_cfg.target.ToString() + StringResource.str("gram"); this.prd_no.Text = pack.curr_cfg.product_no.ToString(); this.operator_no.Text = Program.oper; this.prd_desc.Text = pack.curr_cfg.product_desc.ToString(); //load the corresponding picture. if (prdBmp != null) { prdBmp.Dispose(); } string path_to_jpg; path_to_jpg = ProdNum.baseDir + "\\prodpic\\" + StringResource.language + "\\" + pack.curr_cfg.product_desc.ToString() + ".jpg"; if (!File.Exists(path_to_jpg)) { path_to_jpg = ProdNum.baseDir + "\\prodpic\\default.jpg"; } prdBmp = new Bitmap(path_to_jpg); prd_picture.Image = (Image)prdBmp; }
static public void Initialize() { /* System.Diagnostics.Process[] pses = System.Diagnostics.Process..GetProcessesByName("TSioex"); if (pses.Length > 0) { System.Diagnostics.Process.GetCurrentProcess().Kill(); return; } */ Thread.Sleep(3000); try { StringResource.SetLanguage(); msgwnd = new MsgDlg(); app_cfg = new SqlConfig("app"); app_cfg.LoadConfigFromFile(); curr_cfg = app_cfg.Current; packers = new List<UIPacker>(); for (int i = 0; i < Int32.Parse(curr_cfg.Element("machine_number").Value); i++) { UIPacker p = new UIPacker(i); line++; p.InitConfig(); packers.Add(p); } line = 999; NodeMaster.Dummy(); line++; singlewnd = new SingleModeWnd(); line++; runwnd = new RunModeWnd(); line++; histwnd = new ProdHistory(); line++; kbdwnd = new kbdWnd(); line++; bottomwnd = new BottomWnd(); line++; alertwnd = new AlertWnd(); line++; alertwnd.UpdateUI(); //load alert configuration which is in app_config.xml too pwdwnd = new PwdWnd(); line++; engwnd = new EngWnd(); line++; configwnd = new ConfigMenuWnd(); line++; prodwnd = new ProdWnd(); line++; prodnum = new ProdNum(); line++; } catch (Exception e) { MessageBox.Show(e.Message); System.Diagnostics.Process.GetCurrentProcess().Kill(); } }
static public void Initialize() { /* * System.Diagnostics.Process[] pses = System.Diagnostics.Process..GetProcessesByName("TSioex"); * if (pses.Length > 0) * { * System.Diagnostics.Process.GetCurrentProcess().Kill(); * return; * } */ Thread.Sleep(3000); try { StringResource.SetLanguage(); msgwnd = new MsgDlg(); app_cfg = new SqlConfig("app"); app_cfg.LoadConfigFromFile(); curr_cfg = app_cfg.Current; packers = new List <UIPacker>(); for (int i = 0; i < Int32.Parse(curr_cfg.Element("machine_number").Value); i++) { UIPacker p = new UIPacker(i); line++; p.InitConfig(); packers.Add(p); } line = 999; NodeMaster.Dummy(); line++; singlewnd = new SingleModeWnd(); line++; runwnd = new RunModeWnd(); line++; histwnd = new ProdHistory(); line++; kbdwnd = new kbdWnd(); line++; bottomwnd = new BottomWnd(); line++; alertwnd = new AlertWnd(); line++; alertwnd.UpdateUI(); //load alert configuration which is in app_config.xml too pwdwnd = new PwdWnd(); line++; engwnd = new EngWnd(); line++; configwnd = new ConfigMenuWnd(); line++; prodwnd = new ProdWnd(); line++; prodnum = new ProdNum(); line++; } catch (Exception e) { MessageBox.Show(e.Message); System.Diagnostics.Process.GetCurrentProcess().Kill(); } }
//update UI when a packer is hitted public void CombineNodeUI(CombineEventArgs ce) { foreach (byte naddr in Program.packers[ce.packer_id].weight_nodes) { string param = "wei_node" + naddr.ToString(); //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) { runPan1.SetText(naddr, wt.ToString("F1"), false); } //update status display if (NodeMaster.GetStatus(naddr) == NodeStatus.ST_LOST || NodeMaster.GetStatus(naddr) == NodeStatus.ST_DISABLED) { runPan1.SetStatus("weightbar", naddr, PanStatus.DISBALED, false); } else if (naddr != curr_packer.vib_addr) { if (ce.release_addrs.Contains(naddr)) { runPan1.SetStatus("weightbar", naddr, PanStatus.RELEASE, false); } else { runPan1.SetStatus("weightbar", naddr, PanStatus.IDLE, false); } } } //Update speed information UIPacker p = Program.packers[ce.packer_id]; if (p.status == PackerStatus.RUNNING) { lbl_speed.Text = p.speed.ToString(); lbl_lastweight.Text = p.last_pack_weight.ToString("F1"); lbl_totalpack.Text = p.total_packs.ToString(); RefreshVibUI(); } }
internal NodeCombination(UIPacker p) { packer = p; bSimNodeValid = new Dictionary<byte,bool>(); foreach (byte i in packer.weight_nodes) bSimNodeValid[i] = true; bSimCombine = false; rand = new Random(); pack_cnt = 0; release_cnt = 0; release_timeout = 0; }
internal NodeCombination(UIPacker p) { packer = p; bSimNodeValid = new Dictionary <byte, bool>(); foreach (byte i in packer.weight_nodes) { bSimNodeValid[i] = true; } bSimCombine = false; rand = new Random(); pack_cnt = 0; release_cnt = 0; release_timeout = 0; }
private void sub_applyall() { UIPacker pack = curr_packer; 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 (NodeMaster.GetStatus(n) == NodeStatus.ST_LOST) { continue; } if (NodeMaster.GetStatus(n) == NodeStatus.ST_DISABLED) { continue; } if (n == cn) { continue; } UInt32 val = NodeMaster.GetNodeReg(cn, reg); NodeMaster.SetNodeReg(n, new string[] { reg }, new UInt32[] { val }); if (star) { txt_oper.Text = StringResource.str("modifying") + " " + n.ToString() + "*"; } else { txt_oper.Text = StringResource.str("modifying") + " " + n.ToString(); } star = !star; } } apply_regs.Clear(); }
private void RefreshNodeUI() { foreach (UIPacker pk in Program.packers) { foreach (byte naddr in pk.weight_nodes) { byte n = naddr; double wt = NodeMaster.GetWeight(n); if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT) { runPan1.SetText(n, wt.ToString("F1"), false); } else { if (wt > WeighNode.MAX_VALID_WEIGHT && wt < 65537) { runPan1.SetText(n, "ERR", false); runPan1.SetStatus("weightnode", n, PanStatus.ERROR, false); } } if (NodeMaster.GetStatus(n) == NodeStatus.ST_LOST || NodeMaster.GetStatus(n) == NodeStatus.ST_DISABLED) { runPan1.SetStatus("weightbar", n, PanStatus.DISBALED, false); } if (NodeMaster.GetStatus(n) == NodeStatus.ST_IDLE) { runPan1.SetStatus("weightbar", n, PanStatus.IDLE, false); } } } UIPacker p = curr_packer; if (p.status == PackerStatus.RUNNING) { lbl_speed.Text = p.speed.ToString(); lbl_lastweight.Text = p.last_pack_weight.ToString("F1"); lbl_totalpack.Text = p.total_sim_packs.ToString(); lbl_totalweights.Text = p.total_sim_weights.ToString("F1"); } }
public void RefreshNodeUI() { UIPacker p = curr_packer; lbl_status.Text = ""; foreach (byte n in p.weight_nodes) { UpdateNodeUI(n); } runPan1.ReDraw(); if (lbl_status.Text.ToString() != "") { lbl_status.ForeColor = Color.Red; return; } lbl_status.ForeColor = Color.Green; RefreshVibUI(); if (lbl_status.Text.ToString() == "") { lbl_status.Text = StringResource.str("normal"); } }
public void UpdateNodeUI(byte n) { UIPacker pack = curr_packer; //display the variable based on current setting string err = NodeMaster.GetErrors(n); double wt = -1000; string ct = ""; if (err == "") { wt = NodeMaster.GetWeight(n); ct = wt.ToString("F1"); runPan1.SetStatus("passbar", n, PanStatus.IDLE, false); } else { if (AlertWnd.b_show_alert && AlertWnd.b_turnon_alert) { runPan1.SetStatus("passbar", n, PanStatus.ERROR, false); lbl_status.Text = StringResource.str(err.Substring(0, err.IndexOf(';'))) + "\n"; runPan1.SetText(n, StringResource.str(err.Substring(0, err.IndexOf(';'))), false); } } if (NodeMaster.GetStatus(n) == NodeStatus.ST_LOST || NodeMaster.GetStatus(n) == NodeStatus.ST_DISABLED) { runPan1.SetStatus("weightbar", n, PanStatus.DISBALED, false); } if (NodeMaster.GetStatus(n) == NodeStatus.ST_IDLE) { runPan1.SetStatus("weightbar", n, PanStatus.IDLE, false); } if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT) { runPan1.SetText(n, ct, false); } }
public void KbdData(string param, string data) { //update the display based on keyboard input bool bNeedUpdateComb = false; //whether target weight of each node is required try { UIPacker pack = curr_packer; if (param == "sub_freq_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "magnet_freq" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "magnet_freq"); } if (param == "sub_amp_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "magnet_amp" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "magnet_amp"); } if (param == "sub_time_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "magnet_time" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "magnet_time"); } if (param == "sub_filter_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "cs_gain_wordrate" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "cs_gain_wordrate"); } if (param == "wei_otime_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "open_w" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "open_w"); } if (param == "wei_dtime_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "delay_w" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "delay_w"); } if (param == "col_dtime_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "delay_s" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "delay_s"); } if (param == "col_otime_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "open_s" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "open_s"); } if (param == "openwei_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "delay_f" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "delay_f"); } if (param == "motor_speed_input") { NodeMaster.SetNodeReg((byte)curr_node_index, new string[] { "motor_speed" }, new UInt32[] { UInt32.Parse(data) }); apply_regs.Insert(0, "motor_speed"); } if (param == "run_freq") { NodeMaster.SetNodeReg(curr_packer.vib_addr, new string[] { "magnet_freq" }, new UInt32[] { UInt32.Parse(data) }); } if (param == "run_time") { NodeMaster.SetNodeReg(curr_packer.vib_addr, new string[] { "magnet_time" }, new UInt32[] { UInt32.Parse(data) }); } if (param == "run_amp") { NodeMaster.SetNodeReg(curr_packer.vib_addr, new string[] { "magnet_amp" }, new UInt32[] { UInt32.Parse(data) }); } if (param == "autoamp") { curr_packer.curr_cfg.target_comb = Double.Parse(data); cb_autoamp.Checked = (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) { //Program.MsgShow("Invalid Parameter"); return; } }
private void HitCombineNodeUI(CombineEventArgs ce) { foreach (byte naddr in Program.packers[ce.packer_id].weight_nodes) { byte n = naddr; double wt = NodeMaster.GetWeight(n); if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT) { runPan1.SetText(n, NodeMaster.GetWeight(n).ToString("F1"), false); } else { if (wt > WeighNode.MAX_VALID_WEIGHT && wt < 65537) { runPan1.SetText(n, "ERR", false); runPan1.SetStatus("weightnode", n, PanStatus.ERROR, false); } } if (!ce.release_addrs.Contains(n)) { if (NodeMaster.GetStatus(n) == NodeStatus.ST_LOST || NodeMaster.GetStatus(n) == NodeStatus.ST_DISABLED) { runPan1.SetStatus("weightbar", n, PanStatus.DISBALED, false); } else { if (n != curr_packer.vib_addr) { runPan1.SetStatus("weightbar", n, PanStatus.IDLE, false); } } continue; } if (NodeMaster.GetStatus(n) == NodeStatus.ST_LOST || NodeMaster.GetStatus(n) == NodeStatus.ST_DISABLED) { runPan1.SetStatus("weightbar", n, PanStatus.DISBALED, false); } else { if (n != curr_packer.vib_addr) { if (ce.release_addrs.Contains(n)) { runPan1.SetStatus("weightbar", n, PanStatus.RELEASE, false); } else { runPan1.SetStatus("weightbar", n, PanStatus.IDLE, false); } } } } UIPacker p = curr_packer; if (p.status == PackerStatus.RUNNING) { lbl_speed.Text = p.speed.ToString(); lbl_lastweight.Text = p.last_pack_weight.ToString("F1"); lbl_totalpack.Text = p.total_sim_packs.ToString(); lbl_totalweights.Text = p.total_sim_weights.ToString("F1"); } }
public void KbdData(string param, string data) { try { UIPacker pack = curr_packer; if (param == "newtime") { if (!Regex.IsMatch(newdate, "^\\d\\d\\d\\d\\d\\d\\d\\d$")) { return; } if (!Regex.IsMatch(data, "^\\d\\d\\d\\d\\d\\d$")) { return; } SystemTime time = new SystemTime(); time.wYear = Convert.ToUInt16(newdate.Substring(0, 4)); time.wMonth = Convert.ToUInt16(newdate.Substring(4, 2)); time.wDay = Convert.ToUInt16(newdate.Substring(6, 2)); time.wHour = Convert.ToUInt16(data.Substring(0, 2)); time.wMinute = Convert.ToUInt16(data.Substring(2, 2)); time.wSecond = Convert.ToUInt16(data.Substring(4, 2)); time.wMiliseconds = 0; SetLocalTime(ref time); } if (param == "newdate") { newdate = data; lastcall = "newtime"; return; } 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") { Program.oper = data; pack.SaveCurrentConfig(4); } if (param == "singlemode") { if (Password.compare_pwd("user", data)) { while (lastcall != "") { this.uiTimer_Tick(null, null); } Program.SwitchTo("configmenu"); return; } else { Program.MsgShow(StringResource.str("invalid_pwd")); } } UpdateSysConfigUI(); } catch (System.Exception e) { Program.MsgShow("Invalid Parameter"); return; } }
private static bool tmlock = false; //lock for timer handler void uiTimer_Tick(object sender, EventArgs e) { if (Program.topwnd != "runmode") { return; } lbl_datetime.Text = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); if (tmlock) { return; } tmlock = true; UIPacker p = curr_packer; if (lastcall != "") { if (lastcall == "newtime") { lastcall = ""; Program.kbdwnd.Init(StringResource.str("enter_newtime"), "newtime", false, KbdData); } if (lastcall == "StartStop") { ToggleStartStop(); lbl_status.Text = StringResource.str("normal"); lastcall = ""; } if (lastcall == "UpdatePrdNo") { p.LoadPackConfig(p.curr_cfg.product_no, false); UpdateSysConfigUI(); Thread.Sleep(2000); lastcall = ""; } txt_oper.Visible = false; tmlock = false; return; } else { curr_packer.nc.Step(); if ((NodeCombination.phase == 40) || (NodeCombination.phase == 30)) { idlehit++; } else { idlehit = 0; } } if (NodeCombination.q_hits.Count > 0) { while ((NodeCombination.q_hits.Count > 0)) { CombineNodeUI(NodeCombination.q_hits.Dequeue()); } tmlock = false; return; } if (p.status != PackerStatus.RUNNING) { RefreshNodeUI(); } else { if ((NodeCombination.phase == 50) || (idlehit > 10)) { idlehit = 0; RefreshRunNodeUI(); } } tmlock = false; }
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); }
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") + "','" + Program.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); }