static void Main(string[] args) { foreach (string sArgument in args) { // // Use /path:... argument to point to specific folder (settings/logfiles etc) // if (sArgument.StartsWith("/Path:", StringComparison.OrdinalIgnoreCase)) { SpecifiedPath = sArgument.Substring(6).Trim(); if (SpecifiedPath.Length > 0) { if (SpecifiedPath.EndsWith("\\") == false) { SpecifiedPath += "\\"; } } } if (sArgument.StartsWith("/DebugName:", StringComparison.OrdinalIgnoreCase)) { DebugName = sArgument.Substring(11).Trim(); } if (sArgument.StartsWith("/DebugServer:", StringComparison.OrdinalIgnoreCase)) { DebugServer = sArgument.Substring(13).Trim(); } } // Must be initialized after Argument parsing... IniFileFullname = cPrivateProfile.SettingsPath() + "\\" + "RSMPGS2.ini"; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm = new RSMPGS_Main(); Application.Run(MainForm); }
public void LoadProcessImageValues(RSMPGS_Main MainForm, string FileName) { bool bWeAreConnected = false; try { if (RSMPGS.RSMPConnection != null) { bWeAreConnected = RSMPGS.RSMPConnection.ConnectionStatus() == cTcpSocket.ConnectionStatus_Connected; } List <RSMP_Messages.Status_VTQ> sS = new List <RSMP_Messages.Status_VTQ>(); //StreamReader swReferenceFile = new StreamReader((System.IO.Stream)File.OpenRead(FileName), encoding); //swReferenceFile.Close(); /* * [26108.AB+26108=881CG001.Passagedetektor.Passagedetektor DP1.AB+26108=881DP001.Alarms] * A904.Active=True * * [26108.AB+26108=881CG001.Passagedetektor.Passagedetektor DP1.AB+26108=881DP001.AlarmEvents] * A904.AlarmEvent_0.MessageId=f56ad0f6-7c4c-4b51-a602-8ba9fadf6ea8 * A904.AlarmEvent_0.TimeStamp=2011-11-16T12:52:39.437 * [26108.AB+26108=881CG001.Passagedetektor.Passagedetektor DP1.AB+26108=881DP001.Status] * S0001.status 1.Status=10 */ foreach (cRoadSideObject RoadSideObject in RSMPGS.ProcessImage.RoadSideObjects.Values) { bool bSomeThingWasChangedInAggregatedStatus = false; if (MainForm.checkBox_ProcessImageLoad_AlarmStatus.Checked) { foreach (cAlarmObject AlarmObject in RoadSideObject.AlarmObjects) { string sSection = RoadSideObject.UniqueId() + ".Alarms"; string sParameter = AlarmObject.sAlarmCodeId + ".Active"; cAlarmEvent AlarmEvent = null; cAlarmObject NewAlarmObject = new cAlarmObject(); NewAlarmObject.bActive = cPrivateProfile.GetIniFileInt(FileName, RoadSideObject.UniqueId() + ".Alarms", AlarmObject.sAlarmCodeId + ".Active", 0) != 0; NewAlarmObject.bSuspended = cPrivateProfile.GetIniFileInt(FileName, RoadSideObject.UniqueId() + ".Alarms", AlarmObject.sAlarmCodeId + ".Suspended", 0) != 0; NewAlarmObject.bAcknowledged = cPrivateProfile.GetIniFileInt(FileName, RoadSideObject.UniqueId() + ".Alarms", AlarmObject.sAlarmCodeId + ".Acknowledged", 0) != 0; AlarmObject.AlarmEvents.Clear(); foreach (cAlarmReturnValue AlarmReturnValue in AlarmObject.AlarmReturnValues) { string sValue = cPrivateProfile.GetIniFileString(FileName, RoadSideObject.UniqueId() + ".Alarms", AlarmObject.sAlarmCodeId + "." + AlarmReturnValue.sName + ".Value", "?"); if (sValue != "?") { AlarmReturnValue.Value.SetValue(sValue); } } if (AlarmObject.bSuspended != NewAlarmObject.bSuspended) { AlarmObject.bSuspended = NewAlarmObject.bSuspended; if (bWeAreConnected) { RSMPGS.JSon.CreateAndSendAlarmMessage(AlarmObject, cJSon.AlarmSpecialisation.Suspend); } } if (AlarmObject.bActive != NewAlarmObject.bActive) { AlarmObject.bActive = NewAlarmObject.bActive; if (bWeAreConnected) { if (NewAlarmObject.bActive) { RSMPGS.JSon.CreateAndSendAlarmMessage(AlarmObject, cJSon.AlarmSpecialisation.Issue, out AlarmEvent); if (AlarmEvent != null) { AlarmObject.AlarmEvents.Add(AlarmEvent); } } else { RSMPGS.JSon.CreateAndSendAlarmMessage(AlarmObject, cJSon.AlarmSpecialisation.Issue); AlarmObject.AlarmEvents.Clear(); } } } if (AlarmObject.bAcknowledged != NewAlarmObject.bAcknowledged) { AlarmObject.bAcknowledged = NewAlarmObject.bAcknowledged; if (bWeAreConnected) { RSMPGS.JSon.CreateAndSendAlarmMessage(AlarmObject, cJSon.AlarmSpecialisation.Acknowledge); } AlarmObject.AlarmEvents.Clear(); } AlarmObject.AlarmCount = 0; /* * sSection = sObjectUniqueId + ".AlarmEvents"; * * foreach (cAlarmReturnValue AlarmReturnValue in AlarmObject.AlarmReturnValues) * { * AlarmReturnValue.sValue = cPrivateProfile.GetIniFileString(FileName, sSection, AlarmObject.sAlarmCodeId + ".ReturnValue_" + AlarmReturnValue.sName + ".Value", ""); * } * for (int iIndex = 0; ; iIndex++) * { * string sMsgId = cPrivateProfile.GetIniFileString(FileName, sSection, AlarmObject.sAlarmCodeId + ".AlarmEvent_" + iIndex.ToString() + ".MessageId", ""); * string sTS = cPrivateProfile.GetIniFileString(FileName, sSection, AlarmObject.sAlarmCodeId + ".AlarmEvent_" + iIndex.ToString() + ".TimeStamp", ""); * if (sMsgId.Length > 0) * { * cAlarmEvent AlarmEvent = new cAlarmEvent(); * AlarmEvent.sMessageId = sMsgId; * AlarmEvent.sTimeStamp = sTS; * AlarmObject.AlarmEvents.Add(AlarmEvent); * } * else * { * break; * } * * } */ } } if (MainForm.checkBox_ProcessImageLoad_Status.Checked) { // Stored status foreach (cStatusObject StatusObject in RoadSideObject.StatusObjects) { foreach (cStatusReturnValue StatusReturnValue in StatusObject.StatusReturnValues) { string sStatus = cPrivateProfile.GetIniFileString(FileName, RoadSideObject.UniqueId() + ".Status", StatusObject.sStatusCodeId + "." + StatusReturnValue.sName + ".Status", "?"); StatusReturnValue.bRecentlyChanged = false; if (sStatus != "?") { StatusReturnValue.bRecentlyChanged = StatusReturnValue.Value.GetValue().Equals(sStatus) ? false : true; StatusReturnValue.Value.SetValue(sStatus); } } } sS.Clear(); foreach (cSubscription Subscription in RoadSideObject.Subscriptions) { if (Subscription.SubscribeStatus == cSubscription.SubscribeMethod.OnChange || Subscription.SubscribeStatus == cSubscription.SubscribeMethod.IntervalAndOnChange) { if (Subscription.StatusReturnValue.bRecentlyChanged) { RSMP_Messages.Status_VTQ s = new RSMP_Messages.Status_VTQ(); s.sCI = Subscription.StatusObject.sStatusCodeId; s.n = Subscription.StatusReturnValue.sName; // Subscription.StatusObject.StatusReturnValues .StatusReturnValues[iIndex].sName; UpdateStatusValue(ref s, Subscription.StatusReturnValue.Value.GetValueType(), Subscription.StatusReturnValue.Value.GetValue()); sS.Add(s); Subscription.LastUpdate = DateTime.Now; Subscription.StatusReturnValue.bRecentlyChanged = false; } } } if (sS.Count > 0) { if (bWeAreConnected) { RSMPGS.JSon.CreateAndSendStatusUpdateMessage(RoadSideObject, sS); } } } if (MainForm.checkBox_ProcessImageLoad_AggregatedStatus.Checked) { if (RoadSideObject.bIsComponentGroup) { if (RoadSideObject.sFunctionalPosition.Equals(cPrivateProfile.GetIniFileString(FileName, RoadSideObject.UniqueId() + ".AggregatedStatus", "FunctionalPosition", "")) == false) { RoadSideObject.sFunctionalPosition = cPrivateProfile.GetIniFileString(FileName, RoadSideObject.UniqueId() + ".AggregatedStatus", "FunctionalPosition", ""); bSomeThingWasChangedInAggregatedStatus = true; } if (RoadSideObject.sFunctionalState.Equals(cPrivateProfile.GetIniFileString(FileName, RoadSideObject.UniqueId() + ".AggregatedStatus", "FunctionalState", "")) == false) { RoadSideObject.sFunctionalState = cPrivateProfile.GetIniFileString(FileName, RoadSideObject.UniqueId() + ".AggregatedStatus", "FunctionalState", ""); bSomeThingWasChangedInAggregatedStatus = true; } for (int iIndex = 0; iIndex < RoadSideObject.bBitStatus.GetLength(0); iIndex++) { if (RoadSideObject.bBitStatus[iIndex] != (cPrivateProfile.GetIniFileInt(FileName, RoadSideObject.UniqueId() + ".AggregatedStatus", "BitStatus_" + iIndex.ToString(), 0) != 0)) { RoadSideObject.bBitStatus[iIndex] = cPrivateProfile.GetIniFileInt(FileName, RoadSideObject.UniqueId() + ".AggregatedStatus", "BitStatus_" + iIndex.ToString(), 0) != 0; bSomeThingWasChangedInAggregatedStatus = true; } } if (bSomeThingWasChangedInAggregatedStatus) { if (MainForm.checkBox_AggregatedStatus_SendAutomaticallyWhenChanged.Checked) { if (bWeAreConnected) { RSMPGS.JSon.CreateAndSendAggregatedStatusMessage(RoadSideObject); } } } } } if (MainForm.treeView_SitesAndObjects.SelectedNode != null) { if (MainForm.treeView_SitesAndObjects.SelectedNode.Tag != null && MainForm.treeView_SitesAndObjects.SelectedNode.Parent != null) { if (RoadSideObject == (cRoadSideObject)MainForm.treeView_SitesAndObjects.SelectedNode.Tag) { MainForm.UpdateStatusListView(null, RoadSideObject); MainForm.UpdateAlarmListView(null, RoadSideObject); if (bSomeThingWasChangedInAggregatedStatus) { for (int iIndex = 0; iIndex < RoadSideObject.bBitStatus.GetLength(0); iIndex++) { ListViewItem lvItem = MainForm.listView_AggregatedStatus_StatusBits.Items[iIndex]; MainForm.SetStatusBitColor(lvItem, RoadSideObject.bBitStatus[iIndex]); } RSMPGS_Main.bIsCurrentlyChangingSelection = true; MainForm.listBox_AggregatedStatus_FunctionalPosition.ClearSelected(); for (int iIndex = 0; iIndex < MainForm.listBox_AggregatedStatus_FunctionalPosition.Items.Count; iIndex++) { if (MainForm.listBox_AggregatedStatus_FunctionalPosition.Items[iIndex].Equals(RoadSideObject.sFunctionalPosition)) { MainForm.listBox_AggregatedStatus_FunctionalPosition.SelectedIndex = iIndex; } } MainForm.listBox_AggregatedStatus_FunctionalState.ClearSelected(); for (int iIndex = 0; iIndex < MainForm.listBox_AggregatedStatus_FunctionalState.Items.Count; iIndex++) { if (MainForm.listBox_AggregatedStatus_FunctionalState.Items[iIndex].Equals(RoadSideObject.sFunctionalState)) { MainForm.listBox_AggregatedStatus_FunctionalState.SelectedIndex = iIndex; } } RSMPGS_Main.bIsCurrentlyChangingSelection = false; } } } } } /* * listBox_AggregatedStatus_FunctionalPosition_SelectedIndexChanged(object sender, EventArgs e) * listBox_AggregatedStatus_FunctionalState_SelectedIndexChanged(object sender, EventArgs e) * */ RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Info, "Loaded Process data from '{0}'", FileName); } catch (Exception e) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Error, "Failed to load Process data from '{0}' - {1}", FileName, e.Message); } }