コード例 #1
0
 static Password()
 {
     //load password.xml and fill in the username list
     //pwds = new XmlConfig("password.xml");
     pwds = new SqlConfig("password");
     pwds.LoadConfigFromFile();
     //string a = MD5Value("0106C2255SJ 8GB", true);
     //"0106C2255SJ 8GB"
     //""
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: imdmmp/kpgweigher
        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();
            }
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
ファイル: UIPacker.cs プロジェクト: ymz000/kpgweigher
        public UIPacker(int pack_id)
        {
            vib_addr = 0xff;
            bot_addr = 0xff;

            _pack_id = pack_id;
            status   = PackerStatus.IDLE;


            weight_nodes = new List <byte>();
            nodes_config = new Dictionary <byte, SqlConfig>();


            pkg_confs = new SqlConfig("pack" + pack_id.ToString());

            pkg_confs.LoadConfigFromFile();

            _curr_cfg = new PackerConfig();
            packhist  = new List <onepack>();
        }
コード例 #5
0
ファイル: LogonWindow.cs プロジェクト: imdmmp/kpgweigher
 static Password()
 {
     //load password.xml and fill in the username list
     //pwds = new XmlConfig("password.xml");
     pwds = new SqlConfig("password");
     pwds.LoadConfigFromFile();
     //string a = MD5Value("0106C2255SJ 8GB", true);
     //"0106C2255SJ 8GB"
     //""
 }
コード例 #6
0
ファイル: NodeMaster.cs プロジェクト: ymz000/kpgweigher
        public static uint MSDELAY      = 500; //silent time delay

        #region initialize
        //load current configuration
        //create all the subnodes based on ports, type and address
        private void LoadConfiguration()
        {
            SqlConfig app_cfg;
            XElement  def_cfg;

            Program.line = 3000;
            Int32  baudrate;
            string parity;

            string[] ser_ports;
            string[] node_addrs;
            try
            {
                app_cfg = new SqlConfig("app"); Program.line++;
                app_cfg.LoadConfigFromFile(); Program.line++;
                def_cfg = app_cfg.Current; Program.line++;

                baudrate   = Int32.Parse(def_cfg.Element("baudrate").Value); Program.line++;
                parity     = def_cfg.Element("parity").Value.ToLower(); Program.line++;
                ser_ports  = def_cfg.Element("totalports").Value.ToString().Split(new char[] { ',' }); Program.line++;
                node_addrs = def_cfg.Element("totalnodes").Value.ToString().Split(new char[] { ',' }); Program.line++;

                VAR_RANGE    = Double.Parse(def_cfg.Element("var_range").Value); Program.line++;
                LASTCOMB_NUM = UInt32.Parse(def_cfg.Element("lastcomb_num").Value); Program.line++;
                MSDELAY      = UInt32.Parse(def_cfg.Element("msdelay").Value); Program.line++;
            }
            catch
            {
                throw new Exception("Invalid parameter in database");
            }

            //create all serial ports
            try
            {
                foreach (string port in ser_ports)
                {
                    if (parity == "even")
                    {
                        allports.Add(new SPort(port, baudrate, Parity.Even, 8, StopBits.One));
                    }
                    else if (parity == "odd")
                    {
                        allports.Add(new SPort(port, baudrate, Parity.Odd, 8, StopBits.One));
                    }
                    else
                    {
                        allports.Add(new SPort(port, baudrate, Parity.None, 8, StopBits.One));
                    }
                    Program.line++;
                }
            }
            catch
            {
                throw new Exception("Failed to open the COM port");
            }

            foreach (SPort sp in allports)
            {
                try
                {
                    if (!sp.Open())
                    {
                        throw new Exception("Failed to open the port");
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            Program.line = 5000;
            //create all nodes
            foreach (string node in node_addrs)
            {
                string type = def_cfg.Element("node_type" + node).Value;
                string com  = def_cfg.Element("node_com" + node).Value;

                if (type == "weight")
                {
                    nodemap[byte.Parse(node)] = new WeighNode(allports[byte.Parse(com)], byte.Parse(node));
                    weight_nodes.Add(nodemap[byte.Parse(node)] as WeighNode);
                }
                if (type == "vibrate")
                {
                    nodemap[byte.Parse(node)] = new VibrateNode(allports[byte.Parse(com)], byte.Parse(node));
                }
            }
            Program.line = 33333;
            //missingnode = new SubNode(allports[0], byte.Parse(def_cfg.Element("def_addr").Value)); //36 is the default address of unassigned address board
        }
コード例 #7
0
ファイル: UIPacker.cs プロジェクト: imdmmp/kpgweigher
        public UIPacker(int pack_id)
        {
            vib_addr = 0xff;
            bot_addr = 0xff;

            _pack_id = pack_id;
            status = PackerStatus.IDLE;
            
            
            weight_nodes = new List<byte>();
            nodes_config = new Dictionary<byte, SqlConfig>();

            
            pkg_confs = new SqlConfig("pack" + pack_id.ToString());
            
            pkg_confs.LoadConfigFromFile();

            _curr_cfg = new PackerConfig();
            packhist = new List<onepack>();
            
        }
コード例 #8
0
ファイル: NodeMaster.cs プロジェクト: imdmmp/kpgweigher
        public static uint MSDELAY = 500; //silent time delay

        #region initialize
        //load current configuration
        //create all the subnodes based on ports, type and address
        private void LoadConfiguration()
        {
            SqlConfig app_cfg;
            XElement def_cfg;
            Program.line = 3000;
            Int32 baudrate;
            string parity;
            string[] ser_ports;
            string[] node_addrs;
            try
            {
                app_cfg = new SqlConfig("app"); Program.line++;
                app_cfg.LoadConfigFromFile(); Program.line++;
                def_cfg = app_cfg.Current; Program.line++;

                baudrate = Int32.Parse(def_cfg.Element("baudrate").Value); Program.line++;
                parity = def_cfg.Element("parity").Value.ToLower(); Program.line++;
                ser_ports = def_cfg.Element("totalports").Value.ToString().Split(new char[] { ',' }); Program.line++;
                node_addrs = def_cfg.Element("totalnodes").Value.ToString().Split(new char[] { ',' }); Program.line++;

                VAR_RANGE = Double.Parse(def_cfg.Element("var_range").Value); Program.line++;
                LASTCOMB_NUM = UInt32.Parse(def_cfg.Element("lastcomb_num").Value); Program.line++;
                MSDELAY = UInt32.Parse(def_cfg.Element("msdelay").Value); Program.line++;
            }
            catch
            {
                throw new Exception("Invalid parameter in database");
            }

            //create all serial ports
            try
            {
                foreach (string port in ser_ports)
                {
                    if (parity == "even")
                        allports.Add(new SPort(port, baudrate, Parity.Even, 8, StopBits.One));
                    else if (parity == "odd")
                        allports.Add(new SPort(port, baudrate, Parity.Odd, 8, StopBits.One));
                    else
                        allports.Add(new SPort(port, baudrate, Parity.None, 8, StopBits.One));
                    Program.line++;
                }
            }
            catch
            {
                throw new Exception("Failed to open the COM port");
            }
            
            foreach (SPort sp in allports)
            {
                try
                {
                    if (!sp.Open())
                    {
                        throw new Exception("Failed to open the port");
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            Program.line = 5000;
            //create all nodes
            foreach (string node in node_addrs)
            {
                string type = def_cfg.Element("node_type" + node).Value;
                string com = def_cfg.Element("node_com" + node).Value;

                if (type == "weight")
                {
                    nodemap[byte.Parse(node)] = new WeighNode(allports[byte.Parse(com)], byte.Parse(node));
                    weight_nodes.Add(nodemap[byte.Parse(node)] as WeighNode);
                }
                if (type == "vibrate")
                {
                    nodemap[byte.Parse(node)] = new VibrateNode(allports[byte.Parse(com)], byte.Parse(node));
                }
            }
            Program.line = 33333;
            //missingnode = new SubNode(allports[0], byte.Parse(def_cfg.Element("def_addr").Value)); //36 is the default address of unassigned address board
        }