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); } }
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); * } */ }
private void button_Commands_Send_Click(object sender, EventArgs e) { bool bUseCaseSensitiveIds = cHelper.IsSettingChecked("UseCaseSensitiveIds"); List <cCommandReturnValue> lSelectedCommands = new List <cCommandReturnValue>(); int i = 0; foreach (cCommandObject CommandObject in RoadSideObject.CommandObjects) { foreach (cCommandReturnValue CommandArguments in CommandObject.CommandReturnValues) { if (this.dataGridView_Commands.Rows[i].Cells[0].Value != null && (bool)this.dataGridView_Commands.Rows[i].Cells[0].Value == true) { cCommandReturnValue CommandReturnValue = new cCommandReturnValue(CommandArguments.CommandObject); //CommandReturnValue.sCommandCodeId = CommandArguments.sCommandCodeId; CommandReturnValue.sName = CommandArguments.sName; CommandReturnValue.sCommand = CommandArguments.sCommand; CommandReturnValue.Value = new cValue(CommandArguments.Value.ValueTypeObject, false); CommandReturnValue.CommandObject = CommandObject; if (this.dataGridView_Commands.Rows[i].Cells[4].Value == null || this.dataGridView_Commands.Rows[i].Cells[4].Value.ToString().Trim().Length == 0) { MessageBox.Show(this, "Can't send message with empty value!"); return; } //if (CommandArguments.sValue.Length == 0) //{ CommandReturnValue.Value.SetValue(this.dataGridView_Commands.Rows[i].Cells[4].Value.ToString().Trim()); lSelectedCommands.Add(CommandReturnValue); } i++; } } if (lSelectedCommands.Count > 0) { if (lSelectedCommands.Count > 0) { RSMPGS.JSon.CreateAndSendCommandMessage(RoadSideObject, lSelectedCommands, bUseCaseSensitiveIds); } //Close(); } else { MessageBox.Show(this, "No command is selected!"); } }
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 LoadProcessImageValues(string FileName) { try { if (!File.Exists(FileName)) { var hFile = File.Create(FileName); hFile.Close(); } } catch (Exception e) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Error, "Failed to create file {0}", e.Message, FileName); } try { StreamReader swReferenceFile = new StreamReader((System.IO.Stream)File.OpenRead(FileName), Encoding.UTF8); string sLine; while ((sLine = swReferenceFile.ReadLine()) != null) { cRoadSideObject RoadSideObject; sLine = sLine.Trim(); if (sLine.StartsWith(";") || sLine.Length == 0 || sLine.StartsWith("[")) { continue; } try { RoadSideObject = RSMPGS.JSon.JSonSerializer.Deserialize <cRoadSideObject>(sLine); } catch { continue; } cRoadSideObject gRoadSide = cHelper.FindRoadSideObject(RoadSideObject.sNTSObjectId, RoadSideObject.sComponentId, false); if (gRoadSide != null) { gRoadSide.bBitStatus = RoadSideObject.bBitStatus; //foreach (cAlarmEvent AlarmEvent in RoadSideObject.AlarmEvents) //{ // gRoadSide.AlarmEvents.Add(AlarmEvent); //} foreach (cCommandEvent CommandEvent in RoadSideObject.CommandEvents) { gRoadSide.CommandEvents.Add(CommandEvent); } foreach (cStatusEvent StatusEvent in RoadSideObject.StatusEvents) { gRoadSide.StatusEvents.Add(StatusEvent); } foreach (cAggregatedStatusEvent AggregatedStatusEvent in RoadSideObject.AggregatedStatusEvents) { gRoadSide.AggregatedStatusEvents.Add(AggregatedStatusEvent); } foreach (cStatusObject StatusObject in RoadSideObject.StatusObjects) { if (StatusObject.StatusReturnValues != null && StatusObject.StatusReturnValues.Count > 0) { cStatusObject StatusObject2 = gRoadSide.getStatusObject(StatusObject.sStatusCodeId); // .StatusReturnValues[0].sStatusCommandId); if (StatusObject2 != null) { foreach (cStatusReturnValue StatusReturnValues in StatusObject.StatusReturnValues) { cStatusReturnValue StatusReturnValues2 = StatusObject2.getStatusReturnValueByName(StatusReturnValues.sName); if (StatusReturnValues2 != null) { StatusReturnValues2.sLastUpdateRate = StatusReturnValues.sLastUpdateRate; StatusReturnValues2.bLastUpdateOnChange = StatusReturnValues.bLastUpdateOnChange; StatusReturnValues2.Value.SetValue(StatusReturnValues.Value.GetValue()); StatusReturnValues2.sQuality = StatusReturnValues.sQuality; } } } } } //foreach (cAlarmObject AlarmObject in RoadSideObject.AlarmObjects) //{ // cAlarmObject AlarmObject2 = gRoadSide.getAlarmObject(AlarmObject.sAlarmCodeId); // if (AlarmObject2 != null) // { // AlarmObject2.bAcknowledged = AlarmObject.bAcknowledged; // AlarmObject2.bActive = AlarmObject.bActive; // AlarmObject2.bSuspended = AlarmObject.bSuspended; // } //} foreach (cCommandObject CommandObject in RoadSideObject.CommandObjects) { if (CommandObject.CommandReturnValues != null && CommandObject.CommandReturnValues.Count > 0) { cCommandObject CommandObject2 = gRoadSide.getCommandObject(CommandObject.sCommandCodeId); if (CommandObject2 != null) { foreach (cCommandReturnValue CommandReturnValue in CommandObject.CommandReturnValues) { cCommandReturnValue CommandReturnValue2 = CommandObject2.getCommandReturnValueByName(CommandReturnValue.sName); if (CommandReturnValue2 != null) { CommandReturnValue2.sLastRecAge = CommandReturnValue.sLastRecAge; CommandReturnValue2.sLastRecValue = CommandReturnValue.sLastRecValue; CommandReturnValue2.sAge = CommandReturnValue.sAge; CommandReturnValue2.Value.SetValue(CommandReturnValue.Value.GetValue()); } } } } } } else { //System.Windows.Forms.MessageBox.Show("Did not find roadside object"); } } swReferenceFile.Close(); } catch (Exception e) { RSMPGS.SysLog.SysLog(cSysLogAndDebug.Severity.Error, "Failed to open file {0}", e.Message, FileName); } }