Exemplo n.º 1
0
        /// <summary>
        /// Write the specified data to the watch variable specified by the <paramref name="dictionaryIndex"/> parameter.
        /// </summary>
        /// <param name="dictionaryIndex">The dictionary index.</param>
        /// <param name="dataType">The data type.</param>
        /// <param name="data">The data.</param>
        /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.CloseCommunication() method is not
        /// CommunicationError.Success.</exception>
        public void SendVariable(short dictionaryIndex, short dataType, double data)
        {
            Debug.Assert(m_MutexCommuncationInterface != null, "CommunicationWatch.SendVariable() - [m_MutexCommuncationInterface != null]");

            CommunicationError errorCode = CommunicationError.UnknownError;

            try
            {
                m_MutexCommuncationInterface.WaitOne(DefaultMutexWaitDurationMs, false);
                errorCode = (CommunicationError)m_WatchClockMarshal.SendVariable(dictionaryIndex, dataType, data);
            }
            catch (Exception)
            {
                errorCode = CommunicationError.SystemException;
                throw new CommunicationException(Resources.EMSendVariableFailed, errorCode);
            }
            finally
            {
                m_MutexCommuncationInterface.ReleaseMutex();
            }

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

            if (DebugMode.Enabled == true)
            {
                DebugMode.SendVariable_t sendVariable = new DebugMode.SendVariable_t(dictionaryIndex, dataType, data, errorCode);
                DebugMode.Write(sendVariable.ToXML());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Write the specified data to the watch variable specified by the <paramref name="dictionaryIndex"/> parameter.
        /// </summary>
        /// <param name="dictionaryIndex">The dictionary index.</param>
        /// <param name="dataType">The data type.</param>
        /// <param name="data">The data.</param>
        /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.CloseCommunication() method is not
        /// CommunicationError.Success.</exception>
        public void SendVariable(short dictionaryIndex, short dataType, double data)
        {
            Debug.Assert(m_SendVariable != null, "CommunicationWatch.SendVariable() - [m_SendVariableDelegate != null]");
            Debug.Assert(m_MutexCommuncationInterface != null, "CommunicationWatch.SendVariable() - [m_MutexCommuncationInterface != null]");

            CommunicationError errorCode = CommunicationError.UnknownError;
            try
            {
                m_MutexCommuncationInterface.WaitOne(DefaultMutexWaitDurationMs, false);
                errorCode = (CommunicationError)m_SendVariable(dictionaryIndex, dataType, data);
            }
            catch (Exception)
            {
                errorCode = CommunicationError.SystemException;
                throw new CommunicationException(Resources.EMSendVariableFailed, errorCode);
            }
            finally
            {
                m_MutexCommuncationInterface.ReleaseMutex();
            }

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

            if (DebugMode.Enabled == true)
            {
                DebugMode.SendVariable_t sendVariable = new DebugMode.SendVariable_t(dictionaryIndex, dataType, data, errorCode);
                DebugMode.Write(sendVariable.ToXML());
            }
        }