static void StartRepoMockTest() { string _loggingPath = $"{System.Reflection.Assembly.GetExecutingAssembly().Location}Collector{Path.DirectorySeparatorChar}"; ILogger logger = new LoggerConfiguration() .WriteTo.Console().MinimumLevel.Information() .CreateLogger(); string IPAddress = "192.168.10.11"; string MAC = "00D0C9FCA9BA"; var _pressWriterInflux = new RepositoryWriterMachineMock( (machine, IsConnected) => { logger.Information($"Mock Connection Write: {machine.Line}-{machine.MAC}-{IsConnected}"); }, (machine, IsCycling) => { logger.Information($"Mock Status Write: {machine.Line}-{machine.MAC}-{IsCycling}"); return(DateTime.UtcNow); } ); var realPress = new PressAdam6051( new Repository.Model.MachineInfoInflux() { IPAddress = IPAddress, MAC = MAC, Line = "Y-1-1", Department = Tag.Value.DepartmentPartsProduction, Name = "BC-80020001-0000" }, _pressWriterInflux, new PressAdam6051PayloadConverterStatus(), logger ); var _pressList = new List <PressAdam6051>(); _pressList.Add(realPress); for (int i = 2; i < 13; i++) { _pressList.Add(new PressAdam6051(new Repository.Model.MachineInfoInflux() { IPAddress = IPAddress, MAC = "00D0C9FCA9BA", Line = $"Z-1-{i}", Department = Tag.Value.DepartmentPartsProduction, Name = $"BC-801{"0000":i}-0000", }, _pressWriterInflux, new PressAdam6051MessageConverterMock(i), logger) ); } //var _listOfTopicHandlers = new List<ITopicMessageHandler>(); var PressTopicHandlerForData = new TopicHandler(realPress.TopicForStatus, realPress); //_listOfTopicHandlers.Add(PressTopicHandlerForData); var _messageProcessor = new MessageProcessor(logger); _messageProcessor.AddMachineTopicHandler(PressTopicHandlerForData); foreach (var press in _pressList) { _messageProcessor.AddMachineTopicHandler(new TopicHandler(press.TopicForStatus, press)); } var _collector = new MQTTCollector(_messageProcessor, logger); _collector.Start(); _messageProcessor.StartProcessing(); _collector.WaitUntilStopped(); }
private static async Task RunTestNotLoadedFromFileTest(ILogger sublogger) { string IPAddress = "192.168.10.11"; string MAC = "00D0C9FCA9BA"; // var influxServerAddress = new Uri("http://192.168.1.208:8086"); var repo = new MachineRepository("192.168.1.208"); if (!repo.CanConnect()) { sublogger.Fatal("Can't Connect to DB Server. Exiting..."); return; } var _pressWriterInflux = new RepositoryWriterPressInflux(repo, sublogger); var realPress = new PressAdam6051( new Repository.Model.MachineInfoInflux() { IPAddress = IPAddress, MAC = MAC, Line = "Y-1-1", Department = Tag.Value.DepartmentPartsProduction, Name = "Y-1-1" }, _pressWriterInflux, new PressAdam6051PayloadConverterStatus(), sublogger ); var _pressList = new List <PressAdam6051>(); _pressList.Add(realPress); for (int i = 2; i < 13; i++) { _pressList.Add(new PressAdam6051(new Repository.Model.MachineInfoInflux() { IPAddress = IPAddress, MAC = "00D0C9FCA9BA", Line = $"Z-1-{i}", Department = Tag.Value.DepartmentPartsProduction, Name = $"Z-1-{i}", }, _pressWriterInflux, new PressAdam6051MessageConverterMock(i), sublogger) ); } //var _listOfTopicHandlers = new List<ITopicMessageHandler>(); var PressTopicHandlerForData = new TopicHandler(realPress.TopicForStatus, realPress); //_listOfTopicHandlers.Add(PressTopicHandlerForData); var _messageProcessor = new MessageProcessor(sublogger); _messageProcessor.AddMachineTopicHandler(PressTopicHandlerForData); foreach (var press in _pressList) { _messageProcessor.AddMachineTopicHandler(new TopicHandler(press.TopicForStatus, press)); } var _collector = new MQTTCollector(_messageProcessor, sublogger); Console.WriteLine("Starting Collection"); //await _collector.StartAsync(); _collector.Start(); _messageProcessor.StartProcessing(); Console.WriteLine("Waiting indefinitely"); await _collector.WaitUntilStoppedAsync(); }