public void Start(string ConfigFilePath) { string strConfig = System.IO.File.ReadAllText(ConfigFilePath); T config = JsonSerializer.Deserialize <T>(strConfig); DriveConfig = config; DeviceConn(config); bus = new BusClient(); this.bus.Subscribe(BusOption.CMD_INPUT); this.bus.OnReceived += Bus_OnReceived; ISRun = true; while (ISRun) { IEnumerable <IOTData> iOTs = GetData(); if (iOTs != null) { if (iOTs.Count() > 0) { bus.Publish(BusOption.DATA_OUTPUT, JsonSerializer.Serialize(iOTs)); } } System.Threading.Thread.Sleep(config.CycleTime); } DeviceDiscnn(); }
static void Main(string[] args) { BusClient bus; bus = new BusClient(); while (true) { List <IOTData> iOTs = new List <IOTData>(); iOTs.Add(new IOTData() { DataCode = "test", DataName = "test", DataValue = "test", DriveCode = "test", DriveType = "test", GTime = DateTime.Now, ID = Guid.NewGuid(), Sended = false, Unit = "" }); bus.Publish(BusOption.DATA_OUTPUT, JsonSerializer.Serialize(iOTs)); System.Threading.Thread.Sleep(2000); } }