Пример #1
0
        /// <summary>
        /// Clears the SiteScan Diag counters
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00           Created
        //  09/19/14 jrf 4.00.63 WR 534158 Modified way the test details are set.
        private void ClearSiteScanDiagCounts()
        {
            ItronDeviceResult Result         = ItronDeviceResult.ERROR;
            ISiteScan         SiteScanDevice = m_AmiDevice as ISiteScan;
            bool   bSkipped   = SiteScanDevice == null;
            string strReason  = "";
            string strDetails = "";

            if (IsAborted == false)
            {
                if (bSkipped == false)
                {
                    Result     = SiteScanDevice.ResetDiagCounters();
                    strReason  = DetermineReason(Result);
                    strDetails = GetClearDetails(Result == ItronDeviceResult.SUCCESS);
                }
                else
                {
                    strReason  = TestResources.ReasonSiteScanNotSupported;
                    strDetails = TestResources.ReasonSiteScanNotSupported;
                }

                AddTestDetail(TestResources.ClearSiteScanDiagnosticCounts,
                              GetResultString(bSkipped, Result == ItronDeviceResult.SUCCESS),
                              strDetails,
                              strReason);
            }
        }
Пример #2
0
        /// <summary>
        /// This method a 4 byte floating point BCD value from an SCS device.
        /// </summary>
        /// <exception cref="SCSException">
        /// Thrown when the value cannot be retreived from the meter.
        /// </exception>
        /// <remarks >
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 01/26/07 KRC 8.00.09        Adding Edit Registers
        /// </remarks>
        virtual internal ItronDeviceResult SetFloatingBCDValue(int nBasepageAddress, int nLength, string strValue)
        {
            ItronDeviceResult Result = ItronDeviceResult.SUCCESS;

            byte[] byBCDValue;
            double dblValue;

            // Get the double out of the string (This allows us to format the value as needed when doing the conversion)
            dblValue   = double.Parse(strValue, CultureInfo.CurrentCulture);
            byBCDValue = BCD.DoubleToFloatingBCD(dblValue, nLength);

            // Now that we have the byte array, we can send it to the meter.
            SCSProtocolResponse ProtocolResponse = m_SCSProtocol.Download(nBasepageAddress, nLength, ref byBCDValue);

            if (SCSProtocolResponse.SCS_CAN == ProtocolResponse)
            {
                Result = ItronDeviceResult.SECURITY_ERROR;
            }
            else if (SCSProtocolResponse.SCS_NAK == ProtocolResponse)
            {
                Result = ItronDeviceResult.ERROR;
            }


            return(Result);
        }
Пример #3
0
        /// <summary>
        /// This method sets the RFLAN utility ID without writing to mfg. table 13 and
        /// causing a 3-button reset.
        /// </summary>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  07/10/13 jrf 2.71.01 417021 Created
        //
        public ItronDeviceResult SetRFLANUtilityID(byte byUtilityID)
        {
            ItronDeviceResult Result = ItronDeviceResult.ERROR;
            bool blnUtilityIDSet     = false;

            //Either or both mfg. table 65/73 must be updated
            if (null != Table2113)
            {
                Table2113.UtilityID = byUtilityID;
                blnUtilityIDSet     = true;
            }

            if (null != Table2121)
            {
                Table2121.UtilityID = byUtilityID;
                blnUtilityIDSet     = true;
            }

            //Utility ID portion of native address must be updated.
            if (null != Table122)
            {
                Table122.UtilityID = byUtilityID;
            }
            else
            {
                blnUtilityIDSet = false;
            }

            if (true == blnUtilityIDSet)
            {
                Result = m_AMIDevice.ResetRFLAN();
            }

            return(Result);
        }
Пример #4
0
        /// <summary>
        /// Clears the demand reset count
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00           Created
        //  09/19/14 jrf 4.00.63 WR 534158 Modified way the test details are set.
        private void ClearDemandResetCount()
        {
            ItronDeviceResult Result = m_AmiDevice.ResetNumberDemandResets();

            if (IsAborted == false)
            {
                AddTestDetail(TestResources.ClearDemandResetCount,
                              GetResultString(Result == ItronDeviceResult.SUCCESS),
                              GetClearDetails(Result == ItronDeviceResult.SUCCESS),
                              DetermineReason(Result));
            }
        }
Пример #5
0
        /// <summary>
        /// Writes a Cum Value to the meter
        /// </summary>
        /// <param name="device">Device we are talking to</param>
        /// <param name="strValue">The value to set into the meter</param>
        /// <returns>ItronDeviceResult</returns>
        /// <remarks >
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 01/30/07 KRC 8.09.00  N/A   Getting Edit Registers working
        /// </remarks>
        protected ItronDeviceResult SetCumulativeValue(ref SCSDevice device, string strValue)
        {
            ItronDeviceResult Result = ItronDeviceResult.SUCCESS;

            if (RegisterType == 0x00 || RegisterType == 0x02 || RegisterType == 0x03)
            {
                Result = device.SetFloatingBCDValue(device.TranslateDisplayAddress(this), 4, strValue);
            }
            else if (RegisterType == 0x07)
            {
                Result = device.SetFloatingBCDValue(device.TranslateDisplayAddress(this), 3, strValue);
            }

            return(Result);
        }
Пример #6
0
        /// <summary>
        /// Writes an Energy Value to the meter
        /// </summary>
        /// <param name="device">Device we are talking to</param>
        /// <param name="strValue">The value to set into the meter</param>
        /// <returns>ItronDeviceResult</returns>
        /// <remarks >
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 01/30/07 KRC 8.09.00  N/A   Getting Edit Registers working
        /// </remarks>
        protected ItronDeviceResult SetEnergyValue(ref SCSDevice device, string strValue)
        {
            ItronDeviceResult Result = ItronDeviceResult.SUCCESS;

            if (RegisterType == 0x00 || RegisterType == 0x02 || RegisterType == 0x03)
            {
                Result = device.SetFixedBCDValue(device.TranslateDisplayAddress(this), 4, 7, strValue);
            }
            else
            {
                Result = ItronDeviceResult.ERROR;
            }

            return(Result);
        }
Пример #7
0
        /// <summary>
        /// Writes a new values to the meter for registers that appear on the display.
        /// </summary>
        /// <param name="device"></param>
        /// <returns>ItronDeviceResult</returns>
        public ItronDeviceResult WriteNewValue(SCSDevice device)
        {
            ItronDeviceResult Result = ItronDeviceResult.SUCCESS;

            if (true == Editable)
            {
                // The value is editable so there may be a value.  If the value is null or empty then don't bother
                if (null != Value && "" != Value)
                {
                    Result = SetDisplayItemValue(ref device);
                }
            }

            return(Result);
        }
Пример #8
0
        /// <summary>
        /// Writes a Cum Value to the meter
        /// </summary>
        /// <param name="device">Device we are talking to</param>
        /// <param name="strValue">The value to set into the meter</param>
        /// <returns>ItronDeviceResult</returns>
        /// <remarks >
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 01/31/07 KRC 8.00.10  N/A   Getting Edit Registers working
        /// </remarks>
        override protected ItronDeviceResult SetCCumValue(ref SCSDevice device, string strValue)
        {
            ItronDeviceResult Result = ItronDeviceResult.SUCCESS;

            if (RegisterType == 0) // current season
            {
                Result = device.SetFloatingBCDValue(device.TranslateDisplayAddress(this), 4, strValue);
            }
            else if (RegisterType == 7) // last season
            {
                Result = device.SetFloatingBCDValue(device.TranslateDisplayAddress(this), 3, strValue);
            }

            return(Result);
        }
Пример #9
0
        /// <summary>
        /// SetDisplayvalue - Determines the type of register this display item is
        ///                     and writes the updated value to the meter.
        /// </summary>
        /// <param name="device"></param>
        /// <returns>ItronDeviceResult</returns>
        /// <remarks >
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 01/30/07 KRC 8.09.00  N/A   Supporting Edit Registers
        /// </remarks>
        private ItronDeviceResult SetDisplayItemValue(ref SCSDevice device)
        {
            ItronDeviceResult Result = ItronDeviceResult.SUCCESS;

            switch (RegisterClass)
            {
            case SCSDisplayClass.EnergyValue:
            {
                if (device.EnergyFormat.Units == SCSDisplayFormat.DisplayUnits.Units)
                {
                    m_strValue = MoveDecimalToTheLeft(m_strValue, 3, device.EnergyFormat.NumDecimalDIgits);
                }
                Result = SetEnergyValue(ref device, m_strValue);

                break;
            }

            case SCSDisplayClass.MaxDemandValue:
            {
                if (device.DemandFormat.Units == SCSDisplayFormat.DisplayUnits.Units)
                {
                    m_strValue = MoveDecimalToTheLeft(m_strValue, 3, device.DemandFormat.NumDecimalDIgits);
                }
                Result = SetMaxDemandValue(ref device, m_strValue);

                break;
            }

            case SCSDisplayClass.CumulativeValue:
            case SCSDisplayClass.TotalContinuousCumulativeValue:
            case SCSDisplayClass.TOUContinuousCumulativeValue:
            {
                if (device.CumulativeFormat.Units == SCSDisplayFormat.DisplayUnits.Units)
                {
                    m_strValue = MoveDecimalToTheLeft(m_strValue, 3, device.CumulativeFormat.NumDecimalDIgits);
                }
                Result = SetCumulativeValue(ref device, m_strValue);
                break;
            }

            default:
                // We need to investigate why this got called.
                Result = ItronDeviceResult.UNSUPPORTED_OPERATION;
                break;
            }

            return(Result);
        }
Пример #10
0
        /// <summary>
        /// Sets the cell switch parameter selection in the expansion control bits of mfg table 73.
        /// We want to set bits 4 and 5 in the expansion control bits byte and leave the rest of the
        /// bits unchanged.  Of the 4 possible combinations, only 2 and 3 should be allowed.  Other
        /// values have not been tested.
        /// Hysteresis=400;Level=0;GPD=0;CSI=128 (00)
        /// Hysteresis=500;Level=64;GPD=1;CSI=128 (01)
        /// Hysteresis=400;Level=64;GPD=1;CSI=128 (10)
        /// Hysteresis=400;Level=0;GPD=1;CSI=128 (11)
        /// </summary>
        /// <param name="byCellSwitchParamByte">cell switch parameter value. Only 2 and 3 are allowed</param>
        /// <returns></returns>
        //  Revision History
        //  MM/DD/YY Who Version ID Issue# Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  06/30/14 AF  3.51.01 WR 518450 Created
        //
        public ItronDeviceResult SetRFLANLevel(byte byCellSwitchParamByte)
        {
            ItronDeviceResult Result        = ItronDeviceResult.ERROR;
            byte byExpansionControlBitsMask = 0xCF; // 11001111
            byte byExpansionControlBits     = 0;

            if (null != Table2121)
            {
                byExpansionControlBits  = Table2121.ExpansionControlBits;
                byExpansionControlBits &= byExpansionControlBitsMask;         // Clear out the cell switch parameter selection
                byExpansionControlBits |= (byte)(byCellSwitchParamByte << 4); // Replace the cell switch parameter selection with the desired value

                Table2121.ExpansionControlBits = byExpansionControlBits;

                Result = m_AMIDevice.ResetRFLAN();
            }

            return(Result);
        }
Пример #11
0
        /// <summary>
        /// Determines the reason for a failure
        /// </summary>
        /// <param name="result">The result</param>
        /// <returns>The reason for the failure</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00        Created

        protected string DetermineReason(ItronDeviceResult result)
        {
            string strResult = "";

            switch (result)
            {
            case ItronDeviceResult.SECURITY_ERROR:
            {
                strResult = TestResources.ReasonSecurityError;
                break;
            }

            case ItronDeviceResult.UNSUPPORTED_OPERATION:
            {
                strResult = TestResources.ReasonOperationNotSupported;
                break;
            }
            }

            return(strResult);
        }
Пример #12
0
        /// <summary>
        /// Clears the sitescan snapshots in the meter.  This is not supported by
        /// the Vectron.
        /// </summary>
        /// <returns>A ItronDeviceResult</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------------
        //  02/21/07 mrj 8.00.13		Created
        //
        ItronDeviceResult ISiteScan.ClearSiteScanSnapshots()
        {
            ItronDeviceResult    Result     = ItronDeviceResult.SUCCESS;
            ProcedureResultCodes ProcResult = ProcedureResultCodes.INVALID_PARAM;

            byte[] ProcParam;
            byte[] ProcResponse;

            ProcParam  = new byte[0];             // No parameters for this procedure
            ProcResult = ExecuteProcedure(Procedures.CLEAR_SITESCAN_SNAPSHOTS,
                                          ProcParam, out ProcResponse);

            switch (ProcResult)
            {
            case ProcedureResultCodes.COMPLETED:
            {
                //Success
                Result = ItronDeviceResult.SUCCESS;
                break;
            }

            case ProcedureResultCodes.NO_AUTHORIZATION:
            {
                //Isc error
                Result = ItronDeviceResult.SECURITY_ERROR;
                break;
            }

            default:
            {
                //General Error
                Result = ItronDeviceResult.ERROR;
                break;
            }
            }

            return(Result);
        }
Пример #13
0
        /// <summary>
        /// Implements the ISiteScan interface.  Resets the diagnostic counters
        /// </summary>
        /// Revision History
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 05/24/06 mrj 7.30.00 N/A    Created
        ///
        ItronDeviceResult ISiteScan.ResetDiagCounters()
        {
            ItronDeviceResult Result = ItronDeviceResult.ERROR;

            byte[] ProcResponse;
            ProcedureResultCodes ProcResult = ProcedureResultCodes.INVALID_PARAM;


            //Execute the reset conters MFG procedure
            byte[] byParameter = BitConverter.GetBytes((uint)Reset_Counter_Types.RESET_NUM_DIAG_COUNTERS);
            ProcResult = ExecuteProcedure(Procedures.RESET_COUNTERS, byParameter, out ProcResponse);

            switch (ProcResult)
            {
            case ProcedureResultCodes.COMPLETED:
            {
                //Success
                Result = ItronDeviceResult.SUCCESS;
                break;
            }

            case ProcedureResultCodes.NO_AUTHORIZATION:
            {
                //Isc error
                Result = ItronDeviceResult.SECURITY_ERROR;
                break;
            }

            default:
            {
                //General Error
                Result = ItronDeviceResult.ERROR;
                break;
            }
            }

            return(Result);
        }
Пример #14
0
        /// <summary>
        /// This method sets a continuous cummulative demand value to the meter
        ///
        /// </summary>
        /// <returns></returns>
        /// <remarks >
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 01/31/07 KRC 8.00.10  N/A   Support for Edit Registers
        /// </remarks>
        virtual protected ItronDeviceResult SetCCumValue(ref SCSDevice device, string strValue)
        {
            ItronDeviceResult Result = ItronDeviceResult.SUCCESS;

            return(Result);
        }
Пример #15
0
        /// <summary>
        /// This method updates the IO configuration in the meter.
        /// </summary>
        /// <param name="IOConfig">KYZ configuration data object.</param>
        /// <returns>The result of the configuration.</returns>
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ ---------------------------------------
        // 04/22/09 jrf 2.20.02 n/a	   Created
        // 04/19/10 AF  2.40.39        Made virtual for M2 Gateway override
        // 07/08/10 jrf 2.42.02 157552 Setting the CPC reset bit on close config to fix
        //                             LED lock issue.
        //
        public virtual ItronDeviceResult ConfigureIO(KYZData IOConfig)
        {
            byte[] ProcParam = new byte[0];
            byte[] ProcResponse;
            ProcedureResultCodes ProcResult =
                ProcedureResultCodes.INVALID_PARAM;
            PSEMResponse Result = PSEMResponse.Err;

            ItronDeviceResult    ConfigResult = ItronDeviceResult.ERROR;
            CTable2048_OpenWay   OW2048       = Table2048 as CTable2048_OpenWay;
            CENTRON_AMI_IOConfig IOTable      = OW2048.IOConfig as CENTRON_AMI_IOConfig;

            // Open the Config
            ProcResult = ExecuteProcedure(Procedures.OPEN_CONFIG_FILE, ProcParam, out ProcResponse);

            // Execute Write of IO Table in 2048
            if (ProcedureResultCodes.COMPLETED == ProcResult)
            {
                IOTable.IOData = IOConfig;
                Result         = IOTable.Write();
            }
            else if (ProcedureResultCodes.NO_AUTHORIZATION == ProcResult)
            {
                Result = PSEMResponse.Isc;
            }
            else
            {
                m_Logger.WriteLine(Logger.LoggingLevel.Detailed,
                                   "Open config procedure failed with result = " +
                                   ProcResult);
                Result = PSEMResponse.Err;
            }

            if (Result == PSEMResponse.Ok)
            {
                // Close the Config
                // Data reset bits - we don't want to reset any data, so
                // just initialize them to 0
                ProcParam = new byte[4];
                ProcParam.Initialize();

                // Okay we do want to reset data if we are a HW2.0 Poly.  Need to do this to
                // prevent the worm on the display from freezing.
                if (0 == VersionChecker.CompareTo(HWRevisionFiltered, HW_VERSION_2_5) ||
                    0 == VersionChecker.CompareTo(HWRevisionFiltered, HW_VERSION_2_6))
                {
                    //We need to reset CPC
                    MemoryStream ParamStream = new MemoryStream(ProcParam);
                    BinaryWriter BinWriter   = new BinaryWriter(ParamStream);

                    BinWriter.Write((uint)CloseConfigOptions.CPC);
                }

                ProcResult = ExecuteProcedure(Procedures.CLOSE_CONFIG_FILE, ProcParam, out ProcResponse);

                if (ProcedureResultCodes.COMPLETED != ProcResult)
                {
                    ConfigResult = ItronDeviceResult.ERROR;
                }
                else
                {
                    ConfigResult = ItronDeviceResult.SUCCESS;
                }
            }
            else
            {
                if (Result == PSEMResponse.Isc)
                {
                    ConfigResult = ItronDeviceResult.SECURITY_ERROR;
                }
                else
                {
                    ConfigResult = ItronDeviceResult.ERROR;
                }
            }

            return(ConfigResult);
        }
Пример #16
0
        /// <summary>
        /// This method executes the enter/exit test mode.
        /// </summary>
        /// <param name="modeType">TestMode Type</param>
        /// <param name="timeInTestMode">time for the meter to remain in test minutes</param>
        /// <param name="pulseWeight">actual test mode kh</param>
        /// /// <param name="pulseQuantity">Quantity to be measured in test mode</param>
        /// <returns>The result of the test mode operation.</returns>
        // MM/DD/YY who Version Issue#   Description
        // -------- --- ------- -------- ---------------------------------------
        // 06/23/17 CFB 4.72.02 WR767058 Created
        //
        public virtual ItronDeviceResult EnterExitTestMode(TestMode modeType, byte timeInTestMode, float pulseWeight, uint pulseQuantity)
        {
            ItronDeviceResult    Result     = ItronDeviceResult.ERROR;
            ProcedureResultCodes ProcResult = ProcedureResultCodes.INVALID_PARAM;

            byte[] ProcParam = new byte[8];
            OpenWayMFGTable2170 Table2170 = new OpenWayMFGTable2170(m_PSEM, Table00);

            byte[]           ProcResponse;
            PSEMBinaryWriter PSEMWriter      = new PSEMBinaryWriter(new MemoryStream(ProcParam));
            bool             blnWaitResponse = true;
            int iSeconds = 0;
            //Pulse Weight Test value should be in increments of 0.025 so multiply by 40
            float fPulseWeightParam = pulseWeight * 40;

            PSEMWriter.Write((byte)modeType);
            PSEMWriter.Write(timeInTestMode);
            PSEMWriter.Write(pulseQuantity);
            PSEMWriter.Write((ushort)fPulseWeightParam);

            ProcResult = ExecuteProcedure(Procedures.ENTER_EXIT_TEST_MODE, ProcParam, out ProcResponse);

            if (ProcedureResultCodes.COMPLETED == ProcResult)
            {
                if (TestMode.ENTER_TEST_MODE == modeType)
                {
                    //If we are entering test mode then we will wait
                    //while IsInTestMode property is false.
                    blnWaitResponse = false;
                }

                while (blnWaitResponse == IsInTestMode && 5 > iSeconds)
                {
                    //Check mode every 1 sec. for 5 sec.
                    System.Threading.Thread.Sleep(1000);
                    iSeconds += 1;
                }
            }

            switch (ProcResult)
            {
            case ProcedureResultCodes.COMPLETED:
            {
                //Success
                Result = ItronDeviceResult.SUCCESS;
                break;
            }

            case ProcedureResultCodes.NO_AUTHORIZATION:
            {
                //Isc error
                Result = ItronDeviceResult.SECURITY_ERROR;
                break;
            }

            default:
            {
                //General Error
                Result = ItronDeviceResult.ERROR;
                break;
            }
            }

            return(Result);
        }
Пример #17
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);
        }
Пример #18
0
        /// <summary>
        /// Implements the ISiteScan interface.  Resets the diagnostic counters
        /// </summary>
        /// <exception cref="SCSException">
        /// Thrown when the diagnostic counters cannot be reset in the meter.
        /// </exception>
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 04/27/06 mrj 7.30.00  N/A   Created
        /// 05/26/06 jrf 7.30.00  N/A   Modified
        ///
        ItronDeviceResult ISiteScan.ResetDiagCounters()
        {
            ItronDeviceResult Result = ItronDeviceResult.SUCCESS;

            byte[] byDiagnostic1To4Counters =
                new byte[VEC_DIAGNOSTIC_1_TO_4_COUNTS_LENGTH];
            byte[] byDiagnostic5Counters =
                new byte[VEC_DIAGNOSTIC_5_COUNTS_LENGTH];
            SCSProtocolResponse ProtocolResponse = SCSProtocolResponse.NoResponse;
            int iExceptionAddress = (int)VECAddresses.DIAGNOSTICS_COUNTS;

            m_Logger.WriteLine(
                Logger.LoggingLevel.Functional,
                "Starting Reset Diagnositc Counters");

            // Prepare arrays to reset all diagnostic counters
            byDiagnostic1To4Counters.Initialize();
            byDiagnostic5Counters.Initialize();

            m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Reset Diagnostic Counters 1-4");
            // Reset diagnostic 1 to 4 counters
            ProtocolResponse = m_SCSProtocol.Download(
                (int)VECAddresses.DIAGNOSTICS_COUNTS,
                VEC_DIAGNOSTIC_1_TO_4_COUNTS_LENGTH,
                ref byDiagnostic1To4Counters);

            if (SCSProtocolResponse.SCS_ACK == ProtocolResponse)
            {
                m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Reset Diagnostic 5 Counters");
                // Reset diagnostic 5 counters
                ProtocolResponse = m_SCSProtocol.Download(
                    (int)VECAddresses.DIAGNOSTIC_5_COUNTS,
                    VEC_DIAGNOSTIC_5_COUNTS_LENGTH,
                    ref byDiagnostic5Counters);
                iExceptionAddress = (int)VECAddresses.DIAGNOSTIC_5_COUNTS;
            }

            if (SCSProtocolResponse.SCS_ACK == ProtocolResponse)
            {
                Result = ItronDeviceResult.SUCCESS;
            }
            else if (SCSProtocolResponse.SCS_CAN == ProtocolResponse)
            {
                Result = ItronDeviceResult.ERROR;
            }
            else if (SCSProtocolResponse.NoResponse == ProtocolResponse)
            {
                Result = ItronDeviceResult.ERROR;
            }
            else
            {
                SCSException objSCSException = new SCSException(
                    SCSCommands.SCS_U,
                    ProtocolResponse,
                    iExceptionAddress,
                    m_rmStrings.GetString("RESET_DIAG"));
                throw objSCSException;
            }

            return(Result);
        } //End ISiteScan.ResetDiagCounters()