/// <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(); }
/// <summary> /// Provide dummy target configuration information and write it to the output parameter <paramref name="targetConfiguration"/>. /// </summary> /// <param name="communicationSetting">The communication settings that are to be used to communicate with the target. Ignored.</param> /// <param name="targetConfiguration">The target configuration information returned from the target hardware if a target is found.</param> /// <returns>A flag to indicate whether a target was found; true, if a target was found, otherwise, false.</returns> /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.InitCommunication() method is not /// CommunicationError.Success.</exception> public bool ScanPort(CommunicationSetting_t communicationSetting, out TargetConfiguration_t targetConfiguration) { targetConfiguration.CarIdentifier = m_CarID; targetConfiguration.ConversionMask = ConversionMask; targetConfiguration.ProjectIdentifier = ProjectIdentifier; targetConfiguration.SubSystemName = SubSystemName; targetConfiguration.Version = Version; return(true); }
/// <summary> /// Get the configuration information associated with the target hardware. /// </summary> /// <param name="targetConfiguration">The target configuration information retrieved from the target.</param> /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.GetEmbeddedInformation() method is /// not CommunicationError.Success.</exception> public void GetEmbeddedInformation(out TargetConfiguration_t targetConfiguration) { targetConfiguration = new TargetConfiguration_t(); targetConfiguration.Version = Version; targetConfiguration.CarIdentifier = CarIdentifier; targetConfiguration.SubSystemName = SubSystemName; targetConfiguration.ProjectIdentifier = ProjectIdentifier; targetConfiguration.ConversionMask = ConversionMask; }
/// <summary> /// Event handler for the <c>Shown</c> event. Get the target configuration from the VCU and update the appropriate form labels. /// </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 FormShowSystemInformation_Shown(object sender, EventArgs e) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } Update(); // Ensure that an exception isn't thrown when a child form is opened in the Visual Studio development environment. if (MainWindow == null) { return; } // ------------------------------------------------------------------------------------------------------------------------------------ // Do not initiate any communication requests until the communication associated with any Mdi child forms that are open have been suspended. // ------------------------------------------------------------------------------------------------------------------------------------ Debug.Assert(CommunicationInterface != null); PauseCommunication <ICommunicationApplication>(CommunicationInterface, true); TargetConfiguration_t targetConfiguration = new TargetConfiguration_t(); try { CommunicationInterface.GetEmbeddedInformation(out targetConfiguration); } catch (CommunicationException) { MainWindow.WriteStatusMessage(Resources.EMCommunicationsLoss, Color.Red, Color.Black); CommunicationInterface.CloseCommunication(CommunicationInterface.CommunicationSetting.Protocol); // This resets the main screen so that the user has to reconnect to target hardware MainWindow.SetMode(Mode.Configuration); MainWindow.CommunicationInterface = null; return; } m_LabelLogicType.Text = targetConfiguration.SubSystemName; m_LabelSoftwareVersion.Text = targetConfiguration.Version; m_LabelCarNumber.Text = targetConfiguration.CarIdentifier; DisplayUpdate(this, new EventArgs()); // The DisplayUpdate() method has the potential to close the form, therefore to avoid a NullReferenceException, ensure that the timer is still // instantiated before attempting to start it. if (m_TimerDisplayUpdate != null) { m_TimerDisplayUpdate.Start(); } }
/// <summary> /// Event handler for the OK button <c>Click</c> event. Updates the properties with the selected target logic and communication settings. /// </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_BtnOK_Click(object sender, EventArgs e) { if (m_ListBoxAvailableLogicControllers.SelectedItems.Count == 0) { // No target was selected. MessageBox.Show(Resources.MBTSelectTarget, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int selectedLogic = m_ListBoxAvailableLogicControllers.SelectedIndex; m_TargetSelected = true; m_TargetConfiguration = m_TargetConfigurationList[selectedLogic]; m_CommunicationSetting = m_CommunicationSettingList[selectedLogic]; Close(); }
/// <summary> /// Scan the specified serial communication port to determine if it is connected to a target logic controller. If a target is found /// the target configuration information is written to the output parameter <paramref name="targetConfiguration"/>. /// </summary> /// <param name="communicationSetting">The communication settings that are to be used to communicate with the target.</param> /// <param name="targetConfiguration">The target configuration information returned from the target hardware if a target is found.</param> /// <returns>A flag to indicate whether a target was found; true, if a target was found, otherwise, false.</returns> /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.InitCommunication() method is not /// CommunicationError.Success.</exception> public bool ScanPort(CommunicationSetting_t communicationSetting, out TargetConfiguration_t targetConfiguration) { // Flag to indicate whether target hardware was found; true, if target was found, otherwise, false. bool targetFound = false; try { InitCommunication(communicationSetting); GetEmbeddedInformation(out targetConfiguration); targetFound = true; } catch (InvalidOperationException) { targetConfiguration = new TargetConfiguration_t(); return(targetFound); } finally { CloseCommunication(communicationSetting.Protocol); } return(targetFound); }