public byte[] RecvData() { if (DataQueue.Count > 0) { return((byte[])DataQueue.Dequeue()); } return(null); }
/*initialize infomation on the client*/ public PrivateClient(string ip, int port, DataQueue commandsQue) { commands = commandsQue; //create the TCP client this.server = new TcpClient(); System.Diagnostics.Debug.WriteLine("Client connecting on ip = {0} and port = {1}", ip, port); //connect the TCP client to the server server.Connect(ip, port); }
public void End() { ThrowIfEnded(); lock (MergeLock) { DataQueue.End(); MessageQueue.End(); } }
void OnDestroy() { queue = null; SceneControllerHub.Instance.UnregisterScene(scene); foreach (var view in views) { handlers.Remove(view); } }
/// <summary> /// Initializes a new instance of the <see cref="DataAggregationTriggerActivity"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository.</param> /// <param name="dataQueue">The data queue.</param> /// <param name="options">The data queue message options.</param> public DataAggregationTriggerActivity( NotificationDataRepository notificationDataRepository, DataQueue dataQueue, IOptions <DataQueueMessageOptions> options) { this.notificationDataRepository = notificationDataRepository ?? throw new ArgumentNullException(nameof(notificationDataRepository)); this.dataQueue = dataQueue ?? throw new ArgumentNullException(nameof(dataQueue)); this.messageDelayInSeconds = options?.Value?.MessageDelayInSeconds ?? throw new ArgumentNullException(nameof(options)); }
public void ManualQueueWithDatesTest() { DataQueue queue = new DataQueue(true, true); queue.PutLast(Decimal64.One, new DateTime(1)); Assert.AreEqual(1, queue.Count); queue.PutLast(Decimal64.Two, new DateTime(2)); Assert.AreEqual(Decimal64.One, queue.GetPointsAgo(1)); Assert.AreEqual(new DateTime(1), queue.GetTimeByIndexAgo(1)); Assert.AreEqual(Decimal64.Two, queue.GetPointsAgo(0)); Assert.AreEqual(new DateTime(2), queue.GetTimeByIndexAgo(0)); for (int i = 3; i < 100; i++) { queue.PutLast(Decimal64.FromDouble(i), new DateTime(i)); } Assert.AreEqual(99, queue.Count); Assert.AreEqual(Decimal64.FromDouble(4), queue.GetPointsAgo(95)); Assert.AreEqual(new DateTime(4), queue.GetTimeByIndexAgo(95)); Assert.AreEqual(Decimal64.One, queue.First); Assert.AreEqual(new DateTime(1), queue.FirstDateTime); queue.RemoveFirst(); Assert.AreEqual(Decimal64.FromDouble(2), queue.GetPointsAgo(97)); Assert.AreEqual(new DateTime(2), queue.GetTimeByIndexAgo(97)); Assert.AreEqual(98, queue.Count); queue.PutFirst(Decimal64.One, new DateTime(1)); Assert.AreEqual(Decimal64.FromDouble(1), queue.GetPointsAgo(98)); Assert.AreEqual(new DateTime(1), queue.GetTimeByIndexAgo(98)); Assert.AreEqual(Decimal64.FromDouble(4950), queue.SumOfAbsoluteValues); Assert.AreEqual(Decimal64.FromDouble(328350), queue.SumOfSquares); Assert.AreEqual(Decimal64.FromDouble(4950), queue.Sum); Assert.AreEqual(50, queue.ExpectedValue.ToDouble(), 0.001); DataQueue queueClone = queue.Clone(); queueClone.RemoveLast(); Assert.AreEqual(Decimal64.FromDouble(98), queueClone.Last); Assert.AreEqual(new DateTime(98), queueClone.LastDateTime); Assert.AreEqual(Decimal64.FromDouble(99), queue.Last); Assert.AreEqual(new DateTime(99), queue.LastDateTime); Assert.AreEqual(Decimal64.FromDouble(4851), queueClone.SumOfAbsoluteValues); Assert.AreEqual(Decimal64.FromDouble(318549), queueClone.SumOfSquares); Assert.AreEqual(Decimal64.FromDouble(4851), queueClone.Sum); queue.SetPointsAgo(1, Decimal64.Zero); Assert.AreEqual(Decimal64.FromDouble(0), queue.GetPointsAgo(1)); Assert.AreEqual(new DateTime(98), queue.GetTimeByIndexAgo(1)); Assert.AreEqual(queue.Last, queue.GetPointsAgo(0)); Assert.AreEqual(Decimal64.FromDouble(4852), queue.Sum); Assert.AreEqual(74, queue.GetIndexByTime(new DateTime(25))); Assert.AreEqual(89, queue.GetIndexByTime(new DateTime(10))); Assert.AreEqual(Decimal64.FromDouble(25), queue.GetByTime(new DateTime(25))); queue.SetByTime(new DateTime(25), Decimal64.FromDouble(100)); Assert.AreEqual(Decimal64.FromDouble(4927), queue.Sum); }
void Awake() { handlers = new Handlers(); foreach (var view in views) { handlers.Add(view, view.DataType, view.UpdateView); } queue = SceneControllerHub.Instance.RegisterScene(scene); StartCoroutine(WorkLoop()); }
static void tcpclient_OnReceivedData(object sender, TcpClient.ReceivedDataEventArgs e) { TcpClient tcp = sender as TcpClient; //写入接收数据队列 lock (DataQueue) { DataQueue.Enqueue(Encoding.UTF8.GetString(e.RevData)); } }
public void QueueData(byte[] data) { if (!Started) { throw new InvalidOperationException("Unable to queue element: Queue processing is not running"); } Logger.Trace("Queue new element {0}", data.GetHashCode()); DataQueue.Enqueue(data); DataAvailableEvent.Set(); }
public void DataQueue_TestAddOverFlowProtection() { Motus_1_RawDataPacket packet = new Motus_1_RawDataPacket(sampleMotusPayload); DataQueue queue = new DataQueue(); for (int i = 0; i < queue.MaxSize; i++) { Assert.IsTrue(queue.Add(packet)); } Assert.IsFalse(queue.Add(packet)); }
static void Main(string[] args) { if (args.Length <= 0) { Console.WriteLine("usage: ./VeracityTest <input file path> <time to run (ms)> <delay between producer writes (ms)>"); Console.ReadLine(); return; } FileInfo inputFile = new FileInfo(args[0]); if (!inputFile.Exists) { Console.WriteLine($"File {inputFile.FullName} doesn't exist!"); Console.ReadLine(); return; } Console.WriteLine("control+c to quit early"); int runLength = 10000; int delay = 500; if (args.Length > 1 && int.TryParse(args[1], out int val)) { runLength = val; } if (args.Length > 2 && int.TryParse(args[2], out int val2)) { delay = val2; } IDataQueue dataQueue = new DataQueue(); IProducer producer = new FileProducer(dataQueue, inputFile); IConsumer consoleConsumer = new ConsoleConsumer(dataQueue); IConsumer fileConsumer = new FileConsumer(dataQueue, new FileInfo(@".\output.txt")); dataQueue.RegisterListener(ConsumerType.CONSOLE, consoleConsumer); dataQueue.RegisterListener(ConsumerType.FILE, fileConsumer); producer.StartProducer(delay); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); while (stopWatch.ElapsedMilliseconds < runLength) { Thread.Sleep(500); } stopWatch.Stop(); producer.StopProducer(); }
public void DataQueue_TestFlush() { DataQueue queue = new DataQueue(); Motus_1_RawDataPacket packet = new Motus_1_RawDataPacket(); FillQueue(queue, packet); Assert.IsFalse(queue.IsEmpty()); Assert.AreEqual(queue.Count, queue.MaxSize); queue.Flush(); Assert.IsTrue(queue.IsEmpty()); Assert.AreEqual(queue.Count, 0); }
/// <summary> /// 从源HTML中解析数据到队列 /// </summary> public override void ResolveDataInQueue() { if (_tables == null) { _tables = TableHelper.ResolveTables(SourceHtml); } foreach (var tb in _tables) { //将解释出来的TableDesc加入数据队列 DataQueue.Enqueue(tb); } }
public void ManualQueueTest() { DataQueue queue = new DataQueue(true, false); queue.PutLast(Decimal64.One); Assert.AreEqual(1, queue.Count); queue.PutLast(Decimal64.Two); Assert.AreEqual(Decimal64.One, queue.GetPointsAgo(1)); Assert.AreEqual(Decimal64.Two, queue.GetPointsAgo(0)); for (int i = 0; i < 100; i++) { queue.PutLast(Decimal64.FromDouble(i)); } Assert.AreEqual(102, queue.Count); Assert.AreEqual(Decimal64.FromDouble(4), queue.GetPointsAgo(95)); Assert.AreEqual(Decimal64.One, queue.First); queue.RemoveFirst(); Assert.AreEqual(Decimal64.FromDouble(2), queue.GetPointsAgo(100)); Assert.AreEqual(101, queue.Count); queue.PutFirst(Decimal64.One); Assert.AreEqual(Decimal64.FromDouble(1), queue.GetPointsAgo(101)); Assert.AreEqual(Decimal64.FromDouble(4953), queue.SumOfAbsoluteValues); Assert.AreEqual(Decimal64.FromDouble(328355), queue.SumOfSquares); Assert.AreEqual(Decimal64.FromDouble(4953), queue.Sum); Assert.AreEqual(48.559, queue.ExpectedValue.ToDouble(), 0.001); Assert.AreEqual(Decimal64.FromDouble(99), queue.Last); DataQueue queueClone = queue.Clone(); queueClone.RemoveLast(); Assert.AreEqual(Decimal64.FromDouble(98), queueClone.Last); Assert.AreEqual(Decimal64.FromDouble(99), queue.Last); Assert.AreEqual(Decimal64.FromDouble(4854), queueClone.SumOfAbsoluteValues); Assert.AreEqual(Decimal64.FromDouble(318554), queueClone.SumOfSquares); Assert.AreEqual(Decimal64.FromDouble(4854), queueClone.Sum); queue.SetPointsAgo(1, Decimal64.Zero); Assert.AreEqual(Decimal64.FromDouble(0), queue.GetPointsAgo(1)); Assert.AreEqual(queue.Last, queue.GetPointsAgo(0)); Assert.AreEqual(Decimal64.FromDouble(4855), queue.Sum); var arr = queue.ToArray(); int idx = 0; foreach (var x in queue) { Assert.AreEqual(x, arr[idx++]); } }
public void DataQueue_TestTransferAllUnderFlow() { DataQueue queue1 = new DataQueue(); Motus_1_RawDataPacket packet = new Motus_1_RawDataPacket(); FillQueue(queue1, packet); DataQueue queue2 = new DataQueue(128); queue2.TransferAll(queue1); Assert.IsTrue(queue1.IsEmpty()); Assert.IsFalse(queue2.IsEmpty()); Assert.AreEqual(queue2.Count, queue1.MaxSize); }
public void DataQueue_TestGetStreamableBufferOverflow() { byte[] stream = new byte[1028]; Motus_1_RawDataPacket packet = new Motus_1_RawDataPacket(sampleMotusPayload); DataQueue queue = new DataQueue(); int expectedNumPacketsToQueue = (stream.Length / (18 + DataPacket.NumOverHeadBytes)); int expectedNumBytesToQueue = (18 + DataPacket.NumOverHeadBytes) * expectedNumPacketsToQueue; FillQueue(queue, packet); int numBytesQueued = queue.GetStreamable(stream); int numPacketsQueued = queue.MaxSize - queue.Count; Assert.AreEqual(expectedNumBytesToQueue, numBytesQueued); Assert.AreEqual(expectedNumPacketsToQueue, numPacketsQueued); }
public void CheckDataQueueDequeueTypeCorrect() { IDataQueue dataQueue = new DataQueue(); var consumer = new Mock <IConsumer>(); ConsumerType inType = ConsumerType.CONSOLE; ConsumerType outType = ConsumerType.FILE; consumer.Setup(c => c.OnItemAdded()).Callback(() => outType = dataQueue.GetNextItem(inType).ConsumerType); dataQueue.RegisterListener(inType, consumer.Object); dataQueue.AddItem(new DataItem(inType, "DUMMY")); Assert.That(inType.Equals(outType), $"Expected type to be {inType} but was {outType}"); }
/// <summary> /// Initializes a new instance of the <see cref="CompanyCommunicatorDataFunction"/> class. /// </summary> /// <param name="notificationDataRepository">The notification data repository.</param> /// <param name="aggregateSentNotificationDataService">The service to aggregate the Sent /// Notification Data results.</param> /// <param name="updateNotificationDataService">The service to update the notification totals.</param> /// <param name="dataQueue">The data queue.</param> /// <param name="dataQueueMessageOptions">The data queue message options.</param> public CompanyCommunicatorDataFunction( NotificationDataRepository notificationDataRepository, AggregateSentNotificationDataService aggregateSentNotificationDataService, UpdateNotificationDataService updateNotificationDataService, DataQueue dataQueue, IOptions <DataQueueMessageOptions> dataQueueMessageOptions) { this.notificationDataRepository = notificationDataRepository; this.aggregateSentNotificationDataService = aggregateSentNotificationDataService; this.updateNotificationDataService = updateNotificationDataService; this.dataQueue = dataQueue; this.firstTenMinutesRequeueMessageDelayInSeconds = dataQueueMessageOptions.Value.FirstTenMinutesRequeueMessageDelayInSeconds; this.requeueMessageDelayInSeconds = dataQueueMessageOptions.Value.RequeueMessageDelayInSeconds; }
public void DataQueue_TestGet() { Motus_1_RawDataPacket packet = new Motus_1_RawDataPacket(sampleMotusPayload); DataQueue queue = new DataQueue(); queue.Add(packet); DataPacket getPacket = queue.Get(); Assert.AreEqual(packet.Type, getPacket.Type); Assert.AreEqual(packet.ExpectedLen, getPacket.ExpectedLen); for (int i = 0; i < packet.ExpectedLen; i++) { Assert.AreEqual(packet.Payload[i], getPacket.Payload[i]); } }
public GameServer(Socket socket, string tcppaswd, int serverid, string ipportname) { Alive = true; string[] srvinfos = ipportname.Split(new[] { '|' }, 4); Name = srvinfos[3]; tcppasswd = tcppaswd; SteamID = long.Parse(srvinfos[0]); IP = IPAddress.Parse(srvinfos[1]); Port = Int32.Parse(srvinfos[2]); this.socket = socket; ServerID = serverid; dataQueue = new DataQueue(); dataQueue.OnAdd += DataQueue_OnAdd; FirstSend(ServerID); }
/// <summary> /// Sends a request to change data into the queue. Processing is asynchronous /// and you cannot reliably retrieve the data directly from the database immediately afterwards. /// However, data in the cache will be up to date as soon as a value is changed. /// </summary> /// <param name="data">The data to submit for processing</param> /// <param name="actionType">The type (Insert, Update, Delete, etc.) of change to make.</param> public void SubmitDataChange(IEntity data, DatabaseActionType actionType) { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (actionType == DatabaseActionType.Insert || actionType == DatabaseActionType.Update) { SetIntoCache(data.GetType(), GetEntityKey(data), data); } else if (actionType == DatabaseActionType.Delete) { DeleteFromCache(data.GetType(), GetEntityKey(data)); } DataQueue.Enqueue(new DatabaseAction(data, actionType)); }
/// <summary> /// Sends a request to change data into the queue. Processing is asynchronous /// and you cannot reliably retrieve the data directly from the database immediately afterwards. /// However, data in the cache will be up to date as soon as a value is changed. /// </summary> /// <param name="data">The data to submit for processing</param> /// <param name="actionType">The type (Insert, Update, Delete, etc.) of change to make.</param> public static void SubmitDataChange <T>(T data, DatabaseActionType actionType) where T : class, IEntity { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (actionType == DatabaseActionType.Insert || actionType == DatabaseActionType.Update) { SetIntoCache(data); } else if (actionType == DatabaseActionType.Delete) { RemoveFromCache(data); } DataQueue.Enqueue(new DatabaseAction(data, actionType)); }
public void CheckDataQueueInputCountMatchesOutputCount() { IDataQueue dataQueue = new DataQueue(); var consumer = new Mock <IConsumer>(); int inCount = 10; int outCount = 0; consumer.Setup(c => c.OnItemAdded()).Callback(() => outCount++); dataQueue.RegisterListener(ConsumerType.CONSOLE, consumer.Object); for (int i = 0; i < inCount; i++) { dataQueue.AddItem(new DataItem(ConsumerType.CONSOLE, "")); } Assert.That(inCount.Equals(outCount), $"Expected outCount to be {inCount} but was {outCount}"); }
public void SocketWrapper_TestEndToEnd() { SocketWrapper server = new SocketWrapper(Configuration.server); SocketWrapper client = new SocketWrapper(Configuration.client); DataQueue knownData = new DataQueue(); DataQueue toSend = new DataQueue(); DataQueue toRecieve = new DataQueue(); short[] known = new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; byte[] payload = new byte[known.Length * 2]; Buffer.BlockCopy(known, 0, payload, 0, payload.Length); Motus_1_RawDataPacket dummyPacket = new Motus_1_RawDataPacket(payload); for (int i = 0; i < knownData.MaxSize; i++) { knownData.Add(dummyPacket); toSend.Add(dummyPacket); } server.StartServer(); server.ServerSetTxData(toSend); Assert.IsTrue(toSend.IsEmpty()); client.ClientStartRead(); Thread.Sleep(1000); Assert.IsTrue(client.ClientHasData()); client.ClientGetRxData(toRecieve); Assert.AreEqual(toRecieve.Count, toRecieve.MaxSize); while (!toRecieve.IsEmpty()) { Motus_1_RawDataPacket packetKnown = new Motus_1_RawDataPacket(knownData.Get()); Motus_1_RawDataPacket packetTest = new Motus_1_RawDataPacket(toRecieve.Get()); short[] payloadKnown = packetKnown.DeSerialize(); short[] payloadTest = packetTest.DeSerialize(); for (int i = 0; i < payloadKnown.Length; i++) { Assert.AreEqual(known[i], payloadKnown[i]); Assert.AreEqual(payloadKnown[i], payloadTest[i]); } } }
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { try { if (start) { start = false; if (DataQueue.IsAlive) { if (false == DataQueue.Join(5000)) { DataQueue.Abort(); } } if (AI.IsAlive) { if (false == AI.Join(5000)) { AI.Abort(); } } aitask.Stop(); aitask.Channels.Clear();//把上次启动添加的通道清掉 if (Delete.IsAlive) { if (false == Delete.Join(5000)) { Delete.Abort(); } } } if (mqtt_client.IsConnected) { mqtt_client.Disconnect(); } } catch { } }
/// <summary> /// 生成实体类文件 /// </summary> public override void GenerateFiles() { //获取Mapping类模板内容 string templateContent = Tools.ReadFileContent(Configs.MappingTemplatePath); //数据表总数 int tableCount = DataQueue.Count(); Console.WriteLine($"共有{tableCount}个Mapping类待生成:"); //处理数据表转换队列 while (DataQueue.Count() > 0) { var table = (TableDesc)DataQueue.Dequeue(); Console.WriteLine($"正在生成【Mapping类】{table.Description}({table.Name})……{tableCount - DataQueue.Count()}/{tableCount}"); //Mapping类解析对象上下文 MappingResolveContext context = new MappingResolveContext(templateContent, table); //解析器集合 List <MappingExpression> exps = new List <MappingExpression>(); exps.Add(new ModuleNameExpression()); //模块名称文法解释器 exps.Add(new MappingNameExpression()); //Mapping名称文法解释器 exps.Add(new TableSchemaExpression()); //Mapping类数据表架构(Schema)文法解释器 exps.Add(new MappingHasKeysExpression()); //Mapping主键配置处理文法解释器 exps.Add(new MappingColumnsExpression()); //Mapping字段配置处理文法解释器 //循环执行解析 foreach (var exp in exps) { exp.Interpret(context); } //存储的最终文件路径 string filePath = $@"{OutputDirectory}\{context.Table.Module}\{context.Table.Name}Mapping.cs"; //写入文件并保存 SaveFile(filePath, context.Output); } }
private async Task ProcessQueue(Stream stream) { while (true) { await Task.WhenAny(DataAvailableEvent.WaitOneAsync(), StopEvent.WaitOneAsync()); if (!StopEvent.WaitOne(0)) { byte[] data; if (!DataQueue.TryDequeue(out data)) { Logger.Trace("Unable to deque element from Queue due to concurrency access"); } if (DataQueue.IsEmpty) { Logger.Trace("Writing queue is empty. Wait for new element..."); DataAvailableEvent.Reset(); } try { Logger.Trace("Write queue element {0}", data.GetHashCode()); await stream.WriteAsync(data, 0, data.Length); } catch (Exception e) { Logger.Debug(e, "Unable to send data"); QueueData(data); break; } } else { Logger.Trace("Queue is stopped"); StopEvent.Reset(); break; } } }
/// <summary> /// 生成实体类文件 /// </summary> public override void GenerateFiles() { //获取实体类模板内容 string templateContent = Tools.ReadFileContent(Configs.EntityTemplatePath); //数据表总数 int tableCount = DataQueue.Count(); Console.WriteLine($"共有{tableCount}个实体类类文件待生成:"); //处理数据表转换队列 while (DataQueue.Count() > 0) { var table = (TableDesc)DataQueue.Dequeue(); Console.WriteLine($"正在生成【实体类】{table.Description}({table.Name})……{tableCount - DataQueue.Count()}/{tableCount}"); //实体类解析对象上下文 EntityClassResolveContext context = new EntityClassResolveContext(templateContent, table); //解析器集合 List <EntityClassExpression> exps = new List <EntityClassExpression>(); exps.Add(new ModuleNameExpression()); //模块名称文法解释器 exps.Add(new EntityNameExpression()); //实体名称文法解释器 exps.Add(new EntityDescriptionExpression()); //实体类描述文法解释器 exps.Add(new ForEachPropertiesExpression()); //实体属性循环处理文法解释器 exps.Add(new ForeachPrimaryKeysExpression()); //实体主键处理方法解释器 //循环执行解析 foreach (var exp in exps) { exp.Interpret(context); } //存储的最终文件路径 string filePath = $@"{OutputDirectory}\{context.TableDesc.Module}\{context.TableDesc.Name}.cs"; //写入文件并保存 SaveFile(filePath, context.OutputEntityClassContent); } }
/// <summary> /// Initializes a new instance of the <see cref="SentNotificationsController"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository service that deals with the table storage in azure.</param> /// <param name="sentNotificationDataRepository">Sent notification data repository.</param> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="prepareToSendQueue">The service bus queue for preparing to send notifications.</param> /// <param name="dataQueue">The service bus queue for the data queue.</param> /// <param name="dataQueueMessageOptions">The options for the data queue messages.</param> /// <param name="sendBatchesDataRepository">The send batches data repository.</param> /// <param name="groupsService">The groups service.</param> /// <param name="exportDataRepository">The Export data repository instance.</param> public SentNotificationsController( NotificationDataRepository notificationDataRepository, SentNotificationDataRepository sentNotificationDataRepository, TeamDataRepository teamDataRepository, PrepareToSendQueue prepareToSendQueue, DataQueue dataQueue, IOptions <DataQueueMessageOptions> dataQueueMessageOptions, SendBatchesDataRepository sendBatchesDataRepository, IGroupsService groupsService, ExportDataRepository exportDataRepository) { this.notificationDataRepository = notificationDataRepository; this.sentNotificationDataRepository = sentNotificationDataRepository; this.teamDataRepository = teamDataRepository; this.prepareToSendQueue = prepareToSendQueue; this.dataQueue = dataQueue; this.forceCompleteMessageDelayInSeconds = dataQueueMessageOptions.Value.ForceCompleteMessageDelayInSeconds; this.sendBatchesDataRepository = sendBatchesDataRepository; this.groupsService = groupsService; this.exportDataRepository = exportDataRepository; }
/// <summary> /// !! main thread !! /// </summary> private void Scanner() { myProtocol.ConnectReq(out myPort, myTelNum); mySegmentState = StateEnum.Connected; while (mySegmentState == StateEnum.Connected) { //wlaczamy nasluchiwanie polaczenia if (myProtocol.ListenReq(true) != 0) { throw new System.Exception("Cannot listen (myProtocol)"); } while (true) { //rozpoczêcie czekania na po³aczenie object port; int conind; conind = myProtocol.ConnectInd(out port); if (conind == 0) { ReadValue readvalue; IBlockDescription description; #region ReadCMD loop while (myProtocol.ReadData(out description, out readvalue, myPort)) { myProtocol.Statistic.TimeSlaveResponseDelayResetAndStart(); DataQueue.UpdateAllTags(description, readvalue); myProtocol.Statistic.TimeSlaveResponseDelayStop(); if (readvalue != null) { readvalue.ReturnEmptyEnvelope(); } } //while ( myProtocol.ReadCMD( port, out description, station, out cmd, out message) ) #endregion ReadCMD loop } } //while } //while(mySegmentState=StateEnum.Connected) } //ScannerThread
void Init() { InitLed(); ppTcpReceiver.FrameReceived = OnFrameSplit; dataQueue = new DataQueue<byte[]>(); dataQueue.ActionReceive = QueueReceive; dataQueue.ActionSend = QueueSend; dataQueue.Start(); portData.OnReceiveData += new EventHandler<IOLib.ReceiveEventArgs>(portData_OnReceiveData); portData.LoadConfig_SerialPort(); portData.OpenAll(); List<string> valueList = portData.GetSerialPortStatus(); SafeOutText(string.Format("{0}", DateTime.Now)); SafeOutText("==========================================="); foreach (string item in valueList) { SafeOutText(item); } SafeOutText("==========================================="); }
void InitDataQueue() { dataQueue = new DataQueue<EventArgsPackage>(); dataQueue.ActionReceive = QueueReceive; dataQueue.ActionSend = QueueSend; dataQueue.Start(); }