Esempio n. 1
0
        public void SyncWith(TCDSimulator simulator)
        {
            // Update HoursOfOperation.
            double hoursOfOperation = simulator.GetHoursOfOperation();

            if (!(m_hoursOfOperation.Value is double) || (double)m_hoursOfOperation.Value != hoursOfOperation)
            {
                m_hoursOfOperation.Value = hoursOfOperation;
                m_hoursOfOperation.UpdateChangeMasks(NodeStateChangeMasks.Value);
            }

            // Update DeviceMappingNumber.
            if (m_deviceMappingNumber.Value != simulator.DeviceMappingNumber)
            {
                m_deviceMappingNumber.Value = simulator.DeviceMappingNumber;
                m_deviceMappingNumber.UpdateChangeMasks(NodeStateChangeMasks.Value);
            }

            // Update OperatingMode.
            if (!String.Equals(m_operatingMode.Value, simulator.GetOperatingMode()))
            {
                m_operatingMode.Value = simulator.GetOperatingMode();
                m_operatingMode.UpdateChangeMasks(NodeStateChangeMasks.Value);
            }

            // If the SwitchOn method has been invoked replace the generated method state with
            // one that will switch on this TCD.
            if (!(m_switchOnMethod is SwitchOnMethodState))
            {
                SwitchOnMethodState method = new SwitchOnMethodState(m_switchOnMethod);
                method.setSimulator(simulator);
                m_switchOnMethod = method;
            }

            // If the SwitchOff method has been invoked replace the generated method state with
            // one that will switch off this TCD.
            if (!(m_switchOffMethod is SwitchOffMethodState))
            {
                SwitchOffMethodState method = new SwitchOffMethodState(m_switchOffMethod);
                method.setSimulator(simulator);
                m_switchOffMethod = method;
            }

            // If the ResetAllErrors method has been invoked, then replace the generated
            // method state with one that will reset errors for this TCD.
            if (!(m_resetAllErrorsMethod is ResetAllErrorsMethodState))
            {
                ResetAllErrorsMethodState method = new ResetAllErrorsMethodState(m_resetAllErrorsMethod);
                method.setSimulator(simulator);
                m_resetAllErrorsMethod = method;
            }

            // Update ActiveErrors.
            if (m_activeErrors.Value == null || simulator.HasActiveErrorsChanged())
            {
                m_activeErrors.Value = simulator.GetActiveErrors();
                m_highestActiveAlarmSeverity.Value = 0;
                for (int errorIndex = 0; errorIndex < m_activeErrors.Value.Length; errorIndex++)
                {
                    if (m_activeErrors.Value[errorIndex].Severity > m_highestActiveAlarmSeverity.Value)
                    {
                        m_highestActiveAlarmSeverity.Value = m_activeErrors.Value[errorIndex].Severity;
                    }
                }
                m_activeErrors.UpdateChangeMasks(NodeStateChangeMasks.Value);
                m_highestActiveAlarmSeverity.UpdateChangeMasks(NodeStateChangeMasks.Value);
            }
        }