private static void readInputAndChangeStatus(UnityContainer container) { IRFIDService rfidService = container.Resolve <IRFIDService>(); String command = ""; while (true) { Console.Write("Input a command:"); command = Console.ReadLine(); if (command == "start") { rfidService.start(); Console.WriteLine("Start RFID!"); } if (command == "stop") { rfidService.stop(); Console.WriteLine("Stop RFID!"); } if (command.StartsWith("set")) { String[] strArray = command.Split(' '); if (strArray.Length != 3) { continue; } rfidService.HardwareInterface = strArray[1]; rfidService.HardwareInterfaceConnectionSpeed = strArray[2]; } } }
public static void testRFID(UnityContainer container) //测试程序入口 { IEventAggregator eventAggregator = container.Resolve <IEventAggregator>(); eventAggregator.GetEvent <RFIDHardwareEvent>().Subscribe(RFIDFailureHander); eventAggregator.GetEvent <RFIDNewItemEvent>().Subscribe(RFIDNewItemHander); IRFIDService rfidService = container.Resolve <IRFIDService>(); rfidService.HardwareInterface = ""; rfidService.HardwareInterfaceConnectionSpeed = ""; rfidService.start(); readInputAndChangeStatus(container); Console.ReadLine(); }
public void OnNavigatedTo(NavigationContext navigationContext) { //ISerialService serialService = container.Resolve<ISerialService>(); //IBookInformationService bookInformationService = container.Resolve<IBookInformationService>(); //IBookLocationService bookLocationService = container.Resolve<IBookLocationService>(); IRFIDService rfidService = container.Resolve <IRFIDService>(); //开始读取RFID的信息,并查询数据库 eventAggregator.GetEvent <RFIDNewItemEvent>().Subscribe(handleNewItemFromRFID); //开始订阅RFID服务发出的事件,这个事件是扫描到的条码的信息,在该view非激活时务必取消此事件的订阅 eventAggregator.GetEvent <RFIDHardwareEvent>().Subscribe(handleErrorFromRFID); eventAggregator.GetEvent <DatabaseEvent>().Subscribe(handleErrorFromDatabase); rfidService.start();//开启rfid的后台扫描线程 }