Esempio n. 1
0
        /// <summary>
        /// Creates a new device object
        /// </summary>
        /// <param name="psem">The current PSEM object</param>
        /// <param name="key">Signed authorization security key</param>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00        Created
        //  02/17/11 RCG 2.50.04        Adding Support for ITRD, ITRE, ITRF meters
        //  03/22/11 jrf 2.80.10        Adding support for creating new ITRJ device object.
        //  12/04/13 jrf 3.50.13        Moved logic to create device into CANSIDevice.CreateDevice(...).
        //  10/31/14 jrf 4.00.82  WR 542694 Added support for identifying Bridge meter with signed authorizaion.
        protected CENTRON_AMI CreateDevice(CPSEM psem, SignedAuthorizationKey key)
        {
            CENTRON_AMI CreatedDevice = CANSIDevice.CreateDevice(m_Comm, psem, key) as CENTRON_AMI;

            if (null == CreatedDevice)
            {
                throw new InvalidOperationException(TestResources.MeterTypeNotSupported);
            }

            return(CreatedDevice);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the device information from the meter.
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  08/28/09 RCG 2.30.00           Created
        //  09/19/14 jrf 4.00.63 WR 534158 Modified to use the CANSIDevice.CreateDevice()
        //                                 method to instantiate the correct device and switched
        //                                 to store the name of the meter instead of device class.
        //  10/31/14 jrf 4.00.82  WR 542694 Added support for identifying Bridge meter with signed authorizaion.
        private TestRun GetDeviceInfo()
        {
            CXMLOpenWaySystemSettings SystemSettings = new CXMLOpenWaySystemSettings("");
            CPSEM        PSEM       = new CPSEM(m_Comm);
            PSEMResponse Response   = PSEMResponse.Ok;
            string       strModel   = null;
            TestRun      NewTestRun = new TestRun();
            string       MeterType  = "";

            Response = PSEM.Identify();

            if (Response == PSEMResponse.Ok)
            {
                Response = PSEM.Negotiate(CPSEM.DEFAULT_MAX_PACKET_LEGNTH,
                                          CPSEM.DEFAULT_MAX_NUMBER_OF_PACKETS, m_uiBaudRate);
            }

            if (Response == PSEMResponse.Ok)
            {
                Response = PSEM.Logon("", CPSEM.DEFAULT_HH_PRO_USER_ID);
            }

            if (Response == PSEMResponse.Ok)
            {
                CTable00 Table0 = new CTable00(PSEM);
                CTable01 Table1 = new CTable01(PSEM, Table0.StdVersion);
                strModel = Table1.Model;

                if (strModel == AMI_CENT)
                {
                    CANSIDevice ANSIDevice = CANSIDevice.CreateDevice(m_Comm, PSEM, Settings.Default.AuthenticationKey);
                    CENTRON_AMI AMIDevice  = ANSIDevice as CENTRON_AMI;

                    if (null != AMIDevice)
                    {
                        if (SystemSettings.UseSignedAuthorization && AMIDevice.SignedAuthorizationState != null &&
                            AMIDevice.SignedAuthorizationState.Value != FeatureState.Disabled &&
                            Settings.Default.AuthenticationKey != null)
                        {
                            // Use Signed Authenticaiton
                            AMIDevice.Authenticate(Settings.Default.AuthenticationKey);
                        }
                        else
                        {
                            // Use standard security
                            AMIDevice.Security(GetPasswords());
                        }

                        MeterType = AMIDevice.MeterName;

                        if (AMIDevice.CommModule != null)
                        {
                            m_strMeterID = AMIDevice.CommModule.ElectronicSerialNumber;
                        }
                    }
                }
            }

            try
            {
                PSEM.Logoff();
                PSEM.Terminate();
            }
            catch (Exception)
            {
                // Make sure we log off.
            }

            // Handle any errors that may have occurred
            if (Response != PSEMResponse.Ok)
            {
                throw new PSEMException(PSEMException.PSEMCommands.PSEM_READ, Response, Resources.ErrorRetrievingDeviceIdentification);
            }
            else if (strModel != AMI_CENT)
            {
                throw new InvalidOperationException(Resources.MeterTypeNotSupported);
            }

            // Set up the TestRun results
            NewTestRun.MeterType   = MeterType;
            NewTestRun.MeterID     = m_strMeterID;
            NewTestRun.TestDate    = DateTime.Now;
            NewTestRun.ProgramName = m_strProgramFile;
            NewTestRun.SWVersion   = Application.ProductVersion;

            return(NewTestRun);
        }