private void ToolStripMenuItem_Commands_Click(object sender, EventArgs e) { ToolStripMenuItem menuitem = (ToolStripMenuItem)sender; List <cCommandReturnValue> CRVs = new List <nsRSMPGS.cCommandReturnValue>(); cRoadSideObject RoadSideObject = ((cCommandReturnValue)listView_Commands.SelectedItems[0].Tag).CommandObject.RoadSideObject; foreach (ListViewItem lvItem in listView_Commands.SelectedItems) { cCommandReturnValue CommandReturnValue = (cCommandReturnValue)lvItem.Tag; if (RoadSideObject != CommandReturnValue.CommandObject.RoadSideObject) { break; } CRVs.Add(CommandReturnValue); } RSMPGS2_CommandForm CommandForm = new RSMPGS2_CommandForm(RoadSideObject, CRVs); CommandForm.ShowDialog(this); /* * List<cCommandReturnValue> selectedCommands = CommandForm.GetSelectedCommands(); * if (selectedCommands != null && selectedCommands.Count > 0) * { * RSMPGS.JSon.CreateAndSendCommandMessage(CommandObject.getRoadSideObject(), selectedCommands); * } */ }
public void UpdateCommandListView(cRoadSideObject RoadSideObject) { if (RoadSideObject == null) { return; } RoadSideObject.CommandsGroup.Items.Clear(); foreach (cCommandObject CommandObject in RoadSideObject.CommandObjects) { // Object type;Object (optional);Description;commandCodeId;name;command;type;value;Comment;name;command;type;value;Comment; foreach (cCommandReturnValue CommandReturnValue in CommandObject.CommandReturnValues) { ListViewItem lvItem = new ListViewItem(CommandObject.sCommandCodeId); lvItem.SubItems.Add(CommandObject.sDescription); lvItem.SubItems.Add(CommandReturnValue.sName); lvItem.SubItems.Add(CommandReturnValue.sCommand.Replace("\"-", "").Replace("\n-", " / ").Replace("\n", " / ").Replace("\"", "")); lvItem.SubItems.Add(CommandReturnValue.Value.GetValueType()); #if _RSMPGS2 lvItem.SubItems.Add(CommandReturnValue.sLastRecValue); lvItem.SubItems.Add(CommandReturnValue.sLastRecAge); #endif #if _RSMPGS1 lvItem.SubItems.Add(CommandReturnValue.Value.GetValue()); lvItem.SubItems.Add(""); #endif lvItem.SubItems.Add(CommandReturnValue.sComment.Replace("\n", " / ")); lvItem.Tag = CommandReturnValue; listView_Commands.Items.Add(lvItem); lvItem.Group = RoadSideObject.CommandsGroup; } } }
public void UpdateAlarmListView(cSiteIdObject SiteIdObject, cRoadSideObject RoadSideObject) { listView_Alarms.Items.Clear(); listView_AlarmEvents.Items.Clear(); if (SiteIdObject == null && RoadSideObject == null) { return; } listView_Alarms.BeginUpdate(); listView_Alarms.StopSorting(); listView_AlarmEvents.StopSorting(); if (RoadSideObject != null) { listView_Alarms.ShowGroups = ToolStripMenuItem_View_AlwaysShowGroupHeaders.Checked; UpdateAlarmListView(RoadSideObject); } else { listView_Alarms.ShowGroups = true; foreach (cRoadSideObject roadSideObject in SiteIdObject.RoadSideObjects) { UpdateAlarmListView(roadSideObject); } } listView_Alarms.ResumeSorting(); listView_Alarms.EndUpdate(); listView_AlarmEvents.ResumeSorting(); }
public void UpdateAlarmListView(cRoadSideObject RoadSideObject) { RoadSideObject.AlarmsGroup.Items.Clear(); // // View alarm objects for the selected RoadSide object // foreach (cAlarmObject AlarmObject in RoadSideObject.AlarmObjects) { ListViewItem lvItem = new ListViewItem(); for (int iSubItemIndex = 0; iSubItemIndex < 7 + RSMPGS.ProcessImage.MaxAlarmReturnValues * 4; iSubItemIndex++) { lvItem.SubItems.Add(""); } lvItem.Tag = AlarmObject; UpdateAlarmListView(lvItem); listView_Alarms.Items.Add(lvItem); lvItem.Group = RoadSideObject.AlarmsGroup; foreach (cAlarmEvent AlarmEvent in AlarmObject.AlarmEvents) { AddAlarmEventToList(AlarmObject, AlarmEvent); } } }
private void listView_AggregatedStatus_StatusBits_DoubleClick(object sender, EventArgs e) { if (treeView_SitesAndObjects.SelectedNode == null) { return; } if (treeView_SitesAndObjects.SelectedNode.Parent == null || bIsCurrentlyChangingSelection == true) { return; } cRoadSideObject RoadSideObject = (cRoadSideObject)treeView_SitesAndObjects.SelectedNode.Tag; ListViewItem lvItem = listView_AggregatedStatus_StatusBits.SelectedItems[0]; RoadSideObject.bBitStatus[lvItem.Index] = !RoadSideObject.bBitStatus[lvItem.Index]; SetStatusBitColor(lvItem, RoadSideObject.bBitStatus[lvItem.Index]); RoadSideObject.dtLastChangedAggregatedStatus = DateTime.Now; if (checkBox_AggregatedStatus_SendAutomaticallyWhenChanged.Checked) { RSMPGS.JSon.CreateAndSendAggregatedStatusMessage(RoadSideObject); } lvItem.Selected = false; }
public void CloneFromAlarmObject(cAlarmObject AlarmObjectToCopy) { RoadSideObject = AlarmObjectToCopy.RoadSideObject; bActive = AlarmObjectToCopy.bActive; bSuspended = AlarmObjectToCopy.bSuspended; bAcknowledged = AlarmObjectToCopy.bAcknowledged; sObjectType = AlarmObjectToCopy.sObjectType; sSpecificObject = AlarmObjectToCopy.sSpecificObject; sAlarmCodeId = AlarmObjectToCopy.sAlarmCodeId; sDescription = AlarmObjectToCopy.sDescription; sExternalAlarmCodeId = AlarmObjectToCopy.sExternalAlarmCodeId; sExternalNTSAlarmCodeId = AlarmObjectToCopy.sExternalNTSAlarmCodeId; sPriority = AlarmObjectToCopy.sPriority; sCategory = AlarmObjectToCopy.sCategory; AlarmReturnValues.Clear(); foreach (cAlarmReturnValue AlarmReturnValue in AlarmObjectToCopy.AlarmReturnValues) { cAlarmReturnValue NewAlarmReturnValue = new cAlarmReturnValue(); NewAlarmReturnValue.sName = AlarmReturnValue.sName; NewAlarmReturnValue.sComment = AlarmReturnValue.sComment; NewAlarmReturnValue.Value = new cValue(AlarmReturnValue.Value.ValueTypeObject, true); AlarmReturnValues.Add(NewAlarmReturnValue); } // We don't copy alarm events }
public void CloneFromCommandObject(cCommandObject CommandObjectToCopy) { RoadSideObject = CommandObjectToCopy.RoadSideObject; sObjectType = CommandObjectToCopy.sObjectType; sSpecificObject = CommandObjectToCopy.sSpecificObject; sCommandCodeId = CommandObjectToCopy.sCommandCodeId; sDescription = CommandObjectToCopy.sDescription; CommandReturnValues.Clear(); foreach (cCommandReturnValue CommandReturnValue in CommandObjectToCopy.CommandReturnValues) { cCommandReturnValue NewCommandReturnValue = new cCommandReturnValue(this); NewCommandReturnValue.CommandObject = CommandReturnValue.CommandObject; NewCommandReturnValue.sName = CommandReturnValue.sName; NewCommandReturnValue.sCommand = CommandReturnValue.sCommand; NewCommandReturnValue.sComment = CommandReturnValue.sComment; NewCommandReturnValue.Value = new cValue(CommandReturnValue.Value.ValueTypeObject, true); #if _RSMPGS2 NewCommandReturnValue.sAge = CommandReturnValue.sAge; NewCommandReturnValue.sLastRecValue = CommandReturnValue.sLastRecValue; NewCommandReturnValue.sLastRecAge = CommandReturnValue.sLastRecAge; NewCommandReturnValue.CommandObject = this; #endif CommandReturnValues.Add(NewCommandReturnValue); } }
public void CreateAndSendAggregatedStatusRequestMessage(cRoadSideObject RoadSideObject) { RSMP_Messages.AggregatedStatusRequest AggregatedStatusRequest; string sSendBuffer; try { AggregatedStatusRequest = new RSMP_Messages.AggregatedStatusRequest(); AggregatedStatusRequest.mType = "rSMsg"; AggregatedStatusRequest.type = "AggregatedStatusRequest"; AggregatedStatusRequest.mId = System.Guid.NewGuid().ToString(); AggregatedStatusRequest.ntsOId = RoadSideObject.sNTSObjectId; AggregatedStatusRequest.xNId = RoadSideObject.sExternalNTSId; AggregatedStatusRequest.cId = RoadSideObject.sComponentId; sSendBuffer = JSonSerializer.SerializeObject(AggregatedStatusRequest); RSMPGS.JSon.SendJSonPacket(AggregatedStatusRequest.type, AggregatedStatusRequest.mId, sSendBuffer, true); if (RSMPGS.MainForm.checkBox_ViewOnlyFailedPackets.Checked == false) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Info, "Sent AggregatedStatusRequest message, ntsOId: " + RoadSideObject.sNTSObjectId + ", cId: " + RoadSideObject.sComponentId + ", MsgId: " + AggregatedStatusRequest.mId); } } catch (Exception e) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Error, "Failed to create AggregatedStatusRequest message: {0}", e.Message); } }
public void CloneFromStatusObject(cStatusObject StatusObjectToCopy) { RoadSideObject = StatusObjectToCopy.RoadSideObject; sObjectType = StatusObjectToCopy.sObjectType; sSpecificObject = StatusObjectToCopy.sSpecificObject; sDescription = StatusObjectToCopy.sDescription; sStatusCodeId = StatusObjectToCopy.sStatusCodeId; StatusReturnValues.Clear(); foreach (cStatusReturnValue StatusReturnValue in StatusObjectToCopy.StatusReturnValues) { cStatusReturnValue NewStatusReturnValue = new cStatusReturnValue(this); NewStatusReturnValue.StatusObject = StatusReturnValue.StatusObject; NewStatusReturnValue.sName = StatusReturnValue.sName; NewStatusReturnValue.sComment = StatusReturnValue.sComment; NewStatusReturnValue.Value = new cValue(StatusReturnValue.Value.ValueTypeObject, true); #if _RSMPGS2 NewStatusReturnValue.sLastUpdateRate = StatusReturnValue.sLastUpdateRate; NewStatusReturnValue.bLastUpdateOnChange = StatusReturnValue.bLastUpdateOnChange; NewStatusReturnValue.sQuality = StatusReturnValue.sQuality; #endif StatusReturnValues.Add(NewStatusReturnValue); } }
public RSMP_Messages.AggregatedStatus CreateAndSendAggregatedStatusMessage(cRoadSideObject RoadSideObject, bool bCreateMessageOnly, out string sSendBuffer) { sSendBuffer = ""; RSMP_Messages.AggregatedStatus AggregatedStatusMessage = new RSMP_Messages.AggregatedStatus(); AggregatedStatusMessage.mType = "rSMsg"; AggregatedStatusMessage.type = "AggregatedStatus"; AggregatedStatusMessage.mId = System.Guid.NewGuid().ToString(); AggregatedStatusMessage.ntsOId = RoadSideObject.sNTSObjectId; AggregatedStatusMessage.xNId = RoadSideObject.sExternalNTSId; AggregatedStatusMessage.cId = RoadSideObject.sComponentId; if (RoadSideObject.dtLastChangedAggregatedStatus == DateTime.MinValue) { RoadSideObject.dtLastChangedAggregatedStatus = DateTime.Now; } AggregatedStatusMessage.aSTS = CreateISO8601UTCTimeStamp(RoadSideObject.dtLastChangedAggregatedStatus); AggregatedStatusMessage.fP = RoadSideObject.sFunctionalPosition.Length > 0 ? RoadSideObject.sFunctionalPosition : null; AggregatedStatusMessage.fS = RoadSideObject.sFunctionalState.Length > 0 ? RoadSideObject.sFunctionalState : null; AggregatedStatusMessage.se = (bool[])RoadSideObject.bBitStatus.Clone(); for (int iIndex = 0; iIndex < RoadSideObject.bBitStatus.GetLength(0); iIndex++) { AggregatedStatusMessage.se[iIndex] = RoadSideObject.bBitStatus[iIndex]; } sSendBuffer = JSonSerializer.SerializeObject(AggregatedStatusMessage); if (bCreateMessageOnly) { return(AggregatedStatusMessage); } if (RSMPGS.JSon.SendJSonPacket(AggregatedStatusMessage.type, AggregatedStatusMessage.mId, sSendBuffer, true)) { if (RSMPGS.MainForm.checkBox_ViewOnlyFailedPackets.Checked == false) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Info, "Sent aggregated status message, ntsOId: " + AggregatedStatusMessage.ntsOId + ", Type: " + AggregatedStatusMessage.type + ", MsgId: " + AggregatedStatusMessage.mId); } } else { if (cHelper.IsSettingChecked("BufferAndSendAggregatedStatusWhenConnect")) { cBufferedMessage BufferedMessage = new cBufferedMessage(cBufferedMessage.eMessageType.AggregatedStatus, AggregatedStatusMessage.type, AggregatedStatusMessage.mId, sSendBuffer); RSMPGS.MainForm.AddBufferedMessageToListAndListView(BufferedMessage); RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Warning, "Buffered aggregated status message, ntsOId: " + AggregatedStatusMessage.ntsOId + ", Type: " + AggregatedStatusMessage.type + ", MsgId: " + AggregatedStatusMessage.mId); } } return(AggregatedStatusMessage); }
public void HandleAggregatedStatusListUpdate(cRoadSideObject RoadSideObject, cAggregatedStatusEvent AggregatedStatusEvent) { if (SelectedRoadSideObject == RoadSideObject) { for (int iIndex = 0; iIndex < RoadSideObject.bBitStatus.GetLength(0); iIndex++) { SetStatusBitColor(listView_AggregatedStatus_StatusBits.Items[iIndex], RoadSideObject.bBitStatus[iIndex]); } } AddAggregatedStatusEventToList(RoadSideObject, AggregatedStatusEvent); }
public void CreateAndSendSubscriptionMessage(cRoadSideObject RoadSideObject, List <RSMP_Messages.StatusSubscribe_Status_Over_3_1_4> StatusSubscribeValues) { if (NegotiatedRSMPVersion > RSMPVersion.RSMP_3_1_4) { CreateAndSendSubscriptionMessage_over_3_1_4(RoadSideObject, StatusSubscribeValues); } else { CreateAndSendSubscriptionMessage_upto_3_1_4(RoadSideObject, StatusSubscribeValues); } }
public void HandleCommandListUpdate(cRoadSideObject RoadSideObject, cCommandObject CommandObject, cCommandReturnValue CommandReturnValue) { foreach (ListViewItem lvItem in listView_Commands.Items) { if ((cCommandReturnValue)lvItem.Tag == CommandReturnValue) { lvItem.SubItems[5].Text = CommandReturnValue.Value.GetValue(); lvItem.SubItems[6].Text = CommandReturnValue.Value.Quality.ToString(); break; } } }
public void UpdateStatusListView(cRoadSideObject RoadSideObject) { RoadSideObject.StatusGroup.Items.Clear(); foreach (cStatusObject StatusObject in RoadSideObject.StatusObjects) { // Object type;Object (optional);Description;commandCodeId;name;command;type;value;Comment;name;command;type;value;Comment; foreach (cStatusReturnValue StatusReturnValue in StatusObject.StatusReturnValues) { string sKey = StatusObject.sStatusCodeId.ToUpper() + "/" + StatusReturnValue.sName.ToUpper(); ListViewItem lvItem = new ListViewItem(StatusObject.sStatusCodeId, -1); lvItem.Name = sKey; string[] sValues = new string[8]; //ListViewItem lvItem = listView_Status.Items.Add(sKey, StatusObject.sDescription, -1); sValues[0] = StatusObject.sDescription; sValues[1] = StatusReturnValue.sName; sValues[2] = StatusReturnValue.Value.GetValueType(); sValues[3] = StatusReturnValue.Value.GetValue(); sValues[4] = StatusReturnValue.sQuality; sValues[5] = StatusReturnValue.sLastUpdateRate; sValues[6] = StatusReturnValue.bLastUpdateOnChange.ToString(); sValues[7] = StatusReturnValue.sComment.Replace("\n", " / "); /* * * lvItem.SubItems.Add(StatusObject.sDescription); * lvItem.SubItems.Add(StatusReturnValue.sName); * lvItem.SubItems.Add(StatusReturnValue.sType); * lvItem.SubItems.Add(StatusReturnValue.sStatus); * lvItem.SubItems.Add(StatusReturnValue.sQuality); * lvItem.SubItems.Add(StatusReturnValue.sLastUpdateRate); * lvItem.SubItems.Add(StatusReturnValue.bLastUpdateOnChange.ToString()); * lvItem.SubItems.Add(StatusReturnValue.sComment); */ lvItem.SubItems.AddRange(sValues); listView_Status.Items.Add(lvItem); lvItem.Tag = StatusReturnValue; lvItem.Group = RoadSideObject.StatusGroup; } } foreach (cStatusEvent StatusEvent in RoadSideObject.StatusEvents) { AddStatusEventToList(RoadSideObject, StatusEvent); } }
private bool DecodeAndParseAggregatedStatusMessage(RSMP_Messages.Header packetHeader, string sJSon, bool bUseStrictProtocolAnalysis, bool bUseCaseSensitiveIds, ref bool bHasSentAckOrNack, ref string sError) { StringComparison sc = bUseCaseSensitiveIds ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; bool bSuccess = false; try { RSMP_Messages.AggregatedStatus AggregatedStatus = JSonSerializer.Deserialize <RSMP_Messages.AggregatedStatus>(sJSon); cRoadSideObject RoadSideObject = cHelper.FindRoadSideObject(AggregatedStatus.ntsOId, AggregatedStatus.cId, bUseCaseSensitiveIds); if (RoadSideObject != null) { RoadSideObject.bBitStatus = AggregatedStatus.se; RoadSideObject.sFunctionalPosition = AggregatedStatus.fP; RoadSideObject.sFunctionalState = AggregatedStatus.fS; cAggregatedStatusEvent AggregatedStatusEvent = new cAggregatedStatusEvent(); AggregatedStatusEvent.sTimeStamp = UnpackISO8601UTCTimeStamp(AggregatedStatus.aSTS); AggregatedStatusEvent.sMessageId = AggregatedStatus.mId; AggregatedStatusEvent.sFunctionalPosition = AggregatedStatus.fP; AggregatedStatusEvent.sFunctionalState = AggregatedStatus.fS; for (int i = 1; i < AggregatedStatus.se.Length + 1; i++) { AggregatedStatusEvent.sBitStatus += "B" + i + ": " + AggregatedStatus.se[i - 1] + " | "; } AggregatedStatusEvent.sBitStatus.Trim(); if (RSMPGS_Main.bWriteEventsContinous) { RSMPGS.SysLog.EventLog("AggregatedStatus;{0}\tMId: {1}\tComponentId: {2}\tBitStatus: {3}\tFuncPos: {4}\tFunkState: {5}", AggregatedStatusEvent.sTimeStamp, AggregatedStatusEvent.sMessageId, AggregatedStatus.cId, AggregatedStatusEvent.sBitStatus, AggregatedStatusEvent.sFunctionalPosition, AggregatedStatusEvent.sFunctionalState); } RoadSideObject.AggregatedStatusEvents.Add(AggregatedStatusEvent); RSMPGS.MainForm.HandleAggregatedStatusListUpdate(RoadSideObject, AggregatedStatusEvent); bSuccess = true; } if (bSuccess == false) { sError = "Failed to update AggregatedStatus, could not find object, ntsOId: '" + AggregatedStatus.ntsOId + "', cId: '" + AggregatedStatus.cId + "'"; } } catch (Exception e) { sError = "Failed to deserialize packet: " + e.Message; bSuccess = false; } return(bSuccess); }
private void AddCommandEventToList(cRoadSideObject RoadSideObject, cCommandEvent CommandEvent) { ListViewItem lvItem = listView_CommandEvents.Items.Add(CommandEvent.sTimeStamp.ToString()); lvItem.SubItems.Add(CommandEvent.sMessageId); lvItem.SubItems.Add(CommandEvent.sEvent); lvItem.SubItems.Add(CommandEvent.sCommandCodeId); lvItem.SubItems.Add(CommandEvent.sName); lvItem.SubItems.Add(CommandEvent.sCommand); lvItem.SubItems.Add(CommandEvent.sValue); lvItem.SubItems.Add(CommandEvent.sAge); }
public void CreateAndSendSubscriptionMessage_upto_3_1_4(cRoadSideObject RoadSideObject, List <RSMP_Messages.StatusSubscribe_Status_Over_3_1_4> StatusSubscribeValues) { RSMP_Messages.StatusSubscribe_UpTo_3_1_4 StatusSubscribe; string sSendBuffer; try { StatusSubscribe = new RSMP_Messages.StatusSubscribe_UpTo_3_1_4(); StatusSubscribe.mType = "rSMsg"; StatusSubscribe.type = "StatusSubscribe"; StatusSubscribe.mId = System.Guid.NewGuid().ToString(); StatusSubscribe.ntsOId = RoadSideObject.sNTSObjectId; StatusSubscribe.xNId = RoadSideObject.sExternalNTSId; StatusSubscribe.cId = RoadSideObject.sComponentId; StatusSubscribe.sS = new List <RSMP_Messages.StatusSubscribe_Status_UpTo_3_1_4>(); foreach (RSMP_Messages.StatusSubscribe_Status_Over_3_1_4 StatusSubscriptionValue in StatusSubscribeValues) { RSMP_Messages.StatusSubscribe_Status_UpTo_3_1_4 StatusSubscribeValue = new RSMP_Messages.StatusSubscribe_Status_UpTo_3_1_4(); StatusSubscribeValue.n = StatusSubscriptionValue.n; StatusSubscribeValue.sCI = StatusSubscriptionValue.sCI; StatusSubscribeValue.uRt = StatusSubscriptionValue.uRt; StatusSubscribe.sS.Add(StatusSubscribeValue); AddSubscriptionMessageEvent(RoadSideObject, StatusSubscribe.mId, StatusSubscribe.cId, StatusSubscriptionValue); } sSendBuffer = JSonSerializer.SerializeObject(StatusSubscribe); if (RSMPGS.JSon.SendJSonPacket(StatusSubscribe.type, StatusSubscribe.mId, sSendBuffer, true)) { if (RSMPGS.MainForm.checkBox_ViewOnlyFailedPackets.Checked == false) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Info, "Sent subscription message, ComponentId: " + StatusSubscribe.cId + " , MsgId: " + StatusSubscribe.mId); } } else { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Error, "Failed to send subscription message, ComponentId: " + StatusSubscribe.cId + " , MsgId: " + StatusSubscribe.mId); } } catch (Exception e) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Error, "Failed to create subscription message: {0}", e.Message); } }
public void HandleCommandListUpdate(cRoadSideObject RoadSideObject, string sntsOId, string scId, cCommandEvent CommandEvent, bool bSend, bool bUseCaseSensitiveIds) { if (SelectedRoadSideObject == null) { cRoadSideObject ScanRoadSideObject = cHelper.FindRoadSideObject(sntsOId, scId, bUseCaseSensitiveIds); if (ScanRoadSideObject != null) { if (!bSend) { for (int i = 0; i < listView_Commands.Items.Count; i++) { ListViewItem lvItem = listView_Commands.Items[i]; if (lvItem.SubItems[3].Text.Equals(CommandEvent.sCommandCodeId, StringComparison.OrdinalIgnoreCase) && lvItem.SubItems[4].Text.Equals(CommandEvent.sName, StringComparison.OrdinalIgnoreCase)) { lvItem.SubItems[7].Text = CommandEvent.sValue; lvItem.SubItems[8].Text = CommandEvent.sAge; break; } } } AddCommandEventToList(RoadSideObject, CommandEvent); } } else { if (SelectedRoadSideObject == RoadSideObject) { if (!bSend) { for (int i = 0; i < listView_Commands.Items.Count; i++) { ListViewItem lvItem = listView_Commands.Items[i]; if (lvItem.SubItems[0].Text.Equals(CommandEvent.sCommandCodeId, StringComparison.OrdinalIgnoreCase) && lvItem.SubItems[2].Text.Equals(CommandEvent.sName, StringComparison.OrdinalIgnoreCase)) { lvItem.SubItems[5].Text = CommandEvent.sValue; lvItem.SubItems[6].Text = CommandEvent.sAge; break; } } } AddCommandEventToList(RoadSideObject, CommandEvent); } } }
private void AddAggregatedStatusEventToList(cRoadSideObject RoadSideObject, cAggregatedStatusEvent AggregatedStatusEvent) { if (bIsUpdatingAggregatedStatusEventList == false) { listView_AggregatedStatusEvents.StopSorting(); listView_AggregatedStatusEvents.BeginUpdate(); bIsUpdatingAggregatedStatusEventList = true; } ListViewItem lvItem = listView_AggregatedStatusEvents.Items.Add(AggregatedStatusEvent.sTimeStamp.ToString()); lvItem.SubItems.Add(AggregatedStatusEvent.sMessageId); lvItem.SubItems.Add(AggregatedStatusEvent.sBitStatus); lvItem.SubItems.Add(AggregatedStatusEvent.sFunctionalPosition); lvItem.SubItems.Add(AggregatedStatusEvent.sFunctionalState); }
private void listBox_AggregatedStatus_FunctionalPosition_SelectedIndexChanged(object sender, EventArgs e) { if (treeView_SitesAndObjects.SelectedNode.Parent == null || bIsCurrentlyChangingSelection == true || listBox_AggregatedStatus_FunctionalPosition.SelectedItem == null) { return; } cRoadSideObject RoadSideObject = (cRoadSideObject)treeView_SitesAndObjects.SelectedNode.Tag; RoadSideObject.sFunctionalPosition = listBox_AggregatedStatus_FunctionalPosition.SelectedItem.ToString(); RoadSideObject.dtLastChangedAggregatedStatus = DateTime.Now; if (checkBox_AggregatedStatus_SendAutomaticallyWhenChanged.Checked) { RSMPGS.JSon.CreateAndSendAggregatedStatusMessage(RoadSideObject); } }
private void listBox_AggregatedStatus_FunctionalState_SelectedIndexChanged(object sender, EventArgs e) { if (treeView_SitesAndObjects.SelectedNode.Parent == null || bIsCurrentlyChangingSelection == true || listBox_AggregatedStatus_FunctionalState.SelectedItem == null) // || listView_AggregatedStatus_StatusBits.SelectedItems.Count == 0 - removed 2014-09-11/TR to enable lvItem.Selected = false above { return; } cRoadSideObject RoadSideObject = (cRoadSideObject)treeView_SitesAndObjects.SelectedNode.Tag; RoadSideObject.sFunctionalState = listBox_AggregatedStatus_FunctionalState.SelectedItem.ToString(); RoadSideObject.dtLastChangedAggregatedStatus = DateTime.Now; if (checkBox_AggregatedStatus_SendAutomaticallyWhenChanged.Checked) { RSMPGS.JSon.CreateAndSendAggregatedStatusMessage(RoadSideObject); } }
public RSMP_Messages.StatusUpdate CreateAndSendStatusUpdateMessage(cRoadSideObject RoadSideObject, List <RSMP_Messages.Status_VTQ> sS, bool bCreateMessageOnly, out string sSendBuffer) { sSendBuffer = ""; RSMP_Messages.StatusUpdate StatusUpdateMessage = new RSMP_Messages.StatusUpdate(); StatusUpdateMessage.mType = "rSMsg"; StatusUpdateMessage.type = "StatusUpdate"; StatusUpdateMessage.mId = System.Guid.NewGuid().ToString(); StatusUpdateMessage.ntsOId = RoadSideObject.sNTSObjectId; StatusUpdateMessage.xNId = RoadSideObject.sExternalNTSId; StatusUpdateMessage.cId = RoadSideObject.sComponentId; StatusUpdateMessage.sTs = CreateISO8601UTCTimeStamp(); StatusUpdateMessage.sS = sS; sSendBuffer = JSonSerializer.SerializeObject(StatusUpdateMessage); if (bCreateMessageOnly) { return(StatusUpdateMessage); } if (RSMPGS.JSon.SendJSonPacket(StatusUpdateMessage.type, StatusUpdateMessage.mId, sSendBuffer, true)) { if (RSMPGS.MainForm.checkBox_ViewOnlyFailedPackets.Checked == false) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Info, "Sent Status Update message, Type: " + StatusUpdateMessage.type + ", MsgId: " + StatusUpdateMessage.mId); } } else { if (cHelper.IsSettingChecked("BufferAndSendStatusUpdatesWhenConnect")) { cBufferedMessage BufferedMessage = new cBufferedMessage(cBufferedMessage.eMessageType.Status, StatusUpdateMessage.type, StatusUpdateMessage.mId, sSendBuffer); RSMPGS.MainForm.AddBufferedMessageToListAndListView(BufferedMessage); RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Warning, "Buffered Status Update message, Type: " + StatusUpdateMessage.type + ", MsgId: " + StatusUpdateMessage.mId); } } return(StatusUpdateMessage); }
public void UpdateStatusListView(cRoadSideObject RoadSideObject) { RoadSideObject.StatusGroup.Items.Clear(); foreach (cStatusObject StatusObject in RoadSideObject.StatusObjects) { foreach (cStatusReturnValue StatusReturnValue in StatusObject.StatusReturnValues) { string sKey = StatusObject.sStatusCodeId.ToUpper() + "/" + StatusReturnValue.sName.ToUpper(); ListViewItem lvItem = new ListViewItem(StatusObject.sStatusCodeId, -1); lvItem.Name = sKey; string[] sValues = new string[5]; sValues[0] = StatusObject.sDescription; sValues[1] = StatusReturnValue.sName; sValues[2] = StatusReturnValue.Value.GetValueType(); sValues[3] = StatusReturnValue.Value.GetValue(); sValues[4] = StatusReturnValue.sComment.Replace("\n", " / "); lvItem.SubItems.AddRange(sValues); //ListViewItem lvItem = listView_Status.Items.Add(sKey, StatusObject.sDescription, -1); /* * lvItem.SubItems.Add(StatusObject.sDescription); * lvItem.SubItems.Add(StatusReturnValue.sName); * lvItem.SubItems.Add(StatusReturnValue.sType); * lvItem.SubItems.Add(StatusReturnValue.sStatus); * lvItem.SubItems.Add(StatusReturnValue.sComment); */ lvItem.Tag = StatusReturnValue; listView_Status.Items.Add(lvItem); lvItem.Group = RoadSideObject.StatusGroup; } } // lvItem.SubItems.Add(StatusObject.sDescription.Replace("\"-", "").Replace("\n-", "/").Replace("\n", "/").Replace("\"", "")); }
public void HandleStatusListUpdate(cRoadSideObject RoadSideObject, cStatusEvent StatusEvent, bool bSend) { string sKey = StatusEvent.sStatusCommandId.ToUpper() + "/" + StatusEvent.sName.ToUpper(); if (RoadSideObject.StatusGroup.Items.ContainsKey(sKey)) { ListViewItem lvItem = RoadSideObject.StatusGroup.Items[sKey]; if (!bSend) { lvItem.SubItems[4].Text = StatusEvent.sStatus; lvItem.SubItems[5].Text = StatusEvent.sQuality; } else { lvItem.SubItems[6].Text = StatusEvent.sUpdateRate; lvItem.SubItems[7].Text = StatusEvent.bUpdateOnChange.ToString(); } } AddStatusEventToList(RoadSideObject, StatusEvent); }
private void AddStatusEventToList(cRoadSideObject RoadSideObject, cStatusEvent StatusEvent) { if (bIsUpdatingStatusEventList == false) { listView_StatusEvents.StopSorting(); listView_StatusEvents.BeginUpdate(); bIsUpdatingStatusEventList = true; } ListViewItem lvItem = new ListViewItem(StatusEvent.sTimeStamp.ToString()); lvItem.SubItems.Add(StatusEvent.sMessageId); lvItem.SubItems.Add(StatusEvent.sEvent); lvItem.SubItems.Add(StatusEvent.sStatusCommandId); lvItem.SubItems.Add(StatusEvent.sName); lvItem.SubItems.Add(StatusEvent.sStatus); lvItem.SubItems.Add(StatusEvent.sQuality); lvItem.SubItems.Add(StatusEvent.sUpdateRate); lvItem.SubItems.Add(StatusEvent.bUpdateOnChange.ToString()); listView_StatusEvents.Items.Add(lvItem); }
public RSMPGS2_StatusForm(cRoadSideObject RoadSideObject, bool bStatReq, bool bStatSub) { InitializeComponent(); this.RoadSideObject = RoadSideObject; this.bStatReq = bStatReq; this.bStatSub = bStatSub; groupBox_Status.Text = "Object: " + RoadSideObject.sComponentId; if (!bStatReq && bStatSub) { dataGridView_Status.ColumnCount = 4; dataGridView_Status.Columns[3].Name = "Column_UpdateRate"; dataGridView_Status.Columns[3].HeaderText = "UpdateRate"; dataGridView_Status.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; dataGridView_Status.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable; } int i = 0; foreach (cStatusObject StatusObject in RoadSideObject.StatusObjects) { foreach (cStatusReturnValue StatusArguments in StatusObject.StatusReturnValues) { if (!bStatReq && bStatSub && (StatusArguments.sLastUpdateRate != null) && (StatusArguments.sLastUpdateRate.Length > 0)) { this.dataGridView_Status.Rows.Add(false, StatusArguments.sStatusCommandId, StatusArguments.sName, StatusArguments.sLastUpdateRate); } else { this.dataGridView_Status.Rows.Add(false, StatusArguments.sStatusCommandId, StatusArguments.sName, ""); } if (!bStatReq && bStatSub) { this.dataGridView_Status.Rows[i].Cells[dataGridView_Status.ColumnCount - 1].ReadOnly = false; } i++; } } }
private bool DecodeAndParseAggregatedStatusRequestMessage(RSMP_Messages.Header packetHeader, string sJSon, bool bUseStrictProtocolAnalysis, bool bUseCaseSensitiveIds, ref bool bHasSentAckOrNack, ref string sError) { bool bPacketWasProperlyHandled = false; StringComparison sc = bUseCaseSensitiveIds ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; try { RSMP_Messages.AggregatedStatusRequest AggregatedStatusRequest = JSonSerializer.Deserialize <RSMP_Messages.AggregatedStatusRequest>(sJSon); cRoadSideObject RoadSideObject = cHelper.FindRoadSideObject(AggregatedStatusRequest.ntsOId, AggregatedStatusRequest.cId, bUseStrictProtocolAnalysis); if (RoadSideObject != null) { if (cHelper.IsSettingChecked("AllowRequestsOfAlarmsAndAggStatus")) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Info, "Request of aggregated status, ntsOId: {0}, cId: {1}", AggregatedStatusRequest.ntsOId, AggregatedStatusRequest.cId); bHasSentAckOrNack = SendPacketAck(true, packetHeader.mId, ""); CreateAndSendAggregatedStatusMessage(RoadSideObject); } else { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Warning, "Request of aggregated status, ntsOId: {0}, cId: {1}. RSMP settings prevent us from answering.", AggregatedStatusRequest.ntsOId, AggregatedStatusRequest.cId); bHasSentAckOrNack = SendPacketAck(false, packetHeader.mId, "Invalid packet type: " + packetHeader.type); } bPacketWasProperlyHandled = true; } else { sError = "Failed to handle AggregatedStatusRequest message, ntsOId: " + AggregatedStatusRequest.ntsOId + "/ cId: " + AggregatedStatusRequest.cId + " could not be found)"; RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Error, "{0}", sError); } } catch (Exception e) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Error, "Failed to deserialize packet: {0}", e.Message); } return(bPacketWasProperlyHandled); }
private void AddSubscriptionMessageEvent(cRoadSideObject RoadSideObject, string sMessageId, string sComponentId, RSMP_Messages.StatusSubscribe_Status_Over_3_1_4 StatusSubscribe_Status) { cStatusEvent StatusEvent = null; StatusEvent = new cStatusEvent(); StatusEvent.sTimeStamp = CreateLocalTimeStamp(); StatusEvent.sMessageId = sMessageId; StatusEvent.sEvent = "Sent subscription"; StatusEvent.sStatusCommandId = StatusSubscribe_Status.sCI; StatusEvent.sName = StatusSubscribe_Status.n; StatusEvent.sUpdateRate = StatusSubscribe_Status.uRt; StatusEvent.bUpdateOnChange = StatusSubscribe_Status.sOc; if (RSMPGS_Main.bWriteEventsContinous) { RSMPGS.SysLog.EventLog("Status;{0}\tMId: {1}\tComponentId: {2}\tStatusCommandId: {3}\tName: {4}\tStatus: {5}\tQuality: {6}\tUpdateRate: {7}\tEvent: {8}", StatusEvent.sTimeStamp, StatusEvent.sMessageId, sComponentId, StatusEvent.sStatusCommandId, StatusEvent.sName, StatusEvent.sStatus, StatusEvent.sQuality, StatusEvent.sUpdateRate, StatusEvent.sEvent); } RoadSideObject.StatusEvents.Add(StatusEvent); RSMPGS.MainForm.HandleStatusListUpdate(RoadSideObject, StatusEvent, true); }
public RSMPGS2_CommandForm(cRoadSideObject RoadSideObject, List <cCommandReturnValue> SelectedCRVs) { InitializeComponent(); this.RoadSideObject = RoadSideObject; groupBox_Commands.Text = "Object: " + RoadSideObject.sComponentId; int i = 0; foreach (cCommandObject CommandObject in RoadSideObject.CommandObjects) { foreach (cCommandReturnValue CommandArguments in CommandObject.CommandReturnValues) { bool bWasSelected = SelectedCRVs.IndexOf(CommandArguments) >= 0 ? true : false; string[] aCommands; if (CommandArguments.Value.ValueTypeObject.SelectableValues != null && CommandArguments.Value.ValueTypeObject.SelectableValues.Count > 0) { aCommands = CommandArguments.Value.ValueTypeObject.SelectableValues.Values.ToArray <string>(); } else { aCommands = CommandArguments.Value.ValueTypeObject.sRange.Split('\n'); for (int j = 0; j < aCommands.Length; j++) { aCommands[j] = aCommands[j].TrimStart('"'); aCommands[j] = aCommands[j].TrimStart('-'); aCommands[j] = aCommands[j].TrimEnd('"'); } } /* * string[] aCommands = CommandArguments.sValue.Split('\n'); * * for (int j = 0; j < aCommands.Length; j++) * { * aCommands[j] = aCommands[j].TrimStart('"'); * aCommands[j] = aCommands[j].TrimStart('-'); * aCommands[j] = aCommands[j].TrimEnd('"'); * } */ if ((CommandArguments.Value.ValueTypeObject.sRange == "" || aCommands.Length < 2)) { DataGridViewTextBoxCell txtcell = new DataGridViewTextBoxCell(); this.dataGridView_Commands.Rows.Add(bWasSelected, CommandObject.sCommandCodeId, CommandArguments.sName, CommandArguments.sCommand); this.dataGridView_Commands.Rows[i].Cells[4] = txtcell; if (CommandArguments.Value.GetValueType().Equals("base64", StringComparison.OrdinalIgnoreCase)) { iRows.Add(i); } this.dataGridView_Commands.Rows[i].Cells[4].Value = CommandArguments.Value.GetValue(); //this.dataGridView_Commands.Rows[i].Cells[4].ReadOnly = CommandArguments.sValue == "" || CommandArguments.sValue.EndsWith("]") ? false : true; } else { this.dataGridView_Commands.Rows.Add(bWasSelected, CommandObject.sCommandCodeId, CommandArguments.sName, CommandArguments.sCommand); DataGridViewComboBoxCell combocell = (DataGridViewComboBoxCell)dataGridView_Commands.Rows[i].Cells[4]; combocell.Items.AddRange(aCommands); this.dataGridView_Commands.Rows[i].Cells[4].Value = aCommands[0]; } i++; } } }
private void ToolStripMenuItem_Status_Click(object sender, EventArgs e) { cRoadSideObject RoadSideObject = null; bool bAlwaysUpdateOnChange = false; cJSon.StatusMsgType statusMsgType; ToolStripMenuItem menuitem = (ToolStripMenuItem)sender; string sUpdateRate = ""; if (menuitem.Equals(ToolStripMenuItem_StatusRequest)) { statusMsgType = cJSon.StatusMsgType.Request; } else if (menuitem.Equals(ToolStripMenuItem_StatusUnsubscribe)) { statusMsgType = cJSon.StatusMsgType.UnSubscribe; } else if (menuitem.Equals(ToolStripMenuItem_StatusSubscribe_UpdateOnChangeOnly)) { bAlwaysUpdateOnChange = true; sUpdateRate = "0"; statusMsgType = cJSon.StatusMsgType.Subscribe; } else if (menuitem.Equals(ToolStripMenuItem_StatusSubscribe_UpdateOnInterval_Manually) || menuitem.Equals(ToolStripMenuItem_StatusSubscribe_UpdateOnChangeAndInterval_Manually)) { if (cFormsHelper.InputBox("Enter Update Rate (seconds)", "UpdateRate:", ref sUpdateRate, false, true) != DialogResult.OK) { return; } if (sUpdateRate == "") { return; } bAlwaysUpdateOnChange = menuitem.OwnerItem.Equals(ToolStripMenuItem_StatusSubscribe_UpdateOnChangeAndInterval); statusMsgType = cJSon.StatusMsgType.Subscribe; } else { sUpdateRate = menuitem.Tag.ToString(); bAlwaysUpdateOnChange = menuitem.OwnerItem.Equals(ToolStripMenuItem_StatusSubscribe_UpdateOnChangeAndInterval); statusMsgType = cJSon.StatusMsgType.Subscribe; } // Each group belongs to a RoadSide object foreach (ListViewGroup lvGroup in listView_Status.Groups) { RoadSideObject = null; List <RSMP_Messages.StatusSubscribe_Status_Over_3_1_4> StatusSubscribeValues = new List <RSMP_Messages.StatusSubscribe_Status_Over_3_1_4>(); foreach (ListViewItem lvItem in lvGroup.Items) { if (lvItem.Selected) { cStatusReturnValue StatusReturnValue = (cStatusReturnValue)lvItem.Tag; if (RoadSideObject == null) { RoadSideObject = StatusReturnValue.StatusObject.RoadSideObject; } RSMP_Messages.StatusSubscribe_Status_Over_3_1_4 statusSubscribe_Status = new RSMP_Messages.StatusSubscribe_Status_Over_3_1_4(); statusSubscribe_Status.sCI = StatusReturnValue.StatusObject.sStatusCodeId; statusSubscribe_Status.n = StatusReturnValue.sName; if (statusMsgType == cJSon.StatusMsgType.Subscribe) { statusSubscribe_Status.uRt = sUpdateRate; statusSubscribe_Status.sOc = bAlwaysUpdateOnChange; } else { statusSubscribe_Status.uRt = null; statusSubscribe_Status.sOc = false; } StatusReturnValue.sLastUpdateRate = statusSubscribe_Status.uRt; StatusReturnValue.bLastUpdateOnChange = statusSubscribe_Status.sOc; StatusSubscribeValues.Add(statusSubscribe_Status); } } if (StatusSubscribeValues.Count == 0 || RoadSideObject == null) { continue; } switch (statusMsgType) { case cJSon.StatusMsgType.Subscribe: RSMPGS.JSon.CreateAndSendSubscriptionMessage(RoadSideObject, StatusSubscribeValues); break; case cJSon.StatusMsgType.Request: RSMPGS.JSon.CreateAndSendStatusMessage(RoadSideObject, StatusSubscribeValues, "StatusRequest"); break; case cJSon.StatusMsgType.UnSubscribe: RSMPGS.JSon.CreateAndSendStatusMessage(RoadSideObject, StatusSubscribeValues, "StatusUnsubscribe"); break; default: return; } } }