Ejemplo n.º 1
0
        private void LoadProcessorsAndConfigurations()
        {
            XmlDocument cfg = new XmlDocument();

            cfg.Load(Loader.apppath + @"\config.xml");

            matrixmemsize   = int.Parse(cfg.SelectSingleNode("Configurations/MatrixMemorySize").InnerText);
            threadstacksize = int.Parse(cfg.SelectSingleNode("Configurations/ThreadStackSize").InnerText);

            //*********************Loading Processors************
            XmlNodeList nlist = cfg.SelectNodes("Configurations/RemoteProcessor");

            Console.WriteLine("Loading RemoteProcessors");
            foreach (XmlNode tmp in nlist)
            {
                try
                {
                    RemoteProcessor tmpprocessor = new  RemoteProcessor();
                    string          ipaddr       = tmp.SelectSingleNode("IPAddress").InnerText;
                    int             prt          = int.Parse(tmp.SelectSingleNode("Port").InnerText);
                    Console.WriteLine("Connecting to {0}:{1}....", ipaddr, prt);
                    tmpprocessor.Connect(ipaddr, prt);
                    tmpprocessor.StartProcessor();
                    tmpprocessor.localprocessor = localprocessor;
                    RemoteProcessorsManager.AddProcessor(tmpprocessor);
                }
                catch (Exception exc) {
                    Console.WriteLine(exc.Message);
                }
            }

            //*********************Loading External Devices************
            nlist = cfg.SelectNodes("Configurations/ExternalDevice");

            if (nlist.Count > 0)
            {
                Console.WriteLine("Loading External Devices");
                externaldevices = new ExternalDevicePort[nlist.Count];
                int tmp2 = 0;
                foreach (XmlNode tmp in nlist)
                {
                    externaldevices[tmp2] = new ExternalDevicePort(
                        tmp.SelectSingleNode("Name").InnerText
                        , new ExternalDevicePort.Echo(this.EchoMessage));
                    externaldevices[tmp2].Initialize(int.Parse(
                                                         tmp.SelectSingleNode("Port").InnerText));
                    tmp2++;
                }
            }
        }
Ejemplo n.º 2
0
        private void LoadProcessorsAndConfigurations()
        {
            XmlDocument cfg = new XmlDocument();
            cfg.Load(Loader.apppath +  @"\config.xml");

            matrixmemsize = int.Parse(cfg.SelectSingleNode("Configurations/MatrixMemorySize").InnerText);
            threadstacksize = int.Parse(cfg.SelectSingleNode("Configurations/ThreadStackSize").InnerText);

            //*********************Loading Processors************
            XmlNodeList nlist = cfg.SelectNodes("Configurations/RemoteProcessor");

            Console.WriteLine("Loading RemoteProcessors");
            foreach(XmlNode tmp in nlist){
                try
                {
                    RemoteProcessor tmpprocessor = new  RemoteProcessor();
                    string ipaddr = tmp.SelectSingleNode("IPAddress").InnerText;
                    int prt = int.Parse(tmp.SelectSingleNode("Port").InnerText);
                    Console.WriteLine("Connecting to {0}:{1}....",ipaddr,prt);
                    tmpprocessor.Connect(ipaddr,prt);
                    tmpprocessor.StartProcessor();
                    tmpprocessor.localprocessor = localprocessor;
                    RemoteProcessorsManager.AddProcessor(tmpprocessor);
                }
                catch(Exception exc){
                    Console.WriteLine(exc.Message);
                }
            }

            //*********************Loading External Devices************
            nlist = cfg.SelectNodes("Configurations/ExternalDevice");

            if(nlist.Count>0)
            {
                Console.WriteLine("Loading External Devices");
                externaldevices = new ExternalDevicePort[nlist.Count];
                int tmp2=0;
                foreach(XmlNode tmp in nlist)
                {
                    externaldevices[tmp2] = new ExternalDevicePort(
                        tmp.SelectSingleNode("Name").InnerText
                        ,new ExternalDevicePort.Echo(this.EchoMessage));
                    externaldevices[tmp2].Initialize(int.Parse(
                        tmp.SelectSingleNode("Port").InnerText));
                    tmp2++;
                }
            }
        }