<s> """<STR_LIT>""" <EOL> import sys <EOL> from bacpypes . debugging import bacpypes_debugging , ModuleLogger <EOL> from bacpypes . consolelogging import ConfigArgumentParser <EOL> from bacpypes . consolecmd import ConsoleCmd <EOL> from bacpypes . core import run <EOL> from bacpypes . pdu import Address <EOL> from bacpypes . app import LocalDeviceObject , BIPSimpleApplication <EOL> from bacpypes . object import get_object_class , get_datatype <EOL> from bacpypes . apdu import ReadPropertyMultipleRequest , PropertyReference , ReadAccessSpecification , Error , AbortPDU , ReadPropertyMultipleACK <EOL> from bacpypes . primitivedata import Unsigned <EOL> from bacpypes . constructeddata import Array <EOL> from bacpypes . basetypes import PropertyIdentifier , ServicesSupported <EOL> _debug = <NUM_LIT:0> <EOL> _log = ModuleLogger ( globals ( ) ) <EOL> this_device = None <EOL> this_application = None <EOL> this_console = None <EOL> @ bacpypes_debugging <EOL> class ReadPropertyMultipleApplication ( BIPSimpleApplication ) : <EOL> def __init__ ( self , * args ) : <EOL> if _debug : ReadPropertyMultipleApplication . _debug ( "<STR_LIT>" , args ) <EOL> BIPSimpleApplication . __init__ ( self , * args ) <EOL> self . _request = None <EOL> def request ( self , apdu ) : <EOL> if _debug : ReadPropertyMultipleApplication . _debug ( "<STR_LIT>" , apdu ) <EOL> self . _request = apdu <EOL> BIPSimpleApplication . request ( self , apdu ) <EOL> def confirmation ( self , apdu ) : <EOL> if _debug : ReadPropertyMultipleApplication . _debug ( "<STR_LIT>" , apdu ) <EOL> if isinstance ( apdu , Error ) : <EOL> sys . stdout . write ( "<STR_LIT>" % ( apdu . errorCode , ) ) <EOL> sys . stdout . flush ( ) <EOL> elif isinstance ( apdu , AbortPDU ) : <EOL> apdu . debug_contents ( ) <EOL> elif ( isinstance ( self . _request , ReadPropertyMultipleRequest ) ) and ( isinstance ( apdu , ReadPropertyMultipleACK ) ) : <EOL> for result in apdu . listOfReadAccessResults : <EOL> objectIdentifier = result . objectIdentifier <EOL> if _debug : ReadPropertyMultipleApplication . _debug ( "<STR_LIT>" , objectIdentifier ) <EOL> for element in result . listOfResults : <EOL> propertyIdentifier = element . propertyIdentifier <EOL> if _debug : ReadPropertyMultipleApplication . _debug ( "<STR_LIT>" , propertyIdentifier ) <EOL> propertyArrayIndex = element . propertyArrayIndex <EOL> if _debug : ReadPropertyMultipleApplication . _debug ( "<STR_LIT>" , propertyArrayIndex ) <EOL> readResult = element . readResult <EOL> sys . stdout . write ( propertyIdentifier ) <EOL> if propertyArrayIndex is not None : <EOL> sys . stdout . write ( "<STR_LIT:[>" + str ( propertyArrayIndex ) + "<STR_LIT:]>" ) <EOL> if readResult . propertyAccessError is not None : <EOL> sys . stdout . write ( "<STR_LIT>" + str ( readResult . propertyAccessError ) + '<STR_LIT:\n>' ) <EOL> else : <EOL> propertyValue = readResult . propertyValue <EOL> datatype = get_datatype ( objectIdentifier [ <NUM_LIT:0> ] , propertyIdentifier ) <EOL> if _debug : ReadPropertyMultipleApplication . _debug ( "<STR_LIT>" , datatype ) <EOL> if not datatype : <EOL> raise TypeError , "<STR_LIT>" <EOL> if issubclass ( datatype , Array ) and ( propertyArrayIndex is not None ) : <EOL> if propertyArrayIndex == <NUM_LIT:0> : <EOL> value = propertyValue . cast_out ( Unsigned ) <EOL> else : <EOL> value = propertyValue . cast_out ( datatype . subtype ) <EOL> else : <EOL> value = propertyValue . cast_out ( datatype ) <EOL> if _debug : ReadPropertyMultipleApplication . _debug ( "<STR_LIT>" , value ) <EOL> sys . stdout . write ( "<STR_LIT>" + str ( value ) + '<STR_LIT:\n>' ) <EOL> sys . stdout . flush ( ) <EOL> @ bacpypes_debugging <EOL> class ReadPropertyMultipleConsoleCmd ( ConsoleCmd ) : <EOL> def do_read ( self , args ) : <EOL> """<STR_LIT>""" <EOL> args = args . split ( ) <EOL> if _debug : ReadPropertyMultipleConsoleCmd . _debug ( "<STR_LIT>" , args ) <EOL> try : <EOL> i = <NUM_LIT:0> <EOL> addr = args [ i ] <EOL> i += <NUM_LIT:1> <EOL> read_access_spec_list = [ ] <EOL> while i < len ( args ) : <EOL> obj_type = args [ i ] <EOL> i += <NUM_LIT:1> <EOL> if obj_type . isdigit ( ) : <EOL> obj_type = int ( obj_type ) <EOL> elif not get_object_class ( obj_type ) : <EOL> raise ValueError , "<STR_LIT>" <EOL> obj_inst = int ( args [ i ] ) <EOL> i += <NUM_LIT:1> <EOL> prop_reference_list = [ ] <EOL> while i < len ( args ) : <EOL> prop_id = args [ i ] <EOL> if prop_id not in PropertyIdentifier . enumerations : <EOL> break <EOL> i += <NUM_LIT:1> <EOL> if prop_id in ( '<STR_LIT:all>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> pass <EOL> else : <EOL> datatype = get_datatype ( obj_type , prop_id ) <EOL> if not datatype : <EOL> raise ValueError , "<STR_LIT>" <EOL> prop_reference = PropertyReference ( <EOL> propertyIdentifier = prop_id , <EOL> ) <EOL> if ( i < len ( args ) ) and args [ i ] . isdigit ( ) : <EOL> prop_reference . propertyArrayIndex = int ( args [ i ] ) <EOL> i += <NUM_LIT:1> <EOL> prop_reference_list . append ( prop_reference ) <EOL> if not prop_reference_list : <EOL> raise ValueError , "<STR_LIT>" <EOL> read_access_spec = ReadAccessSpecification ( <EOL> objectIdentifier = ( obj_type , obj_inst ) , <EOL> listOfPropertyReferences = prop_reference_list , <EOL> ) <EOL> read_access_spec_list . append ( read_access_spec ) <EOL> if not read_access_spec_list : <EOL> raise RuntimeError , "<STR_LIT>" <EOL> request = ReadPropertyMultipleRequest ( <EOL> listOfReadAccessSpecs = read_access_spec_list , <EOL> ) <EOL> request . pduDestination = Address ( addr ) <EOL> if _debug : ReadPropertyMultipleConsoleCmd . _debug ( "<STR_LIT>" , request ) <EOL> this_application . request ( request ) <EOL> except Exception , e : <EOL> ReadPropertyMultipleConsoleCmd . _exception ( "<STR_LIT>" , e ) <EOL> try : <EOL> args = ConfigArgumentParser ( description = __doc__ ) . parse_args ( ) <EOL> if _debug : _log . debug ( "<STR_LIT>" ) <EOL> if _debug : _log . debug ( "<STR_LIT>" , args ) <EOL> this_device = LocalDeviceObject ( <EOL> objectName = args . ini . objectname , <EOL> objectIdentifier = int ( args . ini . objectidentifier ) , <EOL> maxApduLengthAccepted = int ( args . ini . maxapdulengthaccepted ) , <EOL> segmentationSupported = args . ini . segmentationsupported , <EOL> vendorIdentifier = int ( args . ini . vendoridentifier ) , <EOL> ) <EOL> this_application = ReadPropertyMultipleApplication ( this_device , args . ini . address ) <EOL> services_supported = this_application . get_services_supported ( ) <EOL> if _debug : _log . debug ( "<STR_LIT>" , services_supported ) <EOL> this_device . protocolServicesSupported = services_supported . value <EOL> this_console = ReadPropertyMultipleConsoleCmd ( ) <EOL> _log . debug ( "<STR_LIT>" ) <EOL> run ( ) <EOL> except Exception , e : <EOL> _log . exception ( "<STR_LIT>" , e ) <EOL> finally : <EOL> _log . debug ( "<STR_LIT>" ) </s>
