Comments (4)
There are lots of methods to create static objects at arbitrary instances. Keep the 'instance' and 'index' consistent with each other so that the device object can iterate through the object list.
There are examples using the 'keylist.c' library to dynamically create objects - see an example ao.c module,
Here is an example where you can modify the object data structure to include the object_instance:
struct object_data {
const uint32_t Object_Instance;
const char *Object_Name;
uint16_t Units;
float Min_Value;
float Max_Value;
bool Writable : 1;
bool Out_Of_Service : 1;
float Present_Value;
};
Create a static object property value table:
/* default values */
static struct object_data Object_List[] = {
{ 55, "Sensor 4A", UNITS_DEGREES_CELSIUS, 0.0, 100.0, true, false, 18.0 }
};
/* number of objects */
static size_t Objects_List_Size = sizeof(Object_List) / sizeof(Object_List[0]);
/**
* @brief Determines the number of objects N
* @return Number of objects N
*/
unsigned Analog_Input_Count(void)
{
return Objects_List_Size;
}
/**
* @brief Return the object or NULL if not found.
* @param object_instance - object-instance number of the object
* @return object if the instance is found, and NULL if not
*/
static struct object_data *Object_List_Element(uint32_t object_instance)
{
unsigned index;
for (index = 0; index < Objects_List_Size; index++) {
if (Object_List[index].object_instance == object_instance) {
return &Object_List[index];
}
}
return NULL;
}
/**
* @brief Determines the object instance-number for a given 0..N index
* @param index - 0..N value
* @return object instance-number for the given index
*/
uint32_t Analog_Input_Index_To_Instance(unsigned index)
{
uint32_t object_instance = UINT32_MAX;
if (index < Objects_List_Size) {
object_instance = Object_List[index].object_instance;
}
return object_instance;
}
/**
* @brief For a given object instance-number, determines a 0..N index
* @param object_instance - object-instance number of the object
* @return index for the given instance-number, or N if not valid.
*/
unsigned Analog_Input_Instance_To_Index(uint32_t object_instance)
{
unsigned index;
for (index = 0; index < Objects_List_Size; index++) {
if (Object_List[index].object_instance == object_instance) {
break;
}
}
return index;
}
/**
* @brief For a given object instance-number, gets the present-value
* @param object_instance - object-instance number of the object
* @return present-value of the object
*/
float Analog_Input_Present_Value(uint32_t object_instance)
{
float value = 0;
struct object_data *pObject;
pObject = Object_List_Element(object_instance);
if (pObject) {
value = pObject->value;
}
return value;
}
from bacnet-stack.
Can you clarify specifically what you mean by max address limit on objects? Perhaps give an example of the problem?
Usually when discussing addresses, I assume you are asking about the address binding to device object instance.
The src/bacnet/basic/binding/address.c
module is an example of how to 'bind' network MAC address to object-instance. There is a function address_add()
for adding new bindings, and is usually called by response from I-Am service. It can also be called from a file if you have one, and there is an example of using the output from Who-Is example to fill the address_cache file. At the moment, the address.c module uses MAX_ADDRESS_CACHE
as maximum size of address bindings in a static array.
If address.c module doesn't suit your needs, you should construct your own module to store address bindings.
from bacnet-stack.
Hello Steve,
Thank you for your quick response.
For example, we have a MAX_ANALOG_INPUTS limit on Analog_Input.
Instead I want to assign an object with a random static address.
When I add Analog_Input_Present_Value(55) I want an object with address 55 to be created automatically. Currently when I set Max_analog_inputs to 55 I create objects from 0 to 54 that I don't need.
I hope I could explain.
from bacnet-stack.
Ok thank you very much
from bacnet-stack.
Related Issues (20)
- Problem with Analog_Input_Present_Value_Set HOT 3
- Schedule Write PROP_WEEKLY_SCHEDULE HOT 1
- segmentation support & BTL Cert HOT 3
- Zephyr hello_bacnet_stack sample build fail HOT 4
- ethernet.c file does not exist in ports/zephyr directory
- Linux Router app Makefile
- undefined reference to 'xxx_function' with cgo_gcc when build the golang codes with shared library HOT 4
- Update to Zephyr v3.6.0 HOT 1
- Life Safety Zone object support
- Inconsistent bacnet-config.h inclusion in header order HOT 1
- Inconsistant use of index/object_instance in ai.c
- the bacserv of MSTP in win32 work abnormal ! HOT 4
- NPDU: DNET=708. Discarded!
- Issue with writing schedule using /apps/writeprop/bacwp HOT 3
- Pipeline static analysis issues with Some hardware. HOT 1
- Invoke ID mismatch HOT 3
- Bacnet on linux HOT 1
- Structured-View-Object HOT 1
- Basic Objects av.c & ai.c have different Alarm_Ack functionality HOT 1
- how to work bacnetip and mstp together HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bacnet-stack.