// read deisred modules from config file public Magellan(int verbosity) { var d = new Discover.Discover(); var modules = d.GetSubClasses("SPH.SerialPortHandler"); List<MagellanConfigPair> conf = ReadConfig(); sph = new List<SerialPortHandler>(); foreach (var pair in conf) { try { if (modules.Any(m => m.Name == pair.module)) { var type = d.GetType("SPH." + pair.module); Console.WriteLine(pair.module + ":" + pair.port); SerialPortHandler s = (SerialPortHandler)Activator.CreateInstance(type, new Object[]{ pair.port }); s.SetParent(this); s.SetVerbose(verbosity); sph.Add(s); } else { throw new Exception("unknown module: " + pair.module); } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine("Warning: could not initialize "+pair.port); Console.WriteLine("Ensure the device is connected and you have permission to access it."); } } MonitorSerialPorts(); UdpListen(); factorRabbits(); }
// read deisred modules from config file public Magellan(int verbosity) { var d = new Discover.Discover(); var modules = d.GetSubClasses("SPH.SerialPortHandler"); List <MagellanConfigPair> conf = ReadConfig(); sph = new List <SerialPortHandler>(); foreach (var pair in conf) { try { if (modules.Any(m => m.Name == pair.module)) { var type = d.GetType("SPH." + pair.module); Console.WriteLine(pair.module + ":" + pair.port); SerialPortHandler s = (SerialPortHandler)Activator.CreateInstance(type, new Object[] { pair.port }); s.SetParent(this); s.SetVerbose(verbosity); sph.Add(s); } else { throw new Exception("unknown module: " + pair.module); } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine("Warning: could not initialize " + pair.port); Console.WriteLine("Ensure the device is connected and you have permission to access it."); } } MonitorSerialPorts(); UdpListen(); factorRabbits(); }
// read deisred modules from config file public Magellan(int verbosity) { var d = new Discover.Discover(); var modules = d.GetSubClasses("SPH.SerialPortHandler"); List<MagellanConfigPair> conf = ReadConfig(); sph = new List<SerialPortHandler>(); foreach (var pair in conf) { try { if (modules.Any(m => m.Name == pair.module)) { var type = d.GetType("SPH." + pair.module); Console.WriteLine(pair.module + ":" + pair.port); SerialPortHandler s = (SerialPortHandler)Activator.CreateInstance(type, new Object[]{ pair.port }); s.SetParent(this); s.SetVerbose(verbosity); sph.Add(s); } else { throw new Exception("unknown module: " + pair.module); } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine("Warning: could not initialize "+pair.port); Console.WriteLine("Ensure the device is connected and you have permission to access it."); } } FinishInit(); #if CORE_RABBIT rabbit_factory = new ConnectionFactory(); rabbit_factory.HostName = "localhost"; rabbit_con = rabbit_factory.CreateConnection(); rabbit_channel = rabbit_con.CreateModel(); rabbit_channel.QueueDeclare("core-pos", false, false, false, null); #endif }
// read deisred modules from config file public Magellan(int verbosity) { var d = new Discover.Discover(); var modules = d.GetSubClasses("SPH.SerialPortHandler"); var my_location = this.GetMyPath(); var sep = Path.DirectorySeparatorChar; Magellan.log_path = my_location + sep + ".." + sep + ".." + sep + ".." + sep + "log" + sep + "debug_lane.log"; List <MagellanConfigPair> conf = ReadConfig(); sph = new List <SerialPortHandler>(); foreach (var pair in conf) { try { if (modules.Any(m => m.Name == pair.module)) { var type = d.GetType("SPH." + pair.module); Console.WriteLine(pair.module + ":" + pair.port); SerialPortHandler s = (SerialPortHandler)Activator.CreateInstance(type, new Object[] { pair.port }); s.SetParent(this); s.SetVerbose(verbosity); s.SetConfig("disableRBA", this.disableRBA ? "true" : "false"); s.SetConfig("disableButtons", this.disableButtons ? "true" : "false"); s.SetConfig("logXML", this.logXML ? "true" : "false"); if (pair.settings != null) { s.SetConfig(pair.settings); } sph.Add(s); } else { throw new Exception("unknown module: " + pair.module); } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine("Warning: could not initialize " + pair.port); Console.WriteLine("Ensure the device is connected and you have permission to access it."); } } MonitorSerialPorts(); UdpListen(); //factorRabbits(); }
static public int Main(string[] args) { int verbosity = 0; for (int i = 0; i < args.Length; i++) { if (args[i] == "-v") { verbosity = 1; if (i + 1 < args.Length) { try { verbosity = Int32.Parse(args[i + 1]); } catch {} } } else if (args[i] == "-m") { // Reference a class in SPH to force SPH.dll to load var load = new List <SerialPortHandler>(); var d = new Discover.Discover(); var modules = d.GetSubClasses("SPH.SerialPortHandler").Where(t => !t.IsAbstract).ToList(); modules.Sort((a, b) => a.ToString().CompareTo(b.ToString())); Console.WriteLine("Available modules:"); foreach (var m in modules) { Console.WriteLine(" " + m); } return(0); } } AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(LastRites); Console.WriteLine("Wait forever"); new Magellan(verbosity); Console.WriteLine("started"); Thread.Sleep(Timeout.Infinite); Console.WriteLine("exiting?"); return(0); }
static public void Main(string[] args) { var d = new Discover(); }
/** Initialize PDCX control with servers and response timeout */ protected bool initDevice() { if (ax_control == null) { var d = new Discover.Discover(); try { var type = d.GetType("AxLayer.PdcxWrapper"); ax_control = (IAxWrapper)Activator.CreateInstance(type); } catch (Exception) { ax_control = new FakeAx(); } ax_control.ServerIPConfig(server_list, 0); ax_control.SetResponseTimeout(CONNECT_TIMEOUT); InitPDCX(); } ax_control.CancelRequest(); if (rba != null) { rba.SetParent(this.parent); rba.SetVerbose(this.verbose_mode); rba.stubStart(); } return true; }