Skip to content

Instantly share code, notes, and snippets.

View JoelBender's full-sized avatar
🎯
Focusing

Joel Bender JoelBender

🎯
Focusing
View GitHub Profile
@JoelBender
JoelBender / GroupObject.py
Created August 22, 2021 06:09
GroupObject Sample
#!/usr/bin/env python
"""
This sample application shows how to create a GroupObject.
"""
import os
import random
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
@JoelBender
JoelBender / sometimes-writable-value.py
Created August 13, 2021 22:15
Sometimes write access is denied
#!/usr/bin/env python
"""
This sample application shows how to extend one of the basic objects, an Analog
Value Object in this case, to provide a present value that is writable but
occasionally returns an error.
"""
import os
import random
@JoelBender
JoelBender / gist:e7de20c9b207bc3988e38b6d289c5a1b
Created July 22, 2021 03:20
AnalogValueObject with a writable object name
"""
Writable Analog Value Object
"""
from bacpypes.errors import ExecutionError
from bacpypes.primitivedata import Real, CharacterString
from bacpypes.basetypes import EngineeringUnits
from bacpypes.object import register_object_type, WritableProperty, AnalogValueObject
# from bacpypes.consolelogging import ConsoleLogHandler
@JoelBender
JoelBender / whois_timer_sample.py
Created May 21, 2021 03:43
Periodically generate a Who-Is request
#!/usr/bin/env python
"""
This application generates a Who-Is request based on a timer, then lines up
the corresponding I-Am for incoming traffic and prints out the contents.
"""
import sys
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
@JoelBender
JoelBender / local_objects.py
Created January 3, 2021 16:45
Local Objects
#!/usr/bin/env python
"""
This sample application is a server that has a local, writable, Analog Value
and Binary Value object.
On a network with two IPv4 workstations make a copy of the BACpypes~.ini file
called in BACpypes.ini and set the 'address:' to the CIDR address of the
workstation. For example, the first one is 192.168.10.11/24 and the second
is 192.168.10.21/24.
@JoelBender
JoelBender / simple_analog_values.py
Created October 20, 2020 02:31
Simple way of serving analog value objects
#!/usr/bin/env python
"""
This sample application shows how to create analog value objects with
different values.
"""
import os
import random
from bacpypes.primitivedata import TagList
from bacpypes.basetypes import (
DeviceObjectPropertyReference,
EventParameterAccessEventAccessEvent,
)
x = EventParameterAccessEventAccessEvent(
listOfAccessEvents=["deniedMaxAttempts"],
accessEventTimeReference=DeviceObjectPropertyReference(
objectIdentifier=("analogValue", 1), propertyIdentifier="presentValue"
@JoelBender
JoelBender / chips.py
Created April 29, 2020 13:24
Chips and wires
"""
Chips
"""
from typing import Any, List
_all_chips: List["Chip"] = []
_all_wires: List["Wire"] = []
@JoelBender
JoelBender / threading_1.py
Created April 17, 2020 01:09
Threading Examples
#!/usr/bin/python
"""
This application demonstrates doing something at a regular interval.
"""
import sys
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ArgumentParser
@JoelBender
JoelBender / gist:0879b78ebc474502ada48870c51a266b
Created September 19, 2019 22:20
asyncio signal handler
import sys
import asyncio
import signal
def ctrl_c():
print("hit!")
sys.exit(1)
loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, ctrl_c)