Exemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <example>
        /// <code>
        /// Communication comm = new Communication();
        /// </code>
        /// </example>
        /// Revision History
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 08/01/05 bdm 7.13.00 N/A	Created
        public SerialCommDesktop()
        {
            m_rmStrings = new ResourceManager(RESOURCE_FILE_PROJECT_STRINGS,
                                              this.GetType().Assembly);
            m_SerialPort               = new SerialPort();
            m_mtxRxBufBsy              = new Mutex();
            m_ReadEvent                = new ManualResetEvent(false);
            m_SerialPort.DataReceived += new SerialDataReceivedEventHandler(this.serialPort_DataReceived);

            m_OpticalProbe = OpticalProbeTypes.GENERIC_1_NO_DTR;

            m_Logger = Logger.TheInstance;

            if ((null == m_rmStrings) || (null == m_mtxRxBufBsy) ||
                (null == m_ReadEvent))
            {
                throw (new Exception("Error creating communication object."));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="strName">
        /// The identifier for the current test run. This is used to identify which probe the test is
        /// being run on and is for informational purposes.
        /// </param>
        /// <param name="strPort">The port to use for the test.</param>
        /// <param name="uiBaudRate">The baud rate to use for the test.</param>
        /// <param name="probeType">The optical probe type for the test.</param>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  08/28/09 RCG 2.30.00        Created

        public ValidationWorker(string strName, string strPort, uint uiBaudRate, OpticalProbeTypes probeType)
        {
            m_bCancelled   = false;
            m_strName      = strName;
            m_strResultDir = Settings.Default.ResultsDir + "\\";
            m_strPort      = strPort;
            m_uiBaudRate   = uiBaudRate;
            m_ProbeType    = probeType;

            m_Comm = new SerialCommDesktop();
            m_Comm.OpticalProbe = m_ProbeType;
            m_Comm.BaudRate     = m_uiBaudRate;

            m_strProgramFile         = Settings.Default.ProgramFile;
            m_strValidationTestsFile = CRegistryHelper.GetFilePath(REG_REPLICA) + TEST_FILE;

            if (Directory.Exists(m_strResultDir) == false)
            {
                Directory.CreateDirectory(m_strResultDir);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the optical probe type from the name of the optical probe.
        /// </summary>
        /// <param name="strOpticalProbeName">The name of the optical probe to get</param>
        /// <returns>The Optical probe type as an enum</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  11/03/09 RCG 2.30.16        Created

        public static OpticalProbeTypes GetOpticalProbeType(string strOpticalProbeName)
        {
            OpticalProbeTypes SelectedType = OpticalProbeTypes.GENERIC_1_NO_DTR;

            switch (strOpticalProbeName)
            {
            case PROBE_SLB:
            {
                SelectedType = OpticalProbeTypes.SCHLUMBERGER;
                break;
            }

            case PROBE_SLB_FRANCE:
            {
                SelectedType = OpticalProbeTypes.SCHLUMBERGER_FRANCE;
                break;
            }

            case PROBE_SLB_SPAIN:
            {
                SelectedType = OpticalProbeTypes.SCHLUMBERGER_SPAIN;
                break;
            }

            case PROBE_GE:
            {
                SelectedType = OpticalProbeTypes.GE_SMARTCOUPLER_SC1;
                break;
            }

            case PROBE_USM_300:
            {
                SelectedType = OpticalProbeTypes.US_MICROTEL_PM_300;
                break;
            }

            case PROBE_USM_500:
            {
                SelectedType = OpticalProbeTypes.US_MICROTEL_PM_500;
                break;
            }

            case PROBE_USM_600:
            {
                SelectedType = OpticalProbeTypes.US_MICROTEL_PM_600;
                break;
            }

            case PROBE_GENERIC_1:
            {
                SelectedType = OpticalProbeTypes.GENERIC_1_NO_DTR;
                break;
            }

            case PROBE_GENERIC_2:
            {
                SelectedType = OpticalProbeTypes.GENERIC_2_DTR;
                break;
            }
            }

            return(SelectedType);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Implements the IConfiguration interface.  Initializes the meter
        /// based on the given program name.
        /// </summary>
        /// <param name="strProgramName">The name of the program to use to
        /// initialize the meter</param>
        /// <returns>ConfigurationResult</returns>
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ -------------------------------------------
        // 01/17/07 jrf 8.00    N/A    Created
        // 01/25/07 jrf 8.00    N/A    Modifed to reflect changes to IntializeDevice(),
        //                             now pass in optical probe and not device ID
        // 02/21/07 jrf 8.00.13        Updating the name of the namespace and class
        //                             for calling initialize device.
        // 03/28/07 jrf 8.00.23 2748   Determine from replica setting the reset billing
        //                             registers on initialization option and pass in
        //                             call to DeviceWrapper.
        // 04/11/06 jrf 8.00.29 2891   We need to set the baud rate when logging
        //                              back on after initialization otherwise
        //                              logging on at 4800 baud will fail.
        //
        public ConfigurationResult Configure(string strProgramName)
        {
            ConfigurationResult InitResult = ConfigurationResult.ERROR;
            ItronDeviceResult   Result     = ItronDeviceResult.ERROR;

            //Save off current communication information
            string            strPortName  = m_SCSProtocol.m_CommPort.PortName;
            uint              uiPortNumber = 0;
            uint              uiBaudRate   = m_SCSProtocol.m_CommPort.BaudRate;
            OpticalProbeTypes OpticalProbe = m_SCSProtocol.m_CommPort.OpticalProbe;

            // Let the replica settings determine what we should do concerning
            // resetting billing registers
            CXMLFieldProSettings xmlFieldProSettings = new CXMLFieldProSettings("");;

            CXMLFieldProSettingsAllDevices.RESET_BILLING_REG_OPTIONS ResetBillingOption
                = xmlFieldProSettings.AllDevices.ResetBillingOnInit;

            //Before we logoff we need to get the security code, since it will
            //get cleared
            string strSecurityCode = m_strCurrentSecurityCode;

            //Convert the port name to port number
            string temp = strPortName.Remove(0, 3);

            temp         = temp.TrimEnd(':');
            uiPortNumber = Convert.ToUInt32(temp, CultureInfo.InvariantCulture);

            m_Logger.WriteLine(Logger.LoggingLevel.Functional, "Initializing Device");

            //Logoff the current device
            Logoff();

            //Close the port
            m_SCSProtocol.m_CommPort.ClosePort();

            try
            {
                //Initialize device
                InitResult = (ConfigurationResult)
                             Itron.Metering.DeviceWrapper.DeviceWrapper.InitializeDevice(strProgramName,
                                                                                         MeterType,
                                                                                         strSecurityCode,
                                                                                         uiPortNumber,
                                                                                         uiBaudRate,
                                                                                         OpticalProbe,
                                                                                         ResetBillingOption);
            }
            catch
            {
                InitResult = ConfigurationResult.ERROR;
            }

            switch (InitResult)
            {
            // For these errors, lets log back on so the user may continue
            case ConfigurationResult.MEMORY_ERROR:
            case ConfigurationResult.IO_ERROR:
            case ConfigurationResult.SECURITY_ERROR:
            case ConfigurationResult.UNSUPPORTED_FUNCTION:
            case ConfigurationResult.MISMATCH_ID:
            case ConfigurationResult.USER_ABORT:
            case ConfigurationResult.DB_ACCESS_ERROR:
            case ConfigurationResult.INVALID_CONFIG:
            case ConfigurationResult.MEMORY_MAP_ERROR:
            {
                //Need to do this so Logon will reissue Wakeup and Identify requests, otherwise
                //Security will fail.
                m_SCSProtocol.Identified = false;

                //Re-open the port
                m_SCSProtocol.m_CommPort.OpenPort(strPortName);

                //Set to the appropriate baud rate
                m_SCSProtocol.m_CommPort.BaudRate = uiBaudRate;

                if (MeterType == m_rmStrings.GetString("FULC_METER_NAME"))
                {
                    //Fulcrum needs a few seconds to itself before allowing a logon
                    //after a logoff
                    Thread.Sleep(4000);
                }

                //Re-Logon to the meter
                Result = Logon();

                if (ItronDeviceResult.SUCCESS == Result)
                {
                    //Issue Security
                    System.Collections.Generic.List <string> passwords = new System.Collections.Generic.List <string>();


                    //It should be cleared but just be be safe, clear out the current
                    //security code so we will issue the command.
                    m_strCurrentSecurityCode = null;
                    passwords.Add(strSecurityCode);

                    Result = Security(passwords);
                }

                if (ItronDeviceResult.SUCCESS != Result)
                {
                    //We were not successful in logging back on so throw a timeout
                    throw new TimeOutException();
                }

                break;
            }

            default:
            {
                // Do nothing. Remain Logged off
                break;
            }
            }

            return(InitResult);
        }