public static void LoadModules() { MyLog.INFO.WriteLine("Loading system modules..."); AddModuleFromAssembly(new FileInfo(MyResources.GetEntryAssemblyPath() + "\\" + CORE_MODULE_NAME), true); MyLog.INFO.WriteLine("Loading custom modules..."); foreach (string modulePath in ModulesSearchPath) { FileInfo info = new FileInfo(modulePath); if ((info.Attributes & FileAttributes.Directory) > 0) { info = new FileInfo(Path.Combine(info.FullName, info.Name + ".dll")); } if (info.Exists) { AddModuleFromAssembly(info); } else { MyLog.ERROR.WriteLine("Module assembly not found: " + info); } } }
static MyConfiguration() { GlobalPTXFolder = MyResources.GetEntryAssemblyPath() + @"\modules\GoodAI.BasicNodes\ptx\"; KnownNodes = new Dictionary <Type, MyNodeConfig>(); KnownWorlds = new Dictionary <Type, MyWorldConfig>(); Modules = new List <MyModuleConfig>(); ModulesSearchPath = new List <string>(); AssemblyLookup = new Dictionary <Assembly, MyModuleConfig>(); }
public static void SetupModuleSearchPath() { //SearchPath.Add(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); //add bs folder name if (Directory.Exists(MyResources.GetEntryAssemblyPath() + "\\" + MODULES_PATH)) { foreach (string modulePath in Directory.GetDirectories(MyResources.GetEntryAssemblyPath() + "\\" + MODULES_PATH)) { ModulesSearchPath.Add(modulePath); } } }
public static void SetupModuleSearchPath() { var modulesPath = Path.Combine(MyResources.GetEntryAssemblyPath(), MODULES_PATH); if (Directory.Exists(modulesPath)) { foreach (string modulePath in Directory.GetDirectories(modulesPath)) { ModulesSearchPath.Add(modulePath); } } }
public static void LoadModules() { MyLog.INFO.WriteLine("Loading system modules..."); AddModuleFromAssembly( new FileInfo(Path.Combine(MyResources.GetEntryAssemblyPath(), CORE_MODULE_NAME)), basicNode: true); if (ModulesSearchPath.Count == 0) { throw new InvalidOperationException("ModulesSearchPath must not be empty."); } MyLog.INFO.WriteLine("Loading custom modules..."); ListModules().ForEach(moduleFileInfo => AddModuleFromAssembly(moduleFileInfo)); }
public MyProjectRunner(MyLogLevel level = MyLogLevel.DEBUG) { // why not to directly ask for TypeMap.GetInstance<MySimulation> ? // because in Typemap configuration, MySimulation is set to be singleton - this causes problems when MyProjectRunner // is instantiated multiple times - second and following instances obtain an instance of MySimulation from the first // MyProjectRunner instance. If the first MyProjectRunner instance was Shutdown-ed, the MySimulation instance is also // cleared and any following Shutdown on other MyProjectRunner instances will cause freeze/inifnite hang. // This code creates new MySimulation instance for each MyProjectRunner instance. // Other solution could be to not have a MySimulation as a singleton in TypeMap configuration - and it could work just OK, // because in BrainSim, the TypeMap's GetInstance on MySimulation is only on one place in MainForm. However, this may change // in future or the change itself may have other consequences, so for now I pick this solution, as it is safer. MySimulation simulation = new MyLocalSimulation(TypeMap.GetInstance <MyValidator>(), TypeMap.GetInstance <IMyExecutionPlanner>()); SimulationHandler = new MySimulationHandler(simulation); m_resultIdCounter = 0; SimulationHandler.ProgressChanged += SimulationHandler_ProgressChanged; SimulationHandler.StepPerformed += SimulationHandler_StepPerformed; m_monitors = new List <Tuple <int, uint, MonitorFunc> >(); m_results = new Hashtable(); Project = new MyProject(); var path = MyResources.GetEntryAssemblyPath(); if (MyConfiguration.ModulesSearchPath.Count == 0) { MyConfiguration.SetupModuleSearchPath(); } MyConfiguration.ProcessCommandParams(); try { if (MyConfiguration.Modules.Count == 0) { MyConfiguration.LoadModules(); } } catch (Exception e) { MyLog.WARNING.WriteLine(e.Message); throw; } MyLog.Level = level; }
private void LoadLicensesList() { // first add our own license var eulaFile = Path.Combine(MyResources.GetEntryAssemblyPath(), @"EULA.rtf"); if (File.Exists(eulaFile)) { licenseList.Items.Add(new LicenseItem(eulaFile, "GoodAI Brain Simulator")); } // add licenses for 3rd party libs var licensesDirInfo = new DirectoryInfo(Path.Combine(MyResources.GetEntryAssemblyPath(), @"licenses")); foreach (var file in licensesDirInfo.GetFiles("*.txt")) { licenseList.Items.Add(new LicenseItem(file.FullName)); } }
public MyProjectRunner(MyLogLevel level = MyLogLevel.DEBUG) { MySimulation simulation = TypeMap.GetInstance <MySimulation>(); SimulationHandler = new MySimulationHandler(simulation); m_resultIdCounter = 0; SimulationHandler.ProgressChanged += SimulationHandler_ProgressChanged; SimulationHandler.StepPerformed += SimulationHandler_StepPerformed; m_monitors = new List <Tuple <int, uint, MonitorFunc> >(); m_results = new Hashtable(); Project = new MyProject(); var path = MyResources.GetEntryAssemblyPath(); if (MyConfiguration.ModulesSearchPath.Count == 0) { MyConfiguration.SetupModuleSearchPath(); } MyConfiguration.ProcessCommandParams(); try { if (MyConfiguration.Modules.Count == 0) { MyConfiguration.LoadModules(); } } catch (Exception e) { MyLog.WARNING.WriteLine(e.Message); throw; } MyLog.Level = level; }