ekmmeters.py
def setCTRatio(self, new_ct, password="00000000"):
        """ Serial call to set CT ratio for attached inductive pickup.

        Args:
            new_ct (int): A :class:`~ekmmeters.CTRatio` value, a legal amperage setting.
            password (str): Optional password.

        Returns:
            bool: True on completion with ACK.
        """
        ret = False
        self.setContext("setCTRatio")
        try:
            self.clearCmdMsg()
            if ((new_ct != CTRatio.Amps_100) and (new_ct != CTRatio.Amps_200) and
                    (new_ct != CTRatio.Amps_400) and (new_ct != CTRatio.Amps_600) and
                    (new_ct != CTRatio.Amps_800) and (new_ct != CTRatio.Amps_1000) and
                    (new_ct != CTRatio.Amps_1200) and (new_ct != CTRatio.Amps_1500) and
                    (new_ct != CTRatio.Amps_2000) and (new_ct != CTRatio.Amps_3000) and
                    (new_ct != CTRatio.Amps_4000) and (new_ct != CTRatio.Amps_5000)):
                self.writeCmdMsg("Legal CT Ratios: 100, 200, 400, 600, " +
                                 "800, 1000, 1200, 1500, 2000, 3000, 4000 and 5000")
                self.setContext("")
                return ret

            if len(password) != 8:
                self.writeCmdMsg("Invalid password length.")
                self.setContext("")
                return ret

            if not self.request(False):
                self.writeCmdMsg("Bad read CRC on setting")
            else:
                if not self.serialCmdPwdAuth(password):
                    self.writeCmdMsg("Password failure")
                else:
                    req_str = "015731023030443028" + binascii.hexlify(str(new_ct).zfill(4)) + "2903"
                    req_str += self.calc_crc16(req_str[2:].decode("hex"))
                    self.m_serial_port.write(req_str.decode("hex"))
                    if self.m_serial_port.getResponse(self.getContext()).encode("hex") == "06":
                        self.writeCmdMsg("Success(setCTRatio): 06 returned.")
                        ret = True
            self.serialPostEnd()

        except:
            ekm_log(traceback.format_exc(sys.exc_info()))

        self.setContext("")
        return ret
def setCTRatio(self, new_ct, password="00000000"):
        ret = False
        self.setContext("setCTRatio")
        try:
            self.clearCmdMsg()
            if ((new_ct != CTRatio.Amps_100) and (new_ct != CTRatio.Amps_200) and
                    (new_ct != CTRatio.Amps_400) and (new_ct != CTRatio.Amps_600) and
                    (new_ct != CTRatio.Amps_800) and (new_ct != CTRatio.Amps_1000) and
                    (new_ct != CTRatio.Amps_1200) and (new_ct != CTRatio.Amps_1500) and
                    (new_ct != CTRatio.Amps_2000) and (new_ct != CTRatio.Amps_3000) and
                    (new_ct != CTRatio.Amps_4000) and (new_ct != CTRatio.Amps_5000)):
                self.writeCmdMsg("Legal CT Ratios: 100, 200, 400, 600, " +
                                 "800, 1000, 1200, 1500, 2000, 3000, 4000 and 5000")
                self.setContext("")
                return ret

            if len(password) != 8:
                self.writeCmdMsg("Invalid password length.")
                self.setContext("")
                return ret

            if not self.request(False):
                self.writeCmdMsg("Bad read CRC on setting")
            else:
                if not self.serialCmdPwdAuth(password):
                    self.writeCmdMsg("Password failure")
                else:
                    req_str = "015731023030443028" + binascii.hexlify(str(new_ct).zfill(4)) + "2903"
                    req_str += self.calc_crc16(req_str[2:].decode("hex"))
                    self.m_serial_port.write(req_str.decode("hex"))
                    if self.m_serial_port.getResponse(self.getContext()).encode("hex") == "06":
                        self.writeCmdMsg("Success(setCTRatio): 06 returned.")
                        ret = True
            self.serialPostEnd()

        except:
            ekm_log(traceback.format_exc(sys.exc_info()))

        self.setContext("")
        return ret
def setCTRatio ( self , new_ct , password = "00000000" ) : ret = False self . setContext ( "setCTRatio" ) try : self . clearCmdMsg ( ) if ( ( new_ct != CTRatio . Amps_100 ) and ( new_ct != CTRatio . Amps_200 ) and ( new_ct != CTRatio . Amps_400 ) and ( new_ct != CTRatio . Amps_600 ) and ( new_ct != CTRatio . Amps_800 ) and ( new_ct != CTRatio . Amps_1000 ) and ( new_ct != CTRatio . Amps_1200 ) and ( new_ct != CTRatio . Amps_1500 ) and ( new_ct != CTRatio . Amps_2000 ) and ( new_ct != CTRatio . Amps_3000 ) and ( new_ct != CTRatio . Amps_4000 ) and ( new_ct != CTRatio . Amps_5000 ) ) : self . writeCmdMsg ( "Legal CT Ratios: 100, 200, 400, 600, " + "800, 1000, 1200, 1500, 2000, 3000, 4000 and 5000" ) self . setContext ( "" ) return ret if len ( password ) != 8 : self . writeCmdMsg ( "Invalid password length." ) self . setContext ( "" ) return ret if not self . request ( False ) : self . writeCmdMsg ( "Bad read CRC on setting" ) else : if not self . serialCmdPwdAuth ( password ) : self . writeCmdMsg ( "Password failure" ) else : req_str = "015731023030443028" + binascii . hexlify ( str ( new_ct ) . zfill ( 4 ) ) + "2903" req_str += self . calc_crc16 ( req_str [ 2 : ] . decode ( "hex" ) ) self . m_serial_port . write ( req_str . decode ( "hex" ) ) if self . m_serial_port . getResponse ( self . getContext ( ) ) . encode ( "hex" ) == "06" : self . writeCmdMsg ( "Success(setCTRatio): 06 returned." ) ret = True self . serialPostEnd ( ) except : ekm_log ( traceback . format_exc ( sys . exc_info ( ) ) ) self . setContext ( "" ) return ret
Serial call to set CT ratio for attached inductive pickup.

        Args:
            new_ct (int): A :class:`~ekmmeters.CTRatio` value, a legal amperage setting.
            password (str): Optional password.

        Returns:
            bool: True on completion with ACK.
Serial call to set CT ratio for attached inductive pickup .