Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding Alarm Services #23

Open
shashankgowdasd opened this issue Dec 4, 2023 · 8 comments
Open

Regarding Alarm Services #23

shashankgowdasd opened this issue Dec 4, 2023 · 8 comments

Comments

@shashankgowdasd
Copy link

Hi Sir @JoelBender ,

I have tried with event-server.py for the Alarm services but I am unable to see the changes nether in the status flags nor in the notification class for the changes in the presentValue and for to check alarm services I have made the analogValue object presentValue changing for every 5 seconds but i didnt observer a Alarm notification in yabe,So please guide reagarding this sir...

@bbartling
Copy link

Not alot of Wisdom here in event notifications in BACnet... but if i run sandbox/event-server-avo1-ir.py

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/bbartling/.local/lib/python3.9/site-packages/bacpypes3/local/event.py", line 411, in state_transition_delayed
    self.state_transition(new_state, True)
  File "/home/bbartling/.local/lib/python3.9/site-packages/bacpypes3/local/event.py", line 618, in state_transition
    ] = self.event_notification_parameters()
  File "/home/bbartling/.local/lib/python3.9/site-packages/bacpypes3/local/event.py", line 1686, in event_notification_parameters
    return event_values
UnboundLocalError: local variable 'event_values' referenced before assignment

It starts with $ python event-server-avo1-ir.py --debug

Where then my rasp pi comes up as a discoverable BACnet device on my test bench LAN with a few points.
image

And if I modified my AnalogValueObjectIR to these values:

timeDelay=10,
notificationClass=1,
highLimit=70.0,
lowLimit=40.0,
deadband=5.0,

Where then in my BACnet scan tool I adjusted the AnalogValueObjectIR below the lowLimit threshold:
image

Where then after the timeDelay it does appear to trigger an event notification that i can see in the logs... but then yields the error UnboundLocalError: local variable 'event_values' referenced before assignment

Here's the whole traceback:

$ python event-server-avo1-ir.py --debug
DEBUG:__main__:args: Namespace(loggers=False, debug=[], color=None, route_aware=None, name='Excelsior', instance=999, network=0, address=None, vendoridentifier=999, foreign=None, ttl=30, bbmd=None)
DEBUG:__main__:app: <bacpypes3.app.Application object at 0x75595940>
DEBUG:__main__:avo1: <bacpypes3.local.analog.AnalogValueObjectIR object at 0x755599a0>
    <bacpypes3.local.analog.AnalogValueObjectIR object at 0x755599a0>
        objectIdentifier = <property object at 0x75c2bb68>
        objectName = <property object at 0x75c2baf0>
        objectType = <ObjectType: analog-value>
        description = 'test analog value'
        propertyList = <property object at 0x75c2bbe0>
        presentValue = 50.0
        statusFlags = <property object at 0x75c2bc58>
        eventState = <EventState: normal>
        outOfService = 0
        units = <EngineeringUnits: degrees-fahrenheit>
        priorityArray = <PriorityArray _obj=<bacpypes3.local.analog.AnalogValueObjectIR object at 0x755599a0>>
        relinquishDefault = 50.0
        timeDelay = 10
        notificationClass = 1
        highLimit = 70.0
        lowLimit = 40.0
        deadband = 5.0
        limitEnable = <LimitEnable: low-limit-enable;high-limit-enable>
        eventEnable = <EventTransitionBits: to-offnormal;to-fault;to-normal>
        ackedTransitions = <EventTransitionBits: >
        notifyType = <NotifyType: alarm>
        eventTimeStamps = [<bacpypes3.basetypes.TimeStamp object at 0x756428c8>, <bacpypes3.basetypes.TimeStamp object at 0x75633ac0>, <bacpypes3.basetypes.TimeStamp object at 0x756336d0>]
        eventMessageTexts = ['', '', '']
        eventDetectionEnable = 1
        eventAlgorithmInhibit = 0
        timeDelayNormal = 2
        currentCommandPriority = <bacpypes3.basetypes.OptionalUnsigned object at 0x756256a0>
            null = ()
DEBUG:__main__:nc1: <bacpypes3.object.NotificationClassObject object at 0x755591c0>
    <bacpypes3.object.NotificationClassObject object at 0x755591c0>
        objectIdentifier = (<ObjectType: notification-class>, 1)
        objectName = 'nc1'
        objectType = <ObjectType: notification-class>
        description = 'test notification class'
        notificationClass = 1
        priority = [9, 9, 9]
        ackRequired = <EventTransitionBits: >
        recipientList = [<bacpypes3.basetypes.Destination object at 0x75559220>]
> Exception in callback EventAlgorithm.state_transition_delayed()
handle: <TimerHandle when=1855.115028604 EventAlgorithm.state_transition_delayed()>
Traceback (most recent call last):
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/bbartling/.local/lib/python3.9/site-packages/bacpypes3/local/event.py", line 411, in state_transition_delayed
    self.state_transition(new_state, True)
  File "/home/bbartling/.local/lib/python3.9/site-packages/bacpypes3/local/event.py", line 618, in state_transition
    ] = self.event_notification_parameters()
  File "/home/bbartling/.local/lib/python3.9/site-packages/bacpypes3/local/event.py", line 1686, in event_notification_parameters
    return event_values
UnboundLocalError: local variable 'event_values' referenced before assignment

@shashankgowdasd
Copy link
Author

Hi @JoelBender Sir,
Is their any substitute methods or example for internsic alarming in bacpypes3 or bacpypes please Suggest me sir......

@JoelBender
Copy link
Owner

The sandbox application that Ben references should be working (along with the others that are similarly named). I'll fix it up and post back here.

@JoelBender
Copy link
Owner

There is now a new event-notification-recipient.py sample application for receiving events, and the event-server-avo1-ir.py sample has been updated (the others also updated but not tested yet).

I have this nagging feeling that the relationship between normal/fault transitions and normal/off-normal transitions aren't quite right yet with respect to timers.

@shashankgowdasd
Copy link
Author

shashankgowdasd commented Dec 27, 2023

Thank you Sir @JoelBender,
I have used the event-server-avo1-ir.py for internsic alarming but when I adjust the presentValue above the HighLimit , I got the below error after the time delay

Error:
Exception in callback EventAlgorithm.state_transition_delayed()
handle: <TimerHandle when=466190.093 EventAlgorithm.state_transition_delayed()>
Traceback (most recent call last):
File "C:\Users\vimel\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\vimel\AppData\Local\Programs\Python\Python39\lib\site-packages\bacpypes3\local\event.py", line 411, in state_transition_delayed
self.state_transition(new_state, True)
File "C:\Users\vimel\AppData\Local\Programs\Python\Python39\lib\site-packages\bacpypes3\local\event.py", line 618, in state_transition
] = self.event_notification_parameters()
File "C:\Users\vimel\AppData\Local\Programs\Python\Python39\lib\site-packages\bacpypes3\local\event.py", line 1686, in event_notification_parameters
return event_values
UnboundLocalError: local variable 'event_values' referenced before assignment

@JoelBender
Copy link
Owner

I think you are still running the old code, those lines should look like this. Please turn on debugging by adding --debug bacpypes3.local.event.OutOfRangeEventAlgorithm and when event_notification_parameters() is called it should dump out the private _current_state and new_state values. If the event_values is unset then the transition isn't being recognized.

The format for building a DeviceAddress (described in basetypes) is the same as other BACpypes addresses. This is one of the rare cases where going from BACnetAddress in the standard to Address in the library would cause headaches, so I renamed it to DeviceAddress:

>>> DeviceAddress("1.2.3.4").debug_contents()
    networkNumber = 0
    macAddress = b'\x01\x02\x03\x04\xba\xc0'

>>> DeviceAddress("5:6").debug_contents()
    networkNumber = 5
    macAddress = b'\x06'

>>> DeviceAddress("*").debug_contents()
    networkNumber = 0
    macAddress = b''

I'm not sure why I excluded global broadcasts, I've looked in the standard and I couldn't find it explicitly excluded.

>>> DeviceAddress("*:*").debug_contents()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/joel/BACpypes3/bacpypes3/constructeddata.py", line 228, in __call__
    return cast(Sequence, type.__call__(new_type, *args, **kwargs))
  File "/home/joel/BACpypes3/bacpypes3/basetypes.py", line 1898, in __init__
    raise ValueError(arg)
ValueError: *:*

@JoelBender
Copy link
Owner

Note that the samples have a recipient device specified by its device object identifier, so for a notification to be sent out the application needs to have it "bound" (see this code). So execute a Who-Is for the destination device, the library doesn't do that automatically.

@shashankgowdasd
Copy link
Author

Hi @JoelBender Sir,
Thank you for your previous suggestions; I was able to see the intrinsic reporting using the event-server-avo1-ir.py. However, I now face the challenge of incorporating alarm services using Bacpypes3. I have developed the entire project using Bacpypes, and I attempted to integrate the AnalogObjectIR from Bacpypes3 directly into my application. Unfortunately, I have encountered difficulties and have not achieved success.

I kindly request your guidance and suggestions on how to effectively implement intrinsic reporting using Bacpypes3 within my Bacpypes-based application. Your expertise and advice will be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants