public void updateAlertToOPCLabel(PacketData data, Dictionary <string, Dictionary <string, uint> > handles) { if (handles.ContainsKey(data.moduleID)) { Dictionary <string, uint> moduleHandle = handles[data.moduleID]; int pos = data.alertPos; int value = data.alertValue; if (moduleHandle.ContainsKey(data.resolvePos(pos))) { deactive(); OPClib.UpdateTag(moduleHandle[data.resolvePos(pos)], data.transformValue(value, pos), 192); } } }
private void TimeoutCheckingThreadWork(object obj) { int timeout = (int)obj; while (true) { Thread.Sleep(1000); DateTime now = DateTime.Now; Dictionary <string, DateTime> oneTimeUpdate = new Dictionary <string, DateTime>(); foreach (KeyValuePair <string, DateTime> updatedItem in lastUpdate) { oneTimeUpdate.Add(updatedItem.Key, updatedItem.Value); } foreach (KeyValuePair <string, DateTime> updatedItem in oneTimeUpdate) { DateTime dt = updatedItem.Value; TimeSpan span = now - dt; string moduleID = updatedItem.Key; if ((span.Minutes > timeout) || (span.Minutes == timeout && span.Seconds > 0)) { if (handles.ContainsKey(moduleID)) { Dictionary <string, uint> handle = handles[moduleID]; foreach (KeyValuePair <string, uint> singleLabel in handle) { string labelName = singleLabel.Key; uint labelHandle = singleLabel.Value; if (lastUpdateData.ContainsKey(moduleID) && lastUpdateData[moduleID].packetDataMap.ContainsKey(labelName)) { OPClib.UpdateTag(labelHandle, lastUpdateData[moduleID].packetDataMap[labelName], 0x18); //LogUtil.writeLog(LogUtil.getFileName(), "[" + DateTime.Now.ToString() + "]: 信号差"); } } lastUpdate.Remove(moduleID); lastUpdateData.Remove(moduleID); } } } } }
public void updateToOPCLabel(PacketData data, Dictionary <string, Dictionary <string, uint> > handles) { if (handles.ContainsKey(data.moduleID)) { Dictionary <string, uint> moduleHandle = handles[data.moduleID]; foreach (KeyValuePair <string, uint> handle in moduleHandle) { if (data.packetDataMap.ContainsKey(handle.Key)) { //System.Runtime.InteropServices.FILETIME f = new System.Runtime.InteropServices.FILETIME(); deactive(); if (!handle.Key.StartsWith("DO")) { OPClib.UpdateTag(handle.Value, data.packetDataMap[handle.Key], 192);//, System.Runtime.InteropServices.FILETIME); } // LogUtil.writeLog(LogUtil.getFileName(), "[" + DateTime.Now.ToString() + "]: OPC标签更新"); } } } }