static void Main(string[] args)
        {
            //dynamic load:
            //load config file from args=>LoadConfig
            //Loader.LoadLog(LoadConfig.Log);
            //Loader.LoadCommunication(LoadConfig.Communication,host);
            //Loader.LoadThing(LoadConfig.Things,host);

            //very first thing to do is congfig logger
            //初始化 LogManager
            NlogProvider.Config();
            Cfet2LogManager.SetLogProvider(new NlogProvider());

            //inject and init the host app module
            var host = new Cfet2Program();

            HubMaster.InjectHubToModule(host);

            //add communication module

            //var comm= new NancyCM("http://localhost:13345");

            //var comm = new AspNetCoreCommunicatonModule();
            //host.MyHub.TryAddCommunicationModule(comm);
            //todo lock comminication so no more communication can be added

            //add things
            host.AddThings(); //this is defined in a partial file of this class f12 to modify

            //start communication modules
            host.MyHub.StartCommunication();

            //start all thins
            host.MyHub.StartThings();


            //start cli loop
            var cli = new CliParser(host);

            cli.Host = host;
            Console.WriteLine("Cfet2 host Cli started");
            while (true)
            {
                Console.Write("Cfet2> ");
                var command = Console.ReadLine();
                try
                {
                    cli.Execute(command);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                if (cli.MySesstion.ShouldExit)
                {
                    //quit the app
                    break;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// initObj是一个AllAndAutoArmAIThings
        /// </summary>
        /// <param name="path"></param>
        public override void TryInit(object path)
        {
            config = new AIManagementConfig((string)path);

            //判断autoArmAIThings是否是allAIThings的子集
            if (!config.AIThings.AutoArmAIThingPaths.All(autoArm => config.AIThings.AllAIThingPaths.Any(every => every == autoArm)))
            {
                throw new Exception("需要自动arm的所有AIThing必须包含在所有AIThing中");
            }
            logger = Cfet2LogManager.GetLogger("AIManagement");
        }
Beispiel #3
0
        public override void TryInit(object initObj)
        {
            base.TryInit(initObj);

            //get a logger
            logger = Cfet2LogManager.GetLogger("Event");

            if (initObj != null)
            {
                config = (ListenerConfig)initObj.TryConvertTo(typeof(ListenerConfig));
            }
            token = MyHub.EventHub.Subscribe(new EventFilter(config.Source, config.EventType), handler);
        }
Beispiel #4
0
 public override void TryInit(object configFilePath)
 {
     myConfig = new UploadConfig((string[])configFilePath);
     if (myConfig != null)
     {
         State = Status.Idle;
     }
     else
     {
         throw new Exception("上传配置文件错误!");
     }
     logger = Cfet2LogManager.GetLogger("UploadLog");
 }
Beispiel #5
0
        public override void TryInit(object initObj)
        {
            var dataAndConfigPath = (DataAndConfigPath)initObj.TryConvertTo(typeof(DataAndConfigPath));

            DataFileParentDirectory = dataAndConfigPath.DataFileParentDirectory;

            //get a logger
            logger = Cfet2LogManager.GetLogger("Event-" + DataFileParentDirectory);

            basicAI.InitAI(dataAndConfigPath.ConfigFilePath);

            //订阅AI的event
            subscribeEvent();
        }
Beispiel #6
0
        public override void TryInit(object configFilePath)
        {
            myConfig = new MdsUploadConfig((string[])configFilePath);
            if (myConfig != null)
            {
                State = Status.Idle;
            }
            else
            {
                State = Status.Error;
            }
            logger = Cfet2LogManager.GetLogger("MdsUploadLog");

            // 当为 Master 时,订阅上传触发事件
            if (myConfig.MasterOrSlave == 1)
            {
                for (int i = 0; i < myConfig.EventPaths.Count(); i++)
                {
                    token = MyHub.EventHub.Subscribe(new EventFilter(myConfig.EventPaths[i], myConfig.EventKinds[i]), handler);
                }
            }
        }