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(); }
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; } }
private void btn_restore_Click(object sender, RoutedEventArgs e) { RunMode.Reset(); MessageBox.Show(StringResource.str("pwd_restore_done")); btn_return_Click(sender, e); }