Exemplo n.º 1
0
        /// <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();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the embedded software information.
        /// </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)
        {
            // Check that the function delegate has been initialized.
            Debug.Assert(m_MutexCommuncationInterface != null, "CommunicationParent.GetEmbeddedInformation() - [m_MutexCommuncation != null]");

            targetConfiguration = new TargetConfiguration_t();
            TargetConfiguration_t localTargetConfiguration = new TargetConfiguration_t();
            CommunicationError errorCode = CommunicationError.UnknownError;
            ProtocolPTU.GetEmbeddedInfoRes embInfo = new ProtocolPTU.GetEmbeddedInfoRes();
            try
            {
                errorCode = m_WatchClockMarshal.GetEmbeddedInformation(ref embInfo);
                m_MutexCommuncationInterface.WaitOne(DefaultMutexWaitDurationMs, false);
                if (errorCode == CommunicationError.Success)
                {
                    localTargetConfiguration.Version = embInfo.SoftwareVersion;
                    localTargetConfiguration.CarIdentifier = embInfo.CarID;
                    localTargetConfiguration.SubSystemName = embInfo.SubSystemName;
                    localTargetConfiguration.ProjectIdentifier = embInfo.IdentifierString;
                    localTargetConfiguration.ConversionMask = embInfo.ConfigurationMask;
                }
            }
            catch (Exception)
            {
                errorCode = CommunicationError.SystemException;
                throw new CommunicationException(Resources.EMGetTargetConfigurationFailed, errorCode);
            }
            finally
            {
                m_MutexCommuncationInterface.ReleaseMutex();
            }

            if (DebugMode.Enabled == true)
            {
                DebugMode.GetEmbeddedInformation_t getEmbeddedInformation =
                    new DebugMode.GetEmbeddedInformation_t(localTargetConfiguration.Version,
                                                            localTargetConfiguration.CarIdentifier,
                                                            localTargetConfiguration.SubSystemName,
                                                            localTargetConfiguration.ProjectIdentifier,
                                                            localTargetConfiguration.ConversionMask,
                                                            errorCode);
                DebugMode.Write(getEmbeddedInformation.ToXML());
            }

            if (errorCode != CommunicationError.Success)
            {
                throw new CommunicationException(Resources.EMGetTargetConfigurationFailed, errorCode);
            }

            targetConfiguration.Version = localTargetConfiguration.Version;
            targetConfiguration.CarIdentifier = localTargetConfiguration.CarIdentifier;
            targetConfiguration.SubSystemName = localTargetConfiguration.SubSystemName;
            targetConfiguration.ProjectIdentifier = localTargetConfiguration.ProjectIdentifier;
            targetConfiguration.ConversionMask = localTargetConfiguration.ConversionMask;
        }
        /// <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;
        }
Exemplo n.º 4
0
        /// <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;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get the embedded software information.
        /// </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)
        {
            // Check that the function delegate has been initialized.
            Debug.Assert(m_GetEmbeddedInformation != null, "CommunicationParent.GetEmbeddedInformation() - [m_GetEmbeddedInformation != null]");
            Debug.Assert(m_MutexCommuncationInterface != null, "CommunicationParent.GetEmbeddedInformation() - [m_MutexCommuncation != null]");

            targetConfiguration = new TargetConfiguration_t();
            TargetConfiguration_t localTargetConfiguration = new TargetConfiguration_t();
            CommunicationError errorCode = CommunicationError.UnknownError;
            try
            {
                m_MutexCommuncationInterface.WaitOne(DefaultMutexWaitDurationMs, false);
                errorCode = (CommunicationError)m_GetEmbeddedInformation(   out localTargetConfiguration.Version,
                                                                            out localTargetConfiguration.CarIdentifier,
                                                                            out localTargetConfiguration.SubSystemName,
                                                                            out localTargetConfiguration.ProjectIdentifier,
                                                                            out localTargetConfiguration.ConversionMask);
            }
            catch (Exception)
            {
                errorCode = CommunicationError.SystemException;
                throw new CommunicationException(Resources.EMGetTargetConfigurationFailed, errorCode);
            }
            finally
            {
                m_MutexCommuncationInterface.ReleaseMutex();
            }

            if (DebugMode.Enabled == true)
            {
                DebugMode.GetEmbeddedInformation_t getEmbeddedInformation =
                    new DebugMode.GetEmbeddedInformation_t( localTargetConfiguration.Version,
                                                            localTargetConfiguration.CarIdentifier,
                                                            localTargetConfiguration.SubSystemName,
                                                            localTargetConfiguration.ProjectIdentifier,
                                                            localTargetConfiguration.ConversionMask,
                                                            errorCode);
                DebugMode.Write(getEmbeddedInformation.ToXML());
            }

            if (errorCode != CommunicationError.Success)
            {
                throw new CommunicationException(Resources.EMGetTargetConfigurationFailed, errorCode);
            }

            targetConfiguration.Version = localTargetConfiguration.Version.Trim();
            targetConfiguration.CarIdentifier = localTargetConfiguration.CarIdentifier.Trim();
            targetConfiguration.SubSystemName = localTargetConfiguration.SubSystemName.Trim();
            targetConfiguration.ProjectIdentifier = localTargetConfiguration.ProjectIdentifier.Trim();
            targetConfiguration.ConversionMask = localTargetConfiguration.ConversionMask;
        }
        /// <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;
        }