def create_MV(oid=1, pv=0, name='MV', states=['red', 'green', 'blue']): msvo = MultiStateValueObject(objectIdentifier=('multiStateValue', oid), objectName=name, presentValue=pv, numberOfStates=len(states), stateText=ArrayOf(CharacterString)(states)) return msvo
def main(): # parse the command line arguments args = ConfigArgumentParser(description=__doc__).parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make a device object this_device = LocalDeviceObject(ini=args.ini) if _debug: _log.debug(" - this_device: %r", this_device) # make a sample application this_application = BIPSimpleApplication(this_device, args.ini.address) # make a multistate value object msvo = MultiStateValueObject( objectIdentifier=('multiStateValue', 1), objectName='My Special Object', presentValue=1, numberOfStates=3, stateText=['red', 'green', 'blue'], ) _log.debug(" - msvo: %r", msvo) # add it to the device this_application.add_object(msvo) _log.debug(" - object list: %r", this_device.objectList) _log.debug("running") run() _log.debug("fini")
def create_MV(oid=1, pv=0, name="MV", states=["red", "green", "blue"]): msvo = MultiStateValueObject( objectIdentifier=("multiStateValue", oid), objectName=name, presentValue=pv, numberOfStates=len(states), stateText=ArrayOf(CharacterString)(states), ) return msvo
def create_MV(oid=1, pv=0, name="MV", states=["red", "green", "blue"], pv_writable=False): msvo = MultiStateValueObject( objectIdentifier=("multiStateValue", oid), objectName=name, presentValue=pv, numberOfStates=len(states), stateText=ArrayOf(CharacterString)(states), priorityArray=PriorityArray(), ) msvo = _make_mutable(msvo, mutable=pv_writable) return msvo
def main(): # parse the command line arguments args = ConfigArgumentParser(description=__doc__).parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make a device object this_device = LocalDeviceObject( objectName=args.ini.objectname, objectIdentifier=int(args.ini.objectidentifier), maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), segmentationSupported=args.ini.segmentationsupported, vendorIdentifier=int(args.ini.vendoridentifier), ) # make a sample application this_application = BIPSimpleApplication(this_device, args.ini.address) # get the services supported services_supported = this_application.get_services_supported() if _debug: _log.debug(" - services_supported: %r", services_supported) # let the device object know this_device.protocolServicesSupported = services_supported.value # make a multistate value object msvo = MultiStateValueObject( objectIdentifier=('multiStateValue', 1), objectName='My Special Object', presentValue=1, numberOfStates=3, stateText=ArrayOf(CharacterString)(['red', 'green', 'blue']), ) _log.debug(" - msvo: %r", msvo) # add it to the device this_application.add_object(msvo) _log.debug(" - object list: %r", this_device.objectList) _log.debug("running") run() _log.debug("fini")
def __init__(self, **kwargs): if _debug: RandomMultiStateValueObject._debug("__init__ %r", kwargs) MultiStateValueObject.__init__(self, **kwargs)
# make a sample application this_application = BIPSimpleApplication(this_device, args.ini.address) # get the services supported services_supported = this_application.get_services_supported() if _debug: _log.debug(" - services_supported: %r", services_supported) # let the device object know this_device.protocolServicesSupported = services_supported.value # make a multistate value object msvo = MultiStateValueObject( objectIdentifier=('multiStateValue', 1), objectName='My Special Object', presentValue=1, numberOfStates=3, stateText=['red', 'green', 'blue'], ) _log.debug(" - msvo: %r", msvo) # add it to the device this_application.add_object(msvo) _log.debug(" - object list: %r", this_device.objectList) _log.debug("running") run() except Exception, e: _log.exception("an error has occurred: %s", e)