private void ClockCheck(SD_Thread Bit)//心跳检测线程 { while (Bit.isStart) { TimeOut = SS_TriggerMarker.Clock_System(LateTime, GetOutTime); //心跳超时检测 Thread.Sleep((int)ClockTimeDelay * 1000); //处理延时 } }
/// <summary> /// 计时器[系统时间]:判断执行时间 /// 循环触发:到达指定时间返回一帧true,并重置时间再次计时 /// 持续触发:到达指定时间后,一直返回true /// </summary> /// <param name="targetSeconds">定时</param> /// <param name="Switch">true/false(循环触发/持续触发)</param> /// <returns>return : 触发标记</returns> public bool IF_Clock_System(float targetSeconds, bool Switch) { bool bit = SS_TriggerMarker.Clock_System(StartTime_System, targetSeconds); if (bit && Switch) { Reset_Marker(); } return((Switch) ? MarkerEdge.isEdge(bit) : bit); }
private void DataQueueProcessor(SD_Thread Bit)//数据队列处理器 { while (Bit.isStart) { if (SS_TriggerMarker.Clock_System(LateTime, ClockTimeDelay) && StartClock) //心跳时间判断 { SetQueue.Enqueue(new byte[] { 1 }); //心跳消息暂时为Byte 1 LateTime = DateTime.Now; //刷新心跳时间 } if (SetQueue.Count > 0)//发送数据 { byte[] data = (byte[])SetQueue.Dequeue(); udpSet.Send(data, data.Length, SetServerPoint); //针对发送数据 LateTime = DateTime.Now; //刷新心跳时间 } Thread.Sleep((int)SetTimeDelay * 1000);//处理延时 } }
/// <summary> /// 计时器[系统时间]:判断执行时间(一次性) /// 到达指定时间返回一帧true /// </summary> /// <param name="targetSeconds">定时</param> /// <returns>return : 触发标记</returns> public bool IF_Clock_System(float targetSeconds) { return(MarkerEdge.isEdge(SS_TriggerMarker.Clock_System(StartTime_System, targetSeconds))); }