protected void ProcessHardwareStatusUpdate(string message, int value) { lock (_statusLock) { StatusElement element = _statusElements.Find(message); if (element != null) { element.Value = value; if (element.Type.Contains(TagTypes.Status)) { SendStatusUpdate(); } if (element.Type.Contains(TagTypes.Information)) { try { DataAccessReference.UpdateWidgets(message, value); } catch { } } if (element.Type.Contains(TagTypes.Control)) { try { DataAccessReference.UpdateWidgets(message, value); } catch { } } } } }
protected void ReadTagConfig() { string group = ConfigurationManager.AppSettings["TagGroup"]; foreach (OpcTagElement tag in DataAccessReference.OpcSection.Server.TagGroup.GetElement(group).Tags) { Dictionary <int, string> map = new Dictionary <int, string>(); try { foreach (OpcTagElement.OpcTagValueElement element in tag.TagValues) { map.Add(element.Value, element.Type); } int value = DataAccessReference.GetTagValue(tag.Name); StatusElement status = new StatusElement(tag.Name, value, tag.Type, map); lock (_statusLock) _statusElements.Add(status); } catch { StatusElement status = new StatusElement(tag.Name, 0, tag.Type, map); lock (_statusLock) _statusElements.Add(status); } } }
protected void SendStatusUpdate() { try { string color = IndicatorColors.Clear; List <string> errorMessages = new List <string>(); List <string> warningMessages = new List <string>(); lock (_statusLock) foreach (StatusElement element in _statusElements) { try { if (element.Type.Contains(TagTypes.Status)) { if (String.Compare(element.StatusType, TagValueTypes.Error, true) == 0) { errorMessages.Add(element.Message); if (string.Compare(color, IndicatorColors.Unknown, true) != 0) { color = IndicatorColors.Error; } } else if (String.Compare(element.StatusType, TagValueTypes.Warning, true) == 0) { warningMessages.Add(element.Message); if (string.Compare(color, IndicatorColors.Clear, true) == 0) { color = IndicatorColors.Warning; } } else if (String.Compare(element.StatusType, TagValueTypes.Unknown, true) == 0) { color = IndicatorColors.Unknown; errorMessages.Clear(); warningMessages.Clear(); break; } } } catch (Exception ex) { Logger.LogError(ex); } } DataAccessReference.UpdateStatusErrorMessages(errorMessages.ToArray()); DataAccessReference.UpdateStatusWarningMessages(warningMessages.ToArray()); DataAccessReference.UpdateStatusIndicator(color); } catch (Exception ex) { Logger.LogError(ex); } }
protected void SendDisplayUpdate() { SendStatusUpdate(); lock (_statusLock) foreach (StatusElement element in _statusElements) { if (element.Type.Contains(TagTypes.Information)) { try { DataAccessReference.UpdateWidgets(element.Name, element.Value); } catch { } } if (element.Type.Contains(TagTypes.Control)) { try { DataAccessReference.UpdateWidgets(element.Name, element.Value); } catch { } } } }
protected virtual void ProcessControlUpdateRequest(string name, int value) { try { DataAccessReference.UpdatePLCTagValue(name, value); } catch (Exception ex) { Logger.LogError(ex); } }