public static void InitializeProcessor() { XmlDocument cfg = new XmlDocument(); cfg.Load("remoteconfig.xml"); //*********************Loading External Devices************ XmlNodeList nlist = cfg.SelectNodes("ProcessorConfiguration/ExternalDevice"); IExternalDevicePort[] externaldevices = null; 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(EchoMessage)); externaldevices[tmp2].Initialize(int.Parse( tmp.SelectSingleNode("Port").InnerText)); tmp2++; } } server = new RemoteRequestServer(int.Parse(cfg.SelectSingleNode( "ProcessorConfiguration/Port").InnerText), cfg.SelectSingleNode("ProcessorConfiguration/Name").InnerText,externaldevices); threadstacksize =int.Parse(cfg.SelectSingleNode( "ProcessorConfiguration/ThreadStackSize").InnerText); }
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++; } } }