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 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 cCommandReturnValue(cCommandObject CommandObject, string sCompleteRow, ref int iIndex)
        {
            this.CommandObject = CommandObject;

            sName = cHelper.Item(sCompleteRow, iIndex++, ';').Trim();

            if (IsValid())
            {
                sCommand = cHelper.Item(sCompleteRow, iIndex++, ';').Trim();
                string sType       = cHelper.Item(sCompleteRow, iIndex++, ';').Trim();
                string sValueRange = cHelper.Item(sCompleteRow, iIndex++, ';').Trim();

                sComment = cHelper.Item(sCompleteRow, iIndex++, ';').Replace("\"", "").Replace("\n", " / ").Trim();

                string sValueTypeKey = CommandObject.sObjectType + "\t" + "alarms" + "\t" + CommandObject.sCommandCodeId + "\t" + CommandObject.sSpecificObject + "\t" + sName;

                RSMPGS.ProcessImage.CreateAndAddValueTypeObject(sValueTypeKey, sName, sType, sValueRange, sComment);

                Value = new cValue(sValueTypeKey, true);
            }
        }
 public cCommandReturnValue(cCommandObject CommandObject)
 {
     this.CommandObject = CommandObject;
 }
        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);
            }
        }