コード例 #1
0
ファイル: FileHandling.cs プロジェクト: SiGenixDave/PtuPc
 /// <summary>
 /// Initializes a new instance of the structure.
 /// </summary>
 /// <param name="header">The file header information.</param>
 public EventLogFile_t(Header_t header)
 {
     Header          = header;
     EventRecordList = new List <EventRecord>();
     Filename        = string.Empty;
     FullFilename    = string.Empty;
 }
コード例 #2
0
ファイル: FileHandling.cs プロジェクト: SiGenixDave/PtuPc
 /// <summary>
 /// Initialize a new instance of the structure. Copies the specified parameters to the structure and creates the auto-scale limits from the specified watch data
 /// frames.
 /// </summary>
 /// <param name="header">The file header information.</param>
 /// <param name="dataStream">The data stream.</param>
 public WatchFile_t(Header_t header, DataStream_t dataStream)
 {
     Header       = header;
     DataStream   = dataStream;
     Filename     = string.Empty;
     FullFilename = string.Empty;
 }
コード例 #3
0
        /// <summary>
        /// Initializes the specified header as unavailable.
        /// </summary>
        /// <param name="header">The header that is to be marked as unavailable.</param>
        public static void Initialize(ref Header_t header)
        {
            DataDictionaryInformation_t projectInformation;
            TargetConfiguration_t       targetConfiguration;

            header.Available       = true;
            header.Comments        = string.Empty;
            header.DateTimeCreated = DateTime.Now;
            header.ProductName     = Application.ProductName;
            header.ProductVersion  = Application.ProductVersion;

            projectInformation = new DataDictionaryInformation_t();
            projectInformation.DataDictionaryBuilderVersion = Resources.TextUnavailable;
            projectInformation.DataDictionaryName           = Resources.TextUnavailable;
            projectInformation.ProjectIdentifier            = Resources.TextUnavailable;
            projectInformation.Version = Resources.TextUnavailable;
            projectInformation.WatchIdentifierCount = 0;
            header.ProjectInformation = projectInformation;

            targetConfiguration = new TargetConfiguration_t();
            targetConfiguration.CarIdentifier     = string.Empty;
            targetConfiguration.ConversionMask    = 0;
            targetConfiguration.ProjectIdentifier = Resources.TextUnavailable;
            targetConfiguration.SubSystemName     = Resources.TextUnavailable;
            targetConfiguration.Version           = Resources.TextUnavailable;
            header.TargetConfiguration            = targetConfiguration;

            header.UserName = General.GetUsername();
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the structure.
 /// </summary>
 /// <param name="header">The file header information.</param>
 public EventLogFile_t(Header_t header)
 {
     m_Header          = header;
     m_EventRecordList = new List <EventRecord>();
     m_Filename        = string.Empty;
     m_FullFilename    = string.Empty;
 }
コード例 #5
0
ファイル: FileHandling.cs プロジェクト: SiGenixDave/PtuPc
        /// <summary>
        /// Initializes a new instance of the structure.
        /// </summary>
        /// <param name="header">The file header information.</param>
        /// <param name="eventRecordList">The list of event records that are to be written to disk file in XML format.</param>
        public EventLogFile_t(Header_t header, List <EventRecord> eventRecordList)
        {
            Header = header;

            // Copy the list of event records.
            EventRecord[] eventRecords = eventRecordList.ToArray();
            EventRecordList = new List <EventRecord>();
            EventRecordList.AddRange(eventRecords);
            Filename     = string.Empty;
            FullFilename = string.Empty;
        }
コード例 #6
0
ファイル: FileHeader.cs プロジェクト: SiGenixDave/PtuPCNew
 /// <summary>
 /// Initializes the specified header as unavailable.
 /// </summary>
 /// <param name="header">The header that is to be marked as unavailable.</param>
 public static void Initialize(ref Header_t header)
 {
     header.Available = true;
     header.Comments = string.Empty;
     header.DateTimeCreated = DateTime.Now;
     header.ProductName = Application.ProductName;
     header.ProductVersion = Application.ProductVersion;
     header.ProjectInformation = new DataDictionaryInformation_t();
     header.ProjectInformation.DataDictionaryBuilderVersion = Resources.TextUnavailable;
     header.ProjectInformation.DataDictionaryName = Resources.TextUnavailable;
     header.ProjectInformation.ProjectIdentifier = Resources.TextUnavailable;
     header.ProjectInformation.Version = Resources.TextUnavailable;
     header.ProjectInformation.WatchIdentifierCount = 0;
     header.TargetConfiguration.CarIdentifier = string.Empty;
     header.TargetConfiguration.ConversionMask = 0;
     header.TargetConfiguration.ProjectIdentifier = Resources.TextUnavailable;
     header.TargetConfiguration.SubSystemName = Resources.TextUnavailable;
     header.TargetConfiguration.Version = Resources.TextUnavailable;
     header.UserName = General.GetUsername();
 }
コード例 #7
0
ファイル: MdiPTU.cs プロジェクト: SiGenixDave/PtuPCNew
        /// <summary>
        /// Event handler for the off-line button <c>Click</c> event. Enter offline mode.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Parameter passed from the object that raised the event.</param>
        private void m_TSBOffline_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Skip, if the button isn't enabled.
            if (m_TSBOffline.Enabled == false)
            {
                return;
            }

            // If offline mode is already selected, toggle to configuration mode.
            if (m_TSBOffline.Checked)
            {
                #region - [Return to Configuration Mode] -
                // -------------------------------------------------------
                // The PTU is already offline, go to configuration mode.
                // -------------------------------------------------------
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    CommunicationInterface.CloseCommunication(CommunicationInterface.CommunicationSetting.Protocol);
                }
                catch (Exception)
                {
                    MessageBox.Show(Resources.MBTPortCloseFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }

                SetMode(Mode.Configuration);

                // Update the LogStatus StatusStrip.
                LogStatus = EventLogSavedStatus.NotApplicable;
                #endregion - [Return to Configuration Mode] -
                return;
            }

            this.Cursor = Cursors.WaitCursor;
            #region - [Go Offline] -
            // ---------------------------------------------------------------------------------------------
            // Enter offline mode. Instantiate a the communication interface which returns simulated values.
            // ---------------------------------------------------------------------------------------------
            CommunicationSetting_t communicationSetting = new CommunicationSetting_t();
            communicationSetting.Port = new Port_t();
            communicationSetting.PortIdentifier = string.Empty;
            communicationSetting.Protocol = Protocol.SIMULATOR;
            CommunicationInterface = new CommunicationParentOffline(communicationSetting);
            TargetConfiguration_t targetConfiguration;
            CommunicationInterface.GetEmbeddedInformation(out targetConfiguration);

            // Update the header information with the target configuration.
            Header_t header = new Header_t();
            header = FileHeader.HeaderCurrent;
            header.TargetConfiguration = targetConfiguration;
            FileHeader.HeaderCurrent = header;

            SetMode(Mode.Offline);

            // Check whether the most recently downloaded event log was saved to disk and update the LogStatus StatusStrip.
            LogStatus = EventLogSavedStatus.Unknown;

            UpdateChartMode();

            // Display the Watch Window only if the project doesn't use a Control Panel.
            if (this.Controls[CommonConstants.KeyControlPanel] == null)
            {
                m_MenuInterfaceWatch.ViewWatchWindow();
            }
            #endregion - [Go Offline] -
            this.Cursor = Cursors.Default;
        }
コード例 #8
0
ファイル: MdiPTU.cs プロジェクト: SiGenixDave/PtuPCNew
        /// <summary>
        /// Event handler for the on-line button <c>Click</c> event. Initializes the communication port specified in the <c>Communication</c> project user settings 
        /// and, if successful: (a) updates the mode setting and then (b) displays the form to show the live watch variable data.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Parameter passed from the object that raised the event.</param>
        private void m_TSBOnline_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Skip, if the button isn't enabled.
            if (m_TSBOnline.Enabled == false)
            {
                return;
            }

            // If online mode is already selected, toggle to configuration mode.
            if (m_TSBOnline.Checked)
            {
                #region - [Return to Configuration Mode] -
                // -------------------------------------------------------
                // The PTU is already online, go to configuration mode.
                // -------------------------------------------------------
				try
				{
					this.Cursor = Cursors.WaitCursor;
					CommunicationInterface.CloseCommunication(CommunicationInterface.CommunicationSetting.Protocol);
				}
				catch (CommunicationException ex)
				{
					// Check to see if it's a failure to close, which we can potentially ignore.
					if (ex.CommunicationError != CommunicationError.SystemException)
					{
						// This is a recoverable error, so we allow the port to stay open, but display the error.
						MessageBox.Show(Resources.MBTPortCloseFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
					}
					else
					{
						MessageBox.Show(Resources.MBTPortCloseFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
						return;
					}
				}
				catch (Exception)
				{
					MessageBox.Show(Resources.MBTPortCloseFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
					return;
				}
                finally
                {
                    this.Cursor = Cursors.Default;
                }

                SetMode(Mode.Configuration);

                // Update the LogStatus StatusStrip.
                LogStatus = EventLogSavedStatus.NotApplicable;
                #endregion -[Return to Configuration Mode] -
                return;
            }

            // ---------------------------------------------------------
            // Show the form to allow the user to select a valid target.
            // ---------------------------------------------------------
            this.Cursor = Cursors.WaitCursor;
            FormSelectTarget formSelectTarget = new FormSelectTarget();
            ShowDialog(formSelectTarget);
            this.Cursor = Cursors.WaitCursor;

            // Skip, if no target logic was selected.
            if (formSelectTarget.TargetSelected != true)
            {
                this.Cursor = Cursors.Default;
                return;
            }

            // -------------------------------------------------------------------------------------------------
            // A valid target was selected, check that the PTU configuration and the target configuration match.
            // -------------------------------------------------------------------------------------------------
            bool configurationMatch = CheckConfiguration(formSelectTarget.TargetConfiguration.ProjectIdentifier, formSelectTarget.TargetConfiguration.Version);
            if (configurationMatch == true)
            {
                #region - [Go Online] -
                // -------------------------------------------------------------------
                // PTU configuration and target configuration match, enter online mode.
                // -------------------------------------------------------------------
                CommunicationInterface = new CommunicationParent(formSelectTarget.CommunicationSetting);
                Debug.Assert(CommunicationInterface != null);

                try
                {
                    // Initialize the serial communications port associated with the selected target.
                    CommunicationInterface.InitCommunication(CommunicationInterface.CommunicationSetting);
                }
                catch (InvalidOperationException)
                {
                    // An error occurred trying to initialize the communication port, do not enter online mode.
                    CommunicationInterface = null;
                    this.Cursor = Cursors.Default;
                    MessageBox.Show(Resources.MBTPortInitializationFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // Update the header information with the target configuration.
                Header_t header = new Header_t();
                header = FileHeader.HeaderCurrent;
                header.TargetConfiguration = formSelectTarget.TargetConfiguration;
                FileHeader.HeaderCurrent = header;

                SetMode(Mode.Online);

                // Check whether the most recently downloaded event log was saved to disk and update the LogStatus StatusStrip.
                LogStatus = EventLogSavedStatus.Unknown;

                UpdateChartMode();

                // Display the Watch Window only if the project doesn't use a Control Panel.
                if (this.Controls[CommonConstants.KeyControlPanel] == null)
                {
                    m_MenuInterfaceWatch.ViewWatchWindow();
                }
                #endregion - [Go Online] -
            }
            this.Cursor = Cursors.Default;
        }
コード例 #9
0
ファイル: MdiPTU.Support.cs プロジェクト: SiGenixDave/PtuPc
        /// <summary>
        /// <para>Configures the PTU application using the specified data dictionary. The configuration procedure is as follows:</para>
        /// <para>(1) updates the <c>Parameter</c> class;</para>
        /// <para>(2) updates the Lookup static class to allow the records contained within the primary key data tables of the data dictionary to be accessed;</para> 
        /// <para>(3) creates the application data sub-directories if they do not exist;</para>
        /// <para>(4) updates the main menu options to reflect the current project and security level;</para>
        /// <para>(5) updates the file header information;</para>
        /// <para>(6) loads the default worksets associated with the specified data dictionary, if they exist;</para>
        /// <para>(7) loads the help file associated with the current project and software version;</para>
        /// <para>(8) shows the 'Help/About' screen.</para>
        /// </summary>
        /// <param name="dataDictionary">The data dictionary that is to be used to configure the PTU.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="dataDictionary"/> is null.</exception>
        public void LoadDictionary(DataDictionary dataDictionary)
        {
            Debug.Assert(dataDictionary != null, "MdiPTU.Support.LoadDictionary - [dataDictionary != null]");

            // The configuration file was OK, initialize the Parameter class.
            Parameter.Initialize(dataDictionary);

            // Check whether the project identifier was passed as a shortcut parameter.
            if (m_ProjectIdentifierPassedAsParameter.Equals(string.Empty))
            {
                // No, initialize the project specific features of the PTU application.
                InitializePTUProjectSpecific(Parameter.ProjectInformation.ProjectIdentifier);

                // Update the member variable that records the project-identifier that was passed as a parameter with the project-identifier associated with the
                // selected configuration file.
                m_ProjectIdentifierPassedAsParameter = Parameter.ProjectInformation.ProjectIdentifier;
            }
            else
            {
                // Check whether the data dictionary matches the project identifier that was passed as a shortcut parameter.
                if (Parameter.ProjectInformation.ProjectIdentifier != m_ProjectIdentifierPassedAsParameter)
                {
                    MessageBox.Show(Resources.MBTConfigProjectAsParameterMismatch, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                    return;
                }
            }

            Lookup.Initialize(dataDictionary);

            InitializeDataSubDirectories();

            // Initialize the system security and set the security clearance to the base level.
            Security.Initialize();
            m_Security = new Security();
            ShowSecurityLevelChange(m_Security);

            // Update the FileHeader.HeaderCurrent property with the parameter values that are currently known.
            Header_t header = new Header_t();
            FileHeader.Initialize(ref header);
            header.ProjectInformation = Parameter.ProjectInformation;
            FileHeader.HeaderCurrent = header;

            SetMode(Mode.Configuration);
            LoadAllWorksetCollections(Parameter.ProjectInformation.ProjectIdentifier);
            LoadHelpFile(Parameter.ProjectInformation.Version, Parameter.ProjectInformation.ProjectIdentifier);

            // If applicable to the current project, show the splash screen.
            switch (m_ProjectIdentifierPassedAsParameter)
            {
                case CommonConstants.ProjectIdNYCT:
                    // Do not show the splash screen for the R188 project.
                    break;
                default:
                    // Show the splash screen.
                    using (FormHelpAbout formHelpAbout = new FormHelpAbout(Resources.ProductNamePTU))
                    {
                        formHelpAbout.ShowDialog();
                    }
                    break;
            }
        }