public static void BaseDelete(this CommunicationEvent @this, DeletableDelete method) { foreach (Task task in @this.TasksWhereWorkItem) { task.Delete(); } }
private void Subscribe(string name = null) { Enabled = true; var eventSvcRemoteFactory = CreateEventServiceRemoteFactory(); try { _krEventproxy = eventSvcRemoteFactory.CreateChannel(); BuildKRService(); var comObj = _krEventproxy as ICommunicationObject; comObj.Faulted += (s, ie) => { //ExceptionEvent?.Invoke(s, "Faulted"); }; comObj.Closed += (s, ie) => { //ExceptionEvent?.Invoke(s, "Closed"); }; comObj.Closing += (s, ie) => { CommunicationEvent?.Invoke(s, new DataEventArgs("remote host is closed")); }; _krEventproxy.Subscribe(CreateDefaultSubscribeArg(name)); } catch (Exception ex) { ExceptionEvent?.Invoke(new KRException("Subscribe", "connection error", ex.Message)); } }
public static void BaseOnPostDerive(this CommunicationEvent @this, ObjectOnPostDerive method) { var session = @this.Strategy.Session; @this.AddSecurityToken(new SecurityTokens(session).DefaultSecurityToken); @this.AddSecurityToken(@this.Owner?.OwnerSecurityToken); }
public void Select(CommunicationEvent communicationEvent) { var row = this.Table.FindRow(communicationEvent); var cell = row.FindCell("subject"); cell.Click(); }
public static void AppsOnDerive(this CommunicationEvent @this, ObjectOnDerive method) { var derivation = method.Derivation; if ([email protected]) { var owner = @this.Strategy.Session.GetUser() as Person; if (owner == null) { owner = @this.Strategy.Session.GetSingleton().Guest as Person; } @this.Owner = owner; } if (@this.ExistScheduledStart && @this.ExistScheduledEnd && @this.ScheduledEnd < @this.ScheduledStart) { derivation.Validation.AddError(@this, M.CommunicationEvent.ScheduledEnd, ErrorMessages.EndDateBeforeStartDate); } if (@this.ExistActualStart && @this.ExistActualEnd && @this.ActualEnd < @this.ActualStart) { derivation.Validation.AddError(@this, M.CommunicationEvent.ActualEnd, ErrorMessages.EndDateBeforeStartDate); } if ([email protected]) { if ([email protected] || (@this.ExistActualStart && @this.ActualStart > DateTime.UtcNow)) { @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Scheduled; } if (@this.ExistActualStart && @this.ActualStart <= DateTime.UtcNow && (@this.ExistActualEnd && @this.ActualEnd > DateTime.UtcNow || [email protected])) { @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).InProgress; } if (@this.ExistActualEnd && @this.ActualEnd <= DateTime.UtcNow) { @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Completed; } } if ([email protected] && @this.ExistScheduledStart) { @this.InitialScheduledStart = @this.ScheduledStart; } if ([email protected] && @this.ExistScheduledEnd) { @this.InitialScheduledEnd = @this.ScheduledEnd; } @this.DeriveInvolvedParties(); @this.DeriveOwnerSecurity(); }
public EmailCommunicationEditPage SelectEmailCommunication(CommunicationEvent communication) { this.CommunicationEventPanel.Click(); var row = this.Table.FindRow(communication); var cell = row.FindCell("description"); cell.Click(); return(new EmailCommunicationEditPage(this.Driver)); }
public LetterCorrespondenceEditPage SelectLetterCorrespondence(CommunicationEvent communication) { this.CommunicationEventPanel.Click(); var row = this.Table.FindRow(communication); var cell = row.FindCell("description"); cell.Click(); return(new LetterCorrespondenceEditPage(this.Driver)); }
private static void DeriveInvolvedParties(this CommunicationEvent @this) { var now = @this.Strategy.Session.Now(); var parties = new[] { @this.FromParty, @this.ToParty, @this.Owner }.Distinct().ToArray(); var organisation = parties.OfType <Person>() .SelectMany(v => v.OrganisationContactRelationshipsWhereContact) .Where(v => v.FromDate <= now && (!v.ExistThroughDate || v.ThroughDate >= now)) .Select(v => v.Organisation); @this.DerivedRoles.InvolvedParties = parties.Union(organisation).ToArray(); }
public static DateTime?AppsGetStart(this CommunicationEvent communicationEvent) { if (communicationEvent.ExistActualStart) { return(communicationEvent.ActualStart); } if (communicationEvent.ExistScheduledStart) { return(communicationEvent.ScheduledStart); } return(null); }
private static void DeriveOwnerSecurity(this CommunicationEvent @this) { if ([email protected]) { var ownerRole = new Roles(@this.Strategy.Session).Owner; @this.OwnerAccessControl = new AccessControlBuilder(@this.Strategy.Session).WithRole(ownerRole) .WithSubject(@this.Owner).Build(); } if ([email protected]) { @this.OwnerSecurityToken = new SecurityTokenBuilder(@this.Strategy.Session) .WithAccessControl(@this.OwnerAccessControl).Build(); } }
private static void DeriveInvolvedParties(this CommunicationEvent @this) { var partiesToRemove = @this.PartiesWhereCommunicationEvent.ToList(); if (@this.GetType().Name.Equals(typeof(EmailCommunication).Name)) { var mail = (EmailCommunication)@this; if (mail.ExistFromEmail) { mail.FromParty = mail.FromEmail.PartyWherePersonalEmailAddress; } if (mail.ExistToEmail) { mail.ToParty = mail.ToEmail.PartyWherePersonalEmailAddress; } } @this.RemoveInvolvedParties(); if (@this.ExistFromParty) { @this.AddInvolvedParty(@this.FromParty); @this.FromParty.AddCommunicationEvent(@this); if (partiesToRemove.Contains(@this.FromParty)) { partiesToRemove.Remove(@this.FromParty); } } if (@this.ExistToParty) { @this.AddInvolvedParty(@this.ToParty); @this.ToParty.AddCommunicationEvent(@this); if (partiesToRemove.Contains(@this.ToParty)) { partiesToRemove.Remove(@this.ToParty); } } if (@this.ExistOwner) { @this.AddInvolvedParty(@this.Owner); @this.Owner.AddCommunicationEvent(@this); if (partiesToRemove.Contains(@this.Owner)) { partiesToRemove.Remove(@this.Owner); } } foreach (Party party in @this.InvolvedParties) { if (party is Person person) { foreach (OrganisationContactRelationship organisationContactRelationship in person.OrganisationContactRelationshipsWhereContact) { if (organisationContactRelationship.FromDate <= DateTime.UtcNow && (!organisationContactRelationship.ExistThroughDate || organisationContactRelationship.ThroughDate >= DateTime.UtcNow)) { var organisation = organisationContactRelationship.Organisation; @this.AddInvolvedParty(organisation); organisation.AddCommunicationEvent(@this); if (partiesToRemove.Contains(organisation)) { partiesToRemove.Remove(organisation); } } } } } foreach (Party party in partiesToRemove) { party.RemoveCommunicationEvent(@this); } }
public static void AppsCancel(this CommunicationEvent @this, CommunicationEventCancel method) { @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Cancelled; }
public static void AppsReopen(this CommunicationEvent @this, CommunicationEventReopen method) { @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Scheduled; }
public static void AppsClose(this CommunicationEvent @this, CommunicationEventClose method) { @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Completed; }
public static void AppsDelete(this CommunicationEvent @this, DeletableDelete method) { @this.RemoveWorkEfforts(); }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="communicationInterface">The communication interface that is to be used to communicate with the VCU.</param> /// <param name="log">The current event log.</param> public FormShowEventHistory(ICommunicationParent communicationInterface, Log log) { InitializeComponent(); // Initialize the communication interface. if (communicationInterface is CommunicationParent) { CommunicationInterface = new CommunicationEvent(communicationInterface); } else { CommunicationInterface = new CommunicationEventOffline(communicationInterface); } Debug.Assert(CommunicationInterface != null); #region - [Size] - m_DataGridViewTextColumnEnableEvent.Visible = false; m_DataGridViewTextColumnStreamTriggered.Visible = false; m_DataGridViewTextColumnCumulativeHistory.Visible = true; m_DataGridViewTextColumnRecentHistory.Visible = true; // Get the combined width of all visible DataGridView columns. int dataGridViewWidth = 0; DataGridViewColumn dataGridViewColumn; for (int columnIndex = 0; columnIndex < m_DataGridViewEventStatus.Columns.Count; columnIndex++) { dataGridViewColumn = m_DataGridViewEventStatus.Columns[columnIndex]; if (dataGridViewColumn.Visible == true) { dataGridViewWidth += dataGridViewColumn.Width; } } m_PanelDataGridViewEventStatus.Width = dataGridViewWidth + MarginRightDataGridViewControl; Width = m_PanelDataGridViewEventStatus.Width + MarginRightPanelControl; #endregion - [Size] - #region - [Buttons] - // Only the OK button is required for this form, move the position of the OK button so that it hides the cancel button. m_ButtonCancel.Visible = false; m_ButtonOK.Location = m_ButtonCancel.Location; #endregion - [Buttons] - #region - [Context Menu] - // Disable those context menu options that are not applicable to this form. m_ContextMenuStripFlags.Items[ContextMenuItemIndexEnabled].Visible = false; m_ContextMenuStripFlags.Items[ContextMenuItemIndexStreamTriggered].Visible = false; #endregion - [Context Menu] - // ------------------------------------------------------------------ // Get the list of events associated with the current event log. // ------------------------------------------------------------------ List <EventRecord> foundEventRecordList = Lookup.EventTable.RecordList.FindAll(delegate(EventRecord eventRecord) { // Include a try/catch block in case an event record has not been defined. try { // The LOGID field of the EVENTS table actually uses the log index value which is equal to the log identifier - 1. return(eventRecord.LogIdentifier == log.Identifier - 1); } catch (Exception) { return(false); } }); foundEventRecordList.Sort(CompareByTaskIDByEventIDAscending); try { FormGetFltHistInfo formGetFltHistInfo = new FormGetFltHistInfo(CommunicationInterface, foundEventRecordList, log); formGetFltHistInfo.CalledFrom = this; formGetFltHistInfo.ShowDialog(); } catch (Exception) { throw new CommunicationException(Resources.EMGetFltHistInfoFailed); } AddList(EventStatusList); }
protected void HandleCommunicationEvent(object sender, string args) { CommunicationEvent?.Invoke(sender, new DataEventArgs(args)); }
public static void AppsOnPostDerive(this CommunicationEvent @this, ObjectOnPostDerive method) { @this.AddSecurityToken(@this.Strategy.Session.GetSingleton().DefaultSecurityToken); @this.AddSecurityToken(@this.Owner?.OwnerSecurityToken); }
/// <summary> /// Initializes an new instance of the form. Defines the communication interface and then downloads the current default data stream parameters and displays these /// on the form. /// </summary> /// <param name="communicationInterface">Reference to the communication interface that is to be used to communicate with the VCU.</param> /// <param name="worksetCollection">The workset collection that is to be managed.</param> /// <param name="log">The selected event log.</param> public FormConfigureFaultLogParameters(ICommunicationParent communicationInterface, WorksetCollection worksetCollection, Log log) : base(worksetCollection) { InitializeComponent(); // Only one column is required for this workset so delete the tab pages associated with columns 2 and 3. m_TabControlColumn.TabPages.Remove(m_TabPageColumn2); m_TabControlColumn.TabPages.Remove(m_TabPageColumn3); // Move the position of the Cancel buttons. m_ButtonCancel.Location = m_ButtonApply.Location; // Check the mode of the PTU. if (communicationInterface == null) { CommunicationInterface = null; } else if (communicationInterface is CommunicationParent) { // The PTU is in online mode. CommunicationInterface = new CommunicationEvent(communicationInterface); } else { // The PTU is in simulation mode (originally referred to as offline mode). CommunicationInterface = new CommunicationEventOffline(communicationInterface); } // Don't allow the user to edit the workset until the security level of the workset has been established. ModifyEnabled = false; m_NumericUpDownSampleMultiple.Enabled = ModifyEnabled; #region - [ToolTipText] - m_ToolStrip.Items[CommonConstants.KeyToolStripButtonUpload].ToolTipText = Resources.FunctionKeyToolTipDataStreamUpload; m_ToolStrip.Items[CommonConstants.KeyToolStripButtonSave].ToolTipText = Resources.FunctionKeyToolTipDataStreamSave; m_ToolStrip.Items[CommonConstants.KeyToolStripButtonEdit].ToolTipText = Resources.FunctionKeyToolTipDataStreamConfigure; m_ToolStrip.Items[CommonConstants.KeyToolStripButtonNew].ToolTipText = Resources.FunctionKeyToolTipDataStreamCreate; m_ToolStrip.Items[CommonConstants.KeyToolStripButtonCopy].ToolTipText = Resources.FunctionKeyToolTipDataStreamCopy; m_ToolStrip.Items[CommonConstants.KeyToolStripButtonRename].ToolTipText = Resources.FunctionKeyToolTipDataStreamRename; m_ToolStrip.Items[CommonConstants.KeyToolStripButtonDelete].ToolTipText = Resources.FunctionKeyToolTipDataStreamDelete; m_ToolStrip.Items[CommonConstants.KeyToolStripButtonSetAsDefault].ToolTipText = Resources.FunctionKeyToolTipDataStreamSetAsDefault; m_ToolStrip.Items[CommonConstants.KeyToolStripButtonOverrideSecurity].ToolTipText = Resources.FunctionKeyToolTipDataStreamOverrideSecurity; #endregion - [ToolTipText] - #region - [Get the Current Data Stream from the VCU] - // This only applies if the PTU is online. Workset_t workset; if (CommunicationInterface != null) { short variableCount, pointCount, sampleMultiple; short[] watchIdentifiers, dataTypes; try { CommunicationInterface.GetDefaultStreamInformation(out variableCount, out pointCount, out sampleMultiple, out watchIdentifiers, out dataTypes); } catch (Exception) { MessageBox.Show(Resources.MBTGetDefaultStreamParametersFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Convert the parameters to a workset. workset = CommunicationInterface.ConvertToWorkset("GetDefaultStreamInformation()", watchIdentifiers, sampleMultiple); // Search the list of worksets for a match. m_WorksetFromVCU = workset; m_WorksetToCompare = workset; Workset_t matchedWorkset = Workset.FaultLog.Worksets.Find(CompareWorkset); // Check whether a match was found. if (matchedWorkset.WatchItems == null) { // No - Create a new workset. workset.Name = DefaultNewWorksetName; // Set the flag to indicate that the workset does not exist and that any changes will be saved as a new workset. m_CreateMode = true; m_ComboBoxWorkset.DropDownStyle = ComboBoxStyle.DropDown; // Ensure that the TextChanged event is not triggered as a result of specifying the Text property of the TextBox control. m_TextBoxName.TextChanged -= new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Text = workset.Name; m_TextBoxName.TextChanged += new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Enabled = true; } else { // Yes - Update the name and security level of the workset. workset = matchedWorkset; // Set the flag to indicate that the form already exists and any changes will result in the existing workset being modified. m_CreateMode = false; m_ComboBoxWorkset.DropDownStyle = ComboBoxStyle.DropDownList; // Ensure that the TextChanged event is not triggered as a result of specifying the Text property of the TextBox control. m_TextBoxName.TextChanged -= new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Text = workset.Name; m_TextBoxName.TextChanged += new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Enabled = false; } } else { // Load the default workset. workset = worksetCollection.Worksets[worksetCollection.DefaultIndex]; // Set the flag to indicate that the form already exists and any changes will result in the existing workset being modified. m_CreateMode = false; m_ComboBoxWorkset.DropDownStyle = ComboBoxStyle.DropDownList; // Ensure that the TextChanged event is not triggered as a result of specifying the Text property of the TextBox control. m_TextBoxName.TextChanged -= new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Text = workset.Name; m_TextBoxName.TextChanged += new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Enabled = false; } #endregion - [Get the Current Data Stream from the VCU] - // Keep a record of the selected workset. This must be set up before the call to SetEnabledToolStripButtons(). m_SelectedWorkset = workset; SetEnabledToolStripButtons(true); // Update the 'Default' Image that identifies whether the selected workset is the default workset or not. m_PictureBoxDefault.Visible = (m_SelectedWorkset.Name.Equals(m_WorksetCollection.DefaultName)) ? true : false; // Display the name of the workset on the ComboBox control. // Ensure that the SelectionChanged event is not triggered as a result of specifying the Text property of the ComboBox control. m_ComboBoxWorkset.SelectedIndexChanged -= new EventHandler(m_ComboBoxWorkset_SelectedIndexChanged); m_ComboBoxWorkset.Text = workset.Name; m_ComboBoxWorkset.SelectedIndexChanged += new EventHandler(m_ComboBoxWorkset_SelectedIndexChanged); LoadWorkset(m_SelectedWorkset); // If an event log was specified, update the EntryCountMax property to reflect the actual number of watch variables associated with the current event log. if (log != null) { m_EntryCountMax = log.DataStreamTypeParameters.WatchVariablesMax; } UpdateCount(); // Check whether the 'Row Header' ListBox can be used to display the channel numbers. This is only possible if // the project doesn't support multiple data stream types and the number of parameters supported by the data // stream can be displayed on the TabPage without the need for scroll bars i.e. <= WatchSizeFaultLogMax. if ((Parameter.SupportsMultipleDataStreamTypes == false) && (Parameter.WatchSizeFaultLog <= WatchSizeFaultLogMax)) { AddRowHeader(); } else { NoRowHeader(); } // Disable all options other than save if the downloaded workset doesn't exist. if (m_CreateMode == true) { SetEnabledToolStripButtons(false); } // Allow the user to save the workset if it doesn't already exist. m_TSBSave.Enabled = (m_CreateMode == true) ? true : false; }
public static void BaseOnDerive(this CommunicationEvent @this, ObjectOnDerive method) { var derivation = method.Derivation; if ([email protected] && @this.Strategy.Session.GetUser() is Person owner) { @this.Owner = owner; } if (@this.ExistScheduledStart && @this.ExistScheduledEnd && @this.ScheduledEnd < @this.ScheduledStart) { derivation.Validation.AddError(@this, M.CommunicationEvent.ScheduledEnd, ErrorMessages.EndDateBeforeStartDate); } if (@this.ExistActualStart && @this.ExistActualEnd && @this.ActualEnd < @this.ActualStart) { derivation.Validation.AddError(@this, M.CommunicationEvent.ActualEnd, ErrorMessages.EndDateBeforeStartDate); } if ([email protected]) { if ([email protected] || (@this.ExistActualStart && @this.ActualStart > @this.Strategy.Session.Now())) { @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Scheduled; } if (@this.ExistActualStart && @this.ActualStart <= @this.Strategy.Session.Now() && ((@this.ExistActualEnd && @this.ActualEnd > @this.Strategy.Session.Now()) || [email protected])) { @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).InProgress; } if (@this.ExistActualEnd && @this.ActualEnd <= @this.Strategy.Session.Now()) { @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Completed; } } if ([email protected] && @this.ExistScheduledStart) { @this.InitialScheduledStart = @this.ScheduledStart; } if ([email protected] && @this.ExistScheduledEnd) { @this.InitialScheduledEnd = @this.ScheduledEnd; } var openCommunicationTasks = @this.TasksWhereWorkItem .OfType <CommunicationTask>() .Where(v => !v.ExistDateClosed) .ToArray(); if (@this.ExistActualEnd) { if (openCommunicationTasks.Length > 0) { openCommunicationTasks.First().DateClosed = @this.Strategy.Session.Now(); } } else { if (openCommunicationTasks.Length == 0) { new CommunicationTaskBuilder(@this.Strategy.Session).WithCommunicationEvent(@this).Build(); } } @this.DeriveInvolvedParties(); }
/// <summary> /// Initializes an new instance of the form. Defines the communication interface and then downloads the current default data stream parameters and displays these /// on the form. /// </summary> /// <param name="communicationInterface">Reference to the communication interface that is to be used to communicate with the VCU.</param> /// <param name="worksetCollection">The workset collection that is to be managed.</param> /// <param name="log">The selected event log.</param> public FormConfigureFaultLogParameters(ICommunicationParent communicationInterface, WorksetCollection worksetCollection, Log log) : base(worksetCollection) { InitializeComponent(); // Move the position of the Cancel buttons. m_ButtonCancel.Location = m_ButtonApply.Location; // Initialize the communication interface. if (communicationInterface is CommunicationParent) { CommunicationInterface = new CommunicationEvent(communicationInterface); } else { CommunicationInterface = new CommunicationEventOffline(communicationInterface); } Debug.Assert(CommunicationInterface != null); // Don't allow the user to edit the workset until the security level of the workset has been established. ModifyEnabled = false; m_NumericUpDownSampleMultiple.Enabled = ModifyEnabled; // ---------------------------------------------------- // Get the current data stream parameters from the VCU. // ---------------------------------------------------- short variableCount, pointCount, sampleMultiple; short[] watchIdentifiers, dataTypes; try { CommunicationInterface.GetDefaultStreamInformation(out variableCount, out pointCount, out sampleMultiple, out watchIdentifiers, out dataTypes); } catch (Exception) { MessageBox.Show(Resources.MBTGetDefaultStreamParametersFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Convert the parameters to a workset. Workset_t workset = CommunicationInterface.ConvertToWorkset("GetDefaultStreamInformation()", watchIdentifiers, sampleMultiple); // Search the list of worksets for a match. m_WorksetFromVCU = workset; m_WorksetToCompare = workset; Workset_t matchedWorkset = Workset.FaultLog.Worksets.Find(CompareWorkset); // Check whether a match was found. if (matchedWorkset.WatchItems == null) { // No - Create a new workset. workset.Name = DefaultNewWorksetName; // Set the flag to indicate that the workset does not exist and that any changes will be saved as a new workset. m_CreateMode = true; m_ComboBoxWorkset.DropDownStyle = ComboBoxStyle.DropDown; // Ensure that the TextChanged event is not triggered as a result of specifying the Text property of the TextBox control. m_TextBoxName.TextChanged -= new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Text = workset.Name; m_TextBoxName.TextChanged += new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Enabled = true; } else { // Yes - Update the name and security level of the workset. workset = matchedWorkset; // Set the flag to indicate that the form already exists and any changes will result in the existing workset being modified. m_CreateMode = false; m_ComboBoxWorkset.DropDownStyle = ComboBoxStyle.DropDownList; // Ensure that the TextChanged event is not triggered as a result of specifying the Text property of the TextBox control. m_TextBoxName.TextChanged -= new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Text = workset.Name; m_TextBoxName.TextChanged += new EventHandler(m_TextBoxName_TextChanged); m_TextBoxName.Enabled = false; } // Keep a record of the selected workset. This must be set up before the call to SetEnabledEditNewCopyRename(). m_SelectedWorkset = workset; SetEnabledEditNewCopyRename(true); // Display the name of the default workset on the ComboBox control. // Ensure that the SelectionChanged event is not triggered as a result of specifying the Text property of the ComboBox control. m_ComboBoxWorkset.SelectedIndexChanged -= new EventHandler(m_ComboBoxWorkset_SelectedIndexChanged); m_ComboBoxWorkset.Text = workset.Name; m_ComboBoxWorkset.SelectedIndexChanged += new EventHandler(m_ComboBoxWorkset_SelectedIndexChanged); LoadWorkset(workset); // Update the EntryCountMax property to reflect the actual number of watch variables associated with the current event log. m_EntryCountMax = log.DataStreamTypeParameters.WatchVariablesMax; UpdateCount(); // Check whether the 'Row Header' ListBox can be used to display the channel numbers. This is only possible if // the project doesn't support multiple data stream types and the number of parameters supported by the data // stream can be displayed on the TabPage without the need for scroll bars i.e. <= WatchSizeFaultLogMax. if ((Parameter.SupportsMultipleDataStreamTypes == false) && (Parameter.WatchSizeFaultLog <= WatchSizeFaultLogMax)) { AddRowHeader(); } else { NoRowHeader(); } // Disable all options other than save if the downloaded workset doesn't exist. if (m_CreateMode == true) { SetEnabledEditNewCopyRename(false); } // Allow the user to save the workset if it doesn't already exist. m_TSBSave.Enabled = (m_CreateMode == true) ? true : false; }
/// <summary> /// Initialize the event logs. /// </summary> public void InitializeEventLogs() { MainWindow.CloseChildForms(); MainWindow.Cursor = Cursors.WaitCursor; ICommunicationEvent communicationEvent; // Initialize the communication interface. if (MainWindow.CommunicationInterface is CommunicationParent) { communicationEvent = new CommunicationEvent(MainWindow.CommunicationInterface); } else { communicationEvent = new CommunicationEventOffline(MainWindow.CommunicationInterface); } // Ask the user for confirmation. DialogResult dialogResult = MessageBox.Show(Resources.MBTConfirmInitializeEventLogs, Resources.MBCaptionQuestion, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (MainWindow != null) { MainWindow.Update(); } if (dialogResult == DialogResult.No) { MainWindow.Cursor = Cursors.Default; return; } // Clear each event logs. Log log; for (int logIndex = 0; logIndex < Lookup.LogTable.RecordList.Count; logIndex++) { log = Lookup.LogTable.RecordList[logIndex]; // Only process those logs that have been defined. if (log != null) { MainWindow.WriteStatusMessage(string.Format(Resources.SMEventLogsInitialize, log.Description)); try { communicationEvent.ChangeEventLog(log); communicationEvent.InitializeEventLog(); } catch (CommunicationException) { MessageBox.Show(Resources.MBTEventLogInitializeFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { MainWindow.WriteStatusMessage(string.Empty); MainWindow.Cursor = Cursors.Default; } } } }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="communicationInterface">The communication interface that is to be used to communicate with the VCU.</param> /// <param name="log">The current event log.</param> public FormConfigureEventFlags(ICommunicationParent communicationInterface, Log log) { InitializeComponent(); // Initialize the communication interface. if (communicationInterface is CommunicationParent) { CommunicationInterface = new CommunicationEvent(communicationInterface); } else { CommunicationInterface = new CommunicationEventOffline(communicationInterface); } Debug.Assert(CommunicationInterface != null); #region - [Size] - // Get the combined width of all visible DataGridView columns. int dataGridViewWidth = 0; DataGridViewColumn dataGridViewColumn; for (int columnIndex = 0; columnIndex < m_DataGridViewEventStatus.Columns.Count; columnIndex++) { dataGridViewColumn = m_DataGridViewEventStatus.Columns[columnIndex]; if (dataGridViewColumn.Visible == true) { dataGridViewWidth += dataGridViewColumn.Width; } } m_PanelDataGridViewEventStatus.Width = dataGridViewWidth + MarginRightDataGridViewControl; Width = m_PanelDataGridViewEventStatus.Width + MarginRightPanelControl; #endregion - [Size] - // ------------------------------------------------------------------ // Get the list of events associated with the current event log. // ------------------------------------------------------------------ List <EventRecord> foundEventRecordList; foundEventRecordList = Lookup.EventTable.RecordList.FindAll(delegate(EventRecord eventRecord) { // Include a try/catch block in case an event record has not been defined. try { // The LOGID field of the EVENTS table actually uses the log index value which is equal to the log identifier - 1. return(eventRecord.LogIdentifier == log.Identifier - 1); } catch (Exception) { return(false); } }); foundEventRecordList.Sort(CompareByTaskIDByEventIDAscending); // --------------------------------------------------------------- // Get the event flag information associated with the current log. // --------------------------------------------------------------- int eventCount = (short)foundEventRecordList.Count; int maxEventCount = log.MaxEventsPerTask * log.MaxTasks; // Initialize the validFlags array to define which of the events are used in the current log. short[] validFlags = new short[maxEventCount]; int eventIndex; for (int index = 0; index < foundEventRecordList.Count; index++) { eventIndex = foundEventRecordList[index].TaskIdentifier * log.MaxEventsPerTask + foundEventRecordList[index].EventIdentifier; validFlags[eventIndex] = CommonConstants.True; } short[] enabledFlags = new short[eventCount]; short[] streamTriggeredFlags = new short[eventCount]; try { CommunicationInterface.GetFltFlagInfo(validFlags, ref enabledFlags, ref streamTriggeredFlags, (short)maxEventCount); } catch (Exception) { throw new CommunicationException(Resources.EMGetFltFlagInfoFailed); } // --------------------------------- // Initialise the event status list. // --------------------------------- m_EventStatusList = new List <EventStatus_t>(eventCount); EventStatus_t eventStatus; for (int eventStatusIndex = 0; eventStatusIndex < eventCount; eventStatusIndex++) { eventStatus = new EventStatus_t(); eventStatus.Index = eventStatusIndex; eventStatus.Identifier = foundEventRecordList[eventStatusIndex].Identifier; if (enabledFlags[eventStatusIndex] == CommonConstants.True) { eventStatus.Enabled = true; } if (streamTriggeredFlags[eventStatusIndex] == CommonConstants.True) { eventStatus.StreamTriggered = true; } m_EventStatusList.Add(eventStatus); } AddList(m_EventStatusList); }
protected void OnCommunicationEvent(CommunicationEventArgs args) { CommunicationEvent?.Invoke(this, args); }