diff --git a/AGENTS.md b/AGENTS.md index bc838ca..fdce40f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -93,8 +93,12 @@ Input 1, `s` advance Schedule 1 (Saffron) to a transition right now. Older stack pins also flooded the log from `AddTrendLogObject` alone ([#2050](https://github.com/chipkin/cas-bacnet-stack/issues/2050), same - class as B-ACC's #2045 for Event Log). That's gone on 6.0.22; if it comes - back, check #2050/#2045 before treating it as a new bug. + class as B-ACC's #2045 for Event Log). That's gone on 6.0.22. The current + `issues/runbook` pin logs a one-off burst of the same lines at startup, + plus one `BACnetDateRange` pair per Calendar `Date_List` access + ([#2381](https://github.com/chipkin/cas-bacnet-stack/issues/2381), + bisected to stack commit `4c793c15`). Check #2381/#2050 before treating + either as a new bug. - **Startup `UUID has not been set` error:** a single `BACnetDataLinkSC::Loop() ... UUID has not been set` line at startup is a harmless stack log defect @@ -110,6 +114,13 @@ Input 1, `s` advance Schedule 1 (Saffron) to a transition right now. the peer is bound, is never re-sent. That's stack gap [#2343](https://github.com/chipkin/cas-bacnet-stack/issues/2343), not a code bug. See TODO.md item 2. +- **Calendar 1 (Cream) is stack-held** (`BACnetStack_AddCalendarObject`, + stack IFC-045): the stack stores `Date_List` and derives `Present_Value`. + Don't serve either from a callback, because the stack answers first. + Saffron's exception is a calendar reference to Cream + (`AddScheduleExceptionEventWithCalendarReference`), which only matches a + stack-held Calendar. `tests/calendar_reference_check.py` adds today to + `Date_List` and checks Cream -> Saffron -> Chartreuse. - Outputs are **commandable**: store the 16-slot `Priority_Array` + `Relinquish_Default` in the app (the `Commandable` struct); let the stack resolve `Present_Value`. Writes land via the `SetProperty*` callbacks (value) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd2f2a6..c37bcd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,47 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.7] - 2026-09-23 + +### Changed + +- **Calendar 1 ("Cream") is now stack-held, and Schedule 1 ("Saffron")'s + exception references it.** Stack issue + [#1758](https://github.com/chipkin/cas-bacnet-stack/issues/1758) is fixed + on `issues/runbook` (IFC-045). `BACnetStack_AddCalendarObject` hands Cream + to the stack, which stores `Date_List` and derives `Present_Value` from + the device's `Local_Date`. Cream's `Date_List` holds December 25 of every + year (`BACnetStack_AddCalendarDateEntry`), and it is WRITABLE + (`SetPropertyWritable`, property 23), so clients can add holidays with + WriteProperty / AddListElement. Saffron's exception moved from the inline + `...WithCalendarEntry` form to + `BACnetStack_AddScheduleExceptionEventWithCalendarReference` pointing at + Cream. The app no longer serves Cream's `Present_Value` from + `GetPropertyBool`, because the stack answers first. +- New `tests/calendar_reference_check.py`: writes today into Cream's + `Date_List` and checks that Cream's `Present_Value` goes TRUE, Saffron's + exception takes over, and Chartreuse moves to 5.0, then restores the + list. Verified live: Cream FALSE -> TRUE, Chartreuse 20.0 -> 5.0 -> 20.0 + after restore (PASS). +- **CAS BACnet Stack pinned to `issues/runbook` @ `00aa2d0e`**, ahead of + `6.x` @ `22ac3c98`, for the Calendar exports. It still reports 6.0.22. + Move back to `6.x` once #1758 lands there. #2051's stack-side change on + this branch is documentation only: the root cause was this example's + local-time window, fixed in 1.0.6. +- **Known log noise on this pin:** a one-off startup burst of + `BACnetDateTime ... Failed to set the date/time` lines (bisected to stack + commit `4c793c15`, #2207), plus a `BACnetDateRange` pair on each Calendar + `Date_List` access. Filed as + [cas-bacnet-stack#2381](https://github.com/chipkin/cas-bacnet-stack/issues/2381). + TODO.md item 1. +- TODO.md: the Calendar gap (old item 3) is removed and the items after it + are renumbered. TUTORIAL.md, AGENTS.md, README.md and `docs/objects.json` + now describe the stack-held Calendar (PICS regenerated). +- Re-verified on this pin: Trend Log 1 / Trend Log Multiple 1 record (28 / + 29 records), ReadPropertyMultiple of the whole Device OK, and + `tests/sched_e_b_remote_peer.py` PASS. +- APP_VERSION bumped 1.0.6 -> 1.0.7. + ## [1.0.6] - 2026-09-22 ### Fixed diff --git a/README.md b/README.md index a922d6a..c13e895 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,9 @@ and ReadRange). It listens on **BACnet/IP (UDP 47808)** and claims only B-BC. - **[docs/PICS.md](docs/PICS.md)** - the Protocol Implementation Conformance Statement: every object, every property, and who answers it. -> **Versions:** this document describes **example v1.0.6**, built and verified -> against **CAS BACnet Stack 6.0.22** (`6.x` @ `22ac3c98`), at +> **Versions:** this document describes **example v1.0.7**, built and verified +> against **CAS BACnet Stack 6.0.22** (`issues/runbook` @ `00aa2d0e`, ahead of `6.x` for +> stack-held Calendars - see `TODO.md`), at > **Protocol_Revision 26**, with the vendored `common/` helper at **v3.0.0**. > Running the example prints all three - if what it prints disagrees with this > line, trust the program and check `CHANGELOG.md`. @@ -27,10 +28,7 @@ and ReadRange). It listens on **BACnet/IP (UDP 47808)** and claims only B-BC. > **B-BC is not fully claimable with the standard stack yet.** This example > implements every B-BC capability the standard CAS BACnet Stack exposes, and > clearly marks what it cannot do - see [TUTORIAL.md](TUTORIAL.md) and -> [TODO.md](TODO.md). In summary: Calendar 1 -> ("Cream")'s `Date_List` cannot be populated -> ([#1758](https://github.com/chipkin/cas-bacnet-stack/issues/1758)). -> Schedule 1's SCHED-E-B remote write is verified on the wire, but the stack +> [TODO.md](TODO.md). In summary: Schedule 1's SCHED-E-B remote write is verified on the wire, but the stack > drops the write it makes at startup, before the remote device has been > found ([#2343](https://github.com/chipkin/cas-bacnet-stack/issues/2343)). @@ -60,7 +58,7 @@ Analog Value 1 "Diamond" (REAL, WRITABLE; intrinsic OutOfRange ala Notification Class 1 "Crimson" (routes Diamond's alarms; Recipient_List WRITABLE) Network Port 1 "Vermilion" (BACnet/IP - required) Schedule 1 "Saffron" (drives Chartreuse locally AND a remote peer - SCHED-E-B) -Calendar 1 "Cream" (see TUTORIAL.md - Date_List not evaluated) +Calendar 1 "Cream" (stack-held Date_List, WRITABLE; drives Saffron's exception) File 1 "Ivory" (backup/restore payload - DM-BR-B) Trend Log 1 "Lilac" (polls Bronze) Trend Log Multiple 1 "Magenta" (polls Bronze/Diamond/Chartreuse) @@ -217,7 +215,7 @@ CMake at it: `cmake -B build -S . -D CAS_STACK_DIR=/path/to/cas-bacnet-stack`. Expected output: ``` -BACnet B-BC (Building Controller) Example - C++ v1.0.6 +BACnet B-BC (Building Controller) Example - C++ v1.0.7 CAS BACnet Stack version: 6.0.22.0 Common helper (common/) version: 3.0.0 FYI: Listening for BACnet/IP on UDP port 47808 (Network Port 1). diff --git a/TODO.md b/TODO.md index b3c67db..928056d 100644 --- a/TODO.md +++ b/TODO.md @@ -1,14 +1,15 @@ # TODO — known gaps (all verified against the pinned stack source and/or the wire, not assumed) -Stack pin: `22ac3c986d3a1c46028527d356ddd80673715bf6` (`6.x`, release 6.0.22, merged 2026-09-22). -The example is back on the `6.x` branch named in `.gitmodules`. The previous pin (`a8d3b6bf` on -`issues/runbook`) was only there to pick up fixes for #2163, #2164 and #2165 early, and those -fixes are now on `6.x`. Every item below was re-checked live against `22ac3c98`. +Stack pin: `00aa2d0e` (`issues/runbook`, reports 6.0.22, 2026-09-23). This is deliberately ahead of +the `6.x` branch `.gitmodules` names (`6.x` @ `22ac3c98`), to pick up stack-held Calendar objects +([#1758](https://github.com/chipkin/cas-bacnet-stack/issues/1758), IFC-045) before they reach +`6.x`. Move back to a `6.x` commit once they do. Items verified on `22ac3c98` say so; everything +was re-checked live on `00aa2d0e`. Each open item has a tracking issue in this repo: -[#14](https://github.com/chipkin/BACnetProfileExample-B-BC-CPP/issues/14) (item 3), -[#15](https://github.com/chipkin/BACnetProfileExample-B-BC-CPP/issues/15) (item 6), -[#16](https://github.com/chipkin/BACnetProfileExample-B-BC-CPP/issues/16) (item 7). +[#18](https://github.com/chipkin/BACnetProfileExample-B-BC-CPP/issues/18) (item 1), +[#15](https://github.com/chipkin/BACnetProfileExample-B-BC-CPP/issues/15) (item 5), +[#16](https://github.com/chipkin/BACnetProfileExample-B-BC-CPP/issues/16) (item 6). ## Fixed on earlier pins (verified live against `a8d3b6bf`, re-checked on `22ac3c98`) @@ -31,15 +32,32 @@ Each open item has a tracking issue in this repo: of commits, not by a change that references the issue directly) - see item 1's update below. - **[#2178](https://github.com/chipkin/cas-bacnet-stack/issues/2178)** (`Schedule.Weekly_Schedule` and `Network_Port.IP_DNS_Server` both Aborting instead of returning a value/Error) — fixed, - closed. `IP_DNS_Server` no longer Aborts, but now surfaces a narrower gap of its own — see item 6 + closed. `IP_DNS_Server` no longer Aborts, but now surfaces a narrower gap of its own — see item 5 (`chipkin/cas-bacnet-stack#2196`). - **[#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051)** (Trend Log 1 "Lilac"'s `Record_Count` stuck at 0) — **not a stack defect.** The example built the `SetTrendLogStartStopTime` window from local time, but the stack compares it against UTC, so off-UTC hosts never logged. Fixed in this repo (`gmtime`, #9). Re-verified on `22ac3c98`. - -## 1. `AddTrendLogObject` causes a continuous internal log flood (same class as #2045) — fixed (regression note only) - +- **[#1758](https://github.com/chipkin/cas-bacnet-stack/issues/1758)** (Calendar `Date_List` had no + customer-facing storage, so a Schedule calendar-reference exception never matched) — fixed on + `issues/runbook` by stack-held Calendars (IFC-045). Calendar 1 ("Cream") is now stack-held with a + December 25 entry and a writable `Date_List`, and Schedule 1's exception references it. + Verified live: see CHANGELOG 1.0.7. + +## 1. "Failed to set the date/time" log lines — the #2050 flood is fixed, but a new startup burst is back on this pin + +**On the current pin (`00aa2d0e`):** 8 pairs of `BACnetDateTime ... Failed to set the date/time` +lines at startup, then silence. This is not the old per-tick flood. In addition, every access to +Calendar 1's `Date_List` logs one `BACnetDateRange ... Failed to set the start/end date` pair. +Behaviour is correct throughout. `git bisect` (same example source at every step) puts the startup +burst at stack commit `4c793c15` (#2207, SC hub-connection timestamps): `BACnetSCHubConnection::Reset()` +assigns an all-unspecified `BACnetDateTime`, and `operator=` rejects unspecified fields. The SC +data link builds those objects even on this BACnet/IP-only device. The `Date_List` lines are the +same pattern in the new Calendar code. +**Filed:** [chipkin/cas-bacnet-stack#2381](https://github.com/chipkin/cas-bacnet-stack/issues/2381). +Tracked here as [#18](https://github.com/chipkin/BACnetProfileExample-B-BC-CPP/issues/18). + +**The original #2050 flood (below) stays fixed:** **Fixed.** 0 occurrences of the flood over a ~30-second live run against `22ac3c98` (6.0.22). It was already gone on `a8d3b6bf`. #2050 is still open upstream (see the re-verification comment there) because no single commit names it. Tracked to closure by @@ -95,19 +113,7 @@ value once the I-Am arrives. The remote target only catches up at the next `Pres **Filed:** [chipkin/cas-bacnet-stack#2343](https://github.com/chipkin/cas-bacnet-stack/issues/2343). Nothing to change on this side. This example's wiring is correct. -## 3. Calendar 1 ("Cream")'s `Date_List` — inherited, pre-existing gap - -Same gap B-AAC's (and B-ACC's) file header already documents against stack issue -[#1758](https://github.com/chipkin/cas-bacnet-stack/issues/1758) (formerly tracked as #963, which -was closed 2026-09-13 with the remaining work split off to #1758 — update this link if you find -another sibling example still pointing at the closed #963): -`BACnetStack_AddScheduleExceptionEventWithCalendarReference` does not resolve a Calendar's -`Date_List` at evaluation time, and there is no customer-facing way to populate `Date_List` at -all. This file uses the inline `...WithCalendarEntry` exception form instead (fully functional, -live-verified), exactly as B-AAC does; Cream still exists as a correctly-served object with -`Date_List` `accepted` (not served) in `docs/objects.json`. - -## 4. F-REINIT / #2036 (Life Safety) — confirmed not applicable +## 3. F-REINIT / #2036 (Life Safety) — confirmed not applicable B-LSC's own port of this callback (`implement-lsc` branch, unmerged) states in its file header: "F-REINIT (DM-RD-B): unchanged from B-AAC/B-ASC" — this example's `ReinitializeDevice` (inherited @@ -116,13 +122,13 @@ B-ACC's pattern) is therefore already the same code B-LSC itself uses for COLDST This example carries **no** Life Safety Point/Zone objects, so cas-bacnet-stack#2036 (a Life Safety Point/Zone-specific defect) does not apply here — confirmed by inspection, not assumed. -## 5. Access-family gaps (#2044, #2046) — confirmed not applicable +## 4. Access-family gaps (#2044, #2046) — confirmed not applicable This profile carries no Access Door/Point/Credential/Rights/Zone objects, so the AE-AC-B notification-generation gap (#2044) and the constructed-property read gaps (#2046) B-ACC found do not apply to this example. -## 6. Network Port 1's `Property_List` advertises two properties it can't actually answer +## 5. Network Port 1's `Property_List` advertises two properties it can't actually answer Split from [#2178](https://github.com/chipkin/cas-bacnet-stack/issues/2178) (that issue's own Abort-PDU bugs — `Schedule.Weekly_Schedule` and `Network_Port.IP_DNS_Server` both aborting — are @@ -142,7 +148,7 @@ or serves either), so there's nothing to change on this side. `FD_Bbmd_Address` `Error (property, value-not-initialized)` is NOT part of this gap — that's the correct answer for a device with no BBMD configured. -## 7. A BACnet/SC "UUID has not been set" error is logged at startup +## 6. A BACnet/SC "UUID has not been set" error is logged at startup Every start prints this line once, even though this example is BACnet/IP-only and never touches the BACnet/SC API: diff --git a/TUTORIAL.md b/TUTORIAL.md index 1c03722..9cfaf50 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -144,7 +144,7 @@ a Value object and it silently stays non-commandable. | Notification Class | `Object_Name` | `Priority`/`Ack_Required`/`Recipient_List` held by the stack's own host-configuration API (`AddNotificationClassObject` / `AddRecipientToNotificationClass`), not a `GetProperty*` callback | | Network Port | `Object_Name`, `Out_Of_Service`, `Network_Type`, `Protocol_Level`, `Changes_Pending` | BACnet/IP addressing via `GetPropertyOctetString` | | Schedule | `Object_Name`, `Reliability`, `Out_Of_Service` | `Present_Value`/`Effective_Period`/`Schedule_Default`/`List_Of_Object_Property_References` held by the stack's Schedule engine | -| Calendar | `Object_Name`, `Present_Value` | `Date_List` cannot be populated through the customer API - see [Known gaps](#known-gaps-in-this-example) | +| Calendar | `Object_Name` | Stack-held: after `AddCalendarObject` the stack stores `Date_List` (populate with `AddCalendarDateEntry` / `AddCalendarDateRangeEntry` / `AddCalendarWeekNDayEntry`) and derives `Present_Value` from the device's `Local_Date`. Make `Date_List` writable with `SetPropertyWritable(..., 23, true)` to let clients edit it | | File | `Object_Name`, `File_Type`, `File_Size`, `Modification_Date`, `Archive` (writable), `Read_Only` | `File_Access_Method` served by the stack | | Trend Log | `Object_Name` | everything else held by the stack's Trend Log engine once configured | | Trend Log Multiple | `Object_Name` | everything else held by the stack's Trend Log Multiple engine once configured | @@ -189,8 +189,11 @@ with reproduction steps. same class of defect as `AddEventLogObject`'s [#2045](https://github.com/chipkin/cas-bacnet-stack/issues/2045). Filed as [#2050](https://github.com/chipkin/cas-bacnet-stack/issues/2050). - **Fixed on the current pin (6.0.22):** no flood in a live run. Kept here in - case it comes back on a future pin. + **Fixed since 6.0.22:** no per-tick flood. The current `issues/runbook` + pin instead logs a one-off burst of the same lines at startup, plus one + `BACnetDateRange ... start/end date` pair per Calendar `Date_List` access. + It's harmless, and bisected and filed as + [#2381](https://github.com/chipkin/cas-bacnet-stack/issues/2381). 2. **Schedule 1's SCHED-E-B remote write works, but the first write can be lost at startup.** `List_Of_Object_Property_References` has two entries, because each `AddScheduleObjectPropertyReference` call APPENDS: a local one @@ -206,15 +209,6 @@ with reproduction steps. peer binds ([#2343](https://github.com/chipkin/cas-bacnet-stack/issues/2343)). The remote target catches up at the Schedule's next `Present_Value` change. -3. **Calendar 1 ("Cream")'s `Date_List` cannot be populated.** There is no - customer-facing export or callback to populate a Calendar object's - `Date_List` (cas-bacnet-stack issue #1758) - inherited from every prior - example in the series that carries a Calendar. Schedule 1's one-off - exception uses an inline calendar-date entry - (`AddScheduleExceptionEventWithCalendarEntry`) instead of a reference to - Cream, which is fully functional and does not depend on this gap. Cream - still exists as a correctly-served object; `Present_Value` always answers - `false` rather than evaluating a `Date_List` that is never populated. ## Reviewing your device @@ -270,10 +264,10 @@ in `accepted`, comes out as a ⚠ row - that is a defect, not a feature. | Symptom | Cause / fix | |---------|-------------| -| On start-up the app prints a wall of red `Error:` lines but the device works | **Expected — mostly not your bug.** Three benign sources: (1) the device receives its **own** broadcast I-Am and logs a decode cascade - any BACnet/IP device that listens for broadcasts hears itself; (2) a one-time *"UUID has not been set..."* BACnet/SC notice, since these IP-only examples never configure that datalink - [#2341](https://github.com/chipkin/cas-bacnet-stack/issues/2341); (3) on stack pins older than 6.0.22 only, a **continuous** `BACnetDateTime::operator =()` flood from `AddTrendLogObject` alone - [#2050](https://github.com/chipkin/cas-bacnet-stack/issues/2050), non-fatal, does not stop the device working. | +| On start-up the app prints a wall of red `Error:` lines but the device works | **Expected — mostly not your bug.** Three benign sources: (1) the device receives its **own** broadcast I-Am and logs a decode cascade - any BACnet/IP device that listens for broadcasts hears itself; (2) a one-time *"UUID has not been set..."* BACnet/SC notice, since these IP-only examples never configure that datalink - [#2341](https://github.com/chipkin/cas-bacnet-stack/issues/2341); (3) a one-off burst of `BACnetDateTime::operator =() ... Failed to set the date/time` lines at startup, and a `BACnetDateRange` pair on each Calendar `Date_List` access - [#2381](https://github.com/chipkin/cas-bacnet-stack/issues/2381) (stack pins older than 6.0.22 instead flooded these every tick - [#2050](https://github.com/chipkin/cas-bacnet-stack/issues/2050)). | | A ReadProperty of `Log_Buffer` on either Trend Log returns `Error(OBJECT, READ_ACCESS_DENIED)` | **Expected — this property is ReadRange-only.** Use ReadRange (`RangeByPosition`), not ReadProperty. | | Schedule 1's remote (SCHED-E-B) write never reaches the peer | Either no peer is running at `REMOTE_DEVICE_INSTANCE` (389002 by default), or the peer is on a different UDP port on the same host - broadcast Who-Is/I-Am does not cross ports, so Device Address Binding cannot resolve it (`tests/sched_e_b_remote_peer.py` works around this with a unicast I-Am). Even when bound, the write made at startup, before binding, is dropped and never re-sent ([#2343](https://github.com/chipkin/cas-bacnet-stack/issues/2343)). See [Known gaps item 2](#known-gaps-in-this-example). | -| Calendar 1 ("Cream")'s `Date_List` reads back empty and `Present_Value` is always `false` | **Expected — inherited stack gap [#1758](https://github.com/chipkin/cas-bacnet-stack/issues/1758).** See [Known gaps item 3](#known-gaps-in-this-example). | +| A Schedule's calendar-reference exception never fires, or a Calendar's `Date_List` reads back empty | The Calendar isn't stack-held. `BACnetStack_AddObject` alone leaves it to your callbacks, and a calendar reference never matches it. Call `BACnetStack_AddCalendarObject` after `AddObject`, then add the entries. | | An optional property you added a callback branch for reads back `Error: unknown-property` | You served it in a `GetProperty*` callback but never called `BACnetStack_SetPropertyEnabled` for it. The stack checks whether a property is enabled *before* calling your callback. This example shipped exactly this bug for the Device's `Description` - see [Adding an object](#adding-an-object-read-this-before-you-copy-any-pattern-in-this-file). | | CMake error: *"CAS BACnet Stack adapter not found under: ..."* | Submodules not initialized. Run `git submodule update --init --recursive` (or pass `-D CAS_STACK_DIR=...`). | | `CASBACnetStackDLL.h: No such file or directory` | Same - submodules not checked out. | diff --git a/docs/PICS.md b/docs/PICS.md index 59946a5..8cc72fa 100644 --- a/docs/PICS.md +++ b/docs/PICS.md @@ -126,7 +126,7 @@ No object is dynamically creatable or deletable. | Notification Class | 1 | Crimson | writable Recipient_List (AE-CRL-B) | | Network Port | 1 | Vermilion | - | | Schedule | 1 | Saffron | - | -| Calendar | 1 | Cream | Date_List not populated - see [TUTORIAL.md](../TUTORIAL.md) | +| Calendar | 1 | Cream | Stack-held Date_List (December 25), writable; drives Schedule 1's calendar-reference exception | | File | 1 | Ivory | writable Archive | | Trend Log | 1 | Lilac | - (Record_Count does not increment - see [TUTORIAL.md](../TUTORIAL.md)) | | Trend Log Multiple | 1 | Magenta | - | @@ -329,7 +329,7 @@ Every object this example creates, and every REQUIRED property of each (per ANSI | Changes_Pending | Boolean | app | no | | Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no | -### Schedule 1 "Saffron" - SCHED-E-B. Present_Value, Effective_Period, Schedule_Default, List_Of_Object_Property_References, Priority_For_Writing and Status_Flags are NOT stack DEFAULTS - they are genuinely held and served by the stack's Schedule engine (BACnetStack_AddScheduleObject plus the BACnetStack_SetSchedule*/AddSchedule* configuration calls in main.cpp). List_Of_Object_Property_References has TWO entries (each BACnetStack_AddScheduleObjectPropertyReference call appends): a LOCAL one at Analog Output 1 (Chartreuse) Present_Value, and a REMOTE one at a peer device's (default instance 389002, e.g. a locally-built B-SA-CPP) Analog Output 1 Present_Value - the SCHED-E-B / F-EXTWRITE remote fan-out. Both writes are wire-verified: the local one is inherited from B-AAC's SCHED-I-B, and the remote one was checked with tests/sched_e_b_remote_peer.py on stack 6.0.22. The stack drops the startup write made before the peer is bound (cas-bacnet-stack issue #2343) - see TODO.md item 2. One weekly transition (Monday 08:00) and one calendar-date exception (2026-12-25, via the inline calendar-entry form) are seeded at start-up; the 's' key (common/'s DemoAdvance) adds a transition for right now so the change can be observed without waiting for the wall clock +### Schedule 1 "Saffron" - SCHED-E-B. Present_Value, Effective_Period, Schedule_Default, List_Of_Object_Property_References, Priority_For_Writing and Status_Flags are NOT stack DEFAULTS - they are genuinely held and served by the stack's Schedule engine (BACnetStack_AddScheduleObject plus the BACnetStack_SetSchedule*/AddSchedule* configuration calls in main.cpp). List_Of_Object_Property_References has TWO entries (each BACnetStack_AddScheduleObjectPropertyReference call appends): a LOCAL one at Analog Output 1 (Chartreuse) Present_Value, and a REMOTE one at a peer device's (default instance 389002, e.g. a locally-built B-SA-CPP) Analog Output 1 Present_Value - the SCHED-E-B / F-EXTWRITE remote fan-out. Both writes are wire-verified: the local one is inherited from B-AAC's SCHED-I-B, and the remote one was checked with tests/sched_e_b_remote_peer.py on stack 6.0.22. The stack drops the startup write made before the peer is bound (cas-bacnet-stack issue #2343) - see TODO.md item 2. One weekly transition (Monday 08:00) and one exception - a calendar reference to Calendar 1 (Cream), whose Date_List holds December 25 - are seeded at start-up; the 's' key (common/'s DemoAdvance) adds a transition for right now so the change can be observed without waiting for the wall clock | Property | Datatype | Served by | Writable | |---|---|---|:---:| @@ -346,15 +346,15 @@ Every object this example creates, and every REQUIRED property of each (per ANSI | Out_Of_Service | Boolean | app | no | | Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no | -### Calendar 1 "Cream" - exists for SCHED-E-B completeness alongside Saffron's exception, but its Date_List cannot be populated through the customer API (cas-bacnet-stack issue #1758 - no read path for a Calendar object's Date_List; the only generic constructed-property callback is test-tool-only). Present_Value therefore always answers false rather than evaluating a Date_List that is never populated - see TODO.md +### Calendar 1 "Cream" - stack-held (BACnetStack_AddCalendarObject, cas-bacnet-stack IFC-045 / #1758): the stack stores Date_List (one entry, December 25 of every year, added with BACnetStack_AddCalendarDateEntry) and derives Present_Value from the device's Local_Date. Date_List is WRITABLE (WriteProperty / AddListElement / RemoveListElement) via BACnetStack_SetPropertyWritable. Schedule 1 (Saffron)'s exception is a calendar reference to this object, so any date in Date_List drives Saffron to its exception value | Property | Datatype | Served by | Writable | |---|---|---|:---:| | Object_Identifier | BACnetObjectIdentifier | stack | no | | Object_Name | CharacterString | app | no | | Object_Type | BACnetObjectType | stack | no | -| Present_Value | Boolean | app | no | -| Date_List | BACnetLIST of BACnetCalendarEntry | stack default, accepted (None known - a read fails with `unknown-property` or an empt) | no | +| Present_Value | Boolean | stack | no | +| Date_List | BACnetLIST of BACnetCalendarEntry | stack | yes | | Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no | ### File 1 "Ivory" - DM-BR-B. A small in-memory STREAM-access file that AtomicReadFile/AtomicWriteFile operate on, and the backup/restore payload for ReinitializeDevice's STARTBACKUP/ENDBACKUP/STARTRESTORE/ENDRESTORE/ABORTRESTORE states (2-6), all accepted by ReinitializeDevice alongside COLDSTART/WARMSTART. BACnetStack_SetBackupAndRestoreEnabled plus the four Prepare/Complete Backup/Restore callbacks are registered. Verified live: File_Size reads 0 (nothing written yet this session) and a WriteProperty of Archive=true reads back correctly diff --git a/docs/objects.json b/docs/objects.json index 531ae7e..b7ca1e5 100644 --- a/docs/objects.json +++ b/docs/objects.json @@ -131,17 +131,18 @@ "enabled": [], "writable": [], "accepted": ["Present_Value", "Effective_Period", "Priority_For_Writing"], - "note": "SCHED-E-B. Present_Value, Effective_Period, Schedule_Default, List_Of_Object_Property_References, Priority_For_Writing and Status_Flags are NOT stack DEFAULTS - they are genuinely held and served by the stack's Schedule engine (BACnetStack_AddScheduleObject plus the BACnetStack_SetSchedule*/AddSchedule* configuration calls in main.cpp). List_Of_Object_Property_References has TWO entries (each BACnetStack_AddScheduleObjectPropertyReference call appends): a LOCAL one at Analog Output 1 (Chartreuse) Present_Value, and a REMOTE one at a peer device's (default instance 389002, e.g. a locally-built B-SA-CPP) Analog Output 1 Present_Value - the SCHED-E-B / F-EXTWRITE remote fan-out. Both writes are wire-verified: the local one is inherited from B-AAC's SCHED-I-B, and the remote one was checked with tests/sched_e_b_remote_peer.py on stack 6.0.22. The stack drops the startup write made before the peer is bound (cas-bacnet-stack issue #2343) - see TODO.md item 2. One weekly transition (Monday 08:00) and one calendar-date exception (2026-12-25, via the inline calendar-entry form) are seeded at start-up; the 's' key (common/'s DemoAdvance) adds a transition for right now so the change can be observed without waiting for the wall clock" + "note": "SCHED-E-B. Present_Value, Effective_Period, Schedule_Default, List_Of_Object_Property_References, Priority_For_Writing and Status_Flags are NOT stack DEFAULTS - they are genuinely held and served by the stack's Schedule engine (BACnetStack_AddScheduleObject plus the BACnetStack_SetSchedule*/AddSchedule* configuration calls in main.cpp). List_Of_Object_Property_References has TWO entries (each BACnetStack_AddScheduleObjectPropertyReference call appends): a LOCAL one at Analog Output 1 (Chartreuse) Present_Value, and a REMOTE one at a peer device's (default instance 389002, e.g. a locally-built B-SA-CPP) Analog Output 1 Present_Value - the SCHED-E-B / F-EXTWRITE remote fan-out. Both writes are wire-verified: the local one is inherited from B-AAC's SCHED-I-B, and the remote one was checked with tests/sched_e_b_remote_peer.py on stack 6.0.22. The stack drops the startup write made before the peer is bound (cas-bacnet-stack issue #2343) - see TODO.md item 2. One weekly transition (Monday 08:00) and one exception - a calendar reference to Calendar 1 (Cream), whose Date_List holds December 25 - are seeded at start-up; the 's' key (common/'s DemoAdvance) adds a transition for right now so the change can be observed without waiting for the wall clock" }, { "type": "Calendar", "instance": 1, "name": "Cream", - "app": ["Object_Name", "Present_Value"], + "app": ["Object_Name"], + "stack": ["Present_Value", "Date_List"], "enabled": [], - "writable": [], - "accepted": ["Date_List"], - "note": "exists for SCHED-E-B completeness alongside Saffron's exception, but its Date_List cannot be populated through the customer API (cas-bacnet-stack issue #1758 - no read path for a Calendar object's Date_List; the only generic constructed-property callback is test-tool-only). Present_Value therefore always answers false rather than evaluating a Date_List that is never populated - see TODO.md" + "writable": ["Date_List"], + "accepted": [], + "note": "stack-held (BACnetStack_AddCalendarObject, cas-bacnet-stack IFC-045 / #1758): the stack stores Date_List (one entry, December 25 of every year, added with BACnetStack_AddCalendarDateEntry) and derives Present_Value from the device's Local_Date. Date_List is WRITABLE (WriteProperty / AddListElement / RemoveListElement) via BACnetStack_SetPropertyWritable. Schedule 1 (Saffron)'s exception is a calendar reference to this object, so any date in Date_List drives Saffron to its exception value" }, { "type": "File", diff --git a/main.cpp b/main.cpp index 3778355..3682211 100644 --- a/main.cpp +++ b/main.cpp @@ -34,12 +34,7 @@ // Deliberately OMITTED: AE-ESUM-B (GetAlarmSummary) is not required at or above // Protocol_Revision 13, so it is not implemented here. // -// WHAT IS NOT IMPLEMENTED (see README.md "What this example does NOT do" + TODO.md): -// - Calendar 1 "Cream"'s Date_List: there is no customer-facing export or -// callback to populate a Calendar object's Date_List (cas-bacnet-stack -// issue #1758), so Schedule 1 "Saffron"'s one-off exception uses an inline -// calendar-date entry rather than a reference to Cream. Inherited from every -// prior example that carries a Calendar (B-AAC, B-ACC, B-LS). +// Known stack gaps this example works around are listed in TODO.md. // // The device keeps the full B-AAC object set (three read-only inputs, three // commandable outputs, the alarm-capable Analog Value + Notification Class, @@ -59,7 +54,8 @@ // Network Port 1 "Vermilion" (the BACnet/IP port - required) // Schedule 1 "Saffron" (drives Chartreuse on a weekly + exception basis, // and a remote peer object - SCHED-E-B) -// Calendar 1 "Cream" (see TODO.md - Date_List not evaluated) +// Calendar 1 "Cream" (stack-held Date_List: every December 25; +// Date_List WRITABLE; drives Saffron's exception) // File 1 "Ivory" (backup/restore payload - DM-BR-B) // Trend Log 1 "Lilac" (polled log of Analog Input 1 "Bronze") // Trend Log Multiple 1 "Magenta" (polled log of several points) @@ -119,7 +115,7 @@ using namespace CASBACnetStackExampleConstants; // 1. Example + device configuration // ----------------------------------------------------------------------------- static const char* APP_NAME = "BACnet B-BC (Building Controller) Example - C++"; -static const char* APP_VERSION = "1.0.6"; +static const char* APP_VERSION = "1.0.7"; // The device instance. BACnet requires this to be configurable, so it defaults // to 389005 and can be overridden on the command line with --deviceID. Keep it @@ -291,9 +287,8 @@ static uint8_t RECIPIENT_IP[4] = { 0, 0, 0, 0 }; // used when not broadcasting // --- SCHED-I-B: Schedule 1 "Saffron" drives Analog Output 1 (Chartreuse) ------- // A weekly transition sets Chartreuse to SCHEDULE_DEMO_VALUE; outside any scheduled -// window Schedule_Default applies instead. Calendar 1 "Cream" exists as a readable -// object alongside the exception (see TODO.md for why it is not wired to the -// exception's period - cas-bacnet-stack issue #1758). +// window Schedule_Default applies instead. Saffron's one exception references +// Calendar 1 "Cream": on any date in Cream's Date_List, the exception value wins. static const uint32_t SCHEDULE_INSTANCE = 1; // "Saffron" static const uint32_t CALENDAR_INSTANCE = 1; // "Cream" static const uint8_t SCHEDULE_WRITE_PRIORITY = 8; // mid-range: below manual overrides at 1-7 @@ -308,6 +303,7 @@ static const uint16_t OBJECT_TYPE_SCHEDULE = 17; static const uint16_t OBJECT_TYPE_CALENDAR = 6; static const uint32_t PROPERTY_IDENTIFIER_RELIABILITY = 103; static const uint32_t PROPERTY_IDENTIFIER_RECIPIENT_LIST = 102; +static const uint32_t PROPERTY_IDENTIFIER_DATE_LIST = 23; static const uint32_t RELIABILITY_NO_FAULT_DETECTED = 0; // --- DM-BR-B: File 1 "Ivory" (backup/restore payload carrier) - the B-ACC addition --- @@ -723,16 +719,6 @@ bool GetPropertyBool(const uint32_t deviceInstance, const uint16_t objectType, if (deviceInstance != g_deviceInstance) { return false; } - // Calendar 1 (Cream) Present_Value (required): true when today's date is in - // Date_List. This example cannot populate a Calendar object's Date_List - // through the customer API (cas-bacnet-stack issue #1758 - see TODO.md), so - // there is nothing to evaluate against; always answer false rather than - // fabricate a match. - if (objectType == OBJECT_TYPE_CALENDAR && objectInstance == CALENDAR_INSTANCE && - propertyIdentifier == PROPERTY_IDENTIFIER_PRESENT_VALUE) { - *value = false; - return true; - } // Commandable outputs: the stack asks "is this Priority_Array slot null?" with // the boolean getter. Answer true (1) for a relinquished slot, false (0) for a // commanded one. This is how the stack knows which slots to skip when computing @@ -1889,10 +1875,36 @@ int main(int argc, char** argv) { printf("Error: Failed to add Schedule 1 (Saffron).\n"); return 1; } + // Calendar 1 (Cream) is STACK-HELD: after BACnetStack_AddCalendarObject the + // stack stores Cream's Date_List, serves it on ReadProperty, and derives + // Present_Value itself (TRUE when the device's Local_Date matches any entry, + // re-checked every tick, with COV). No Present_Value / Date_List callback is + // needed - the stack answers first. (A Calendar added only with + // BACnetStack_AddObject is still served by your callbacks, as before.) if (!BACnetStack_AddObject(g_deviceInstance, OBJECT_TYPE_CALENDAR, CALENDAR_INSTANCE)) { printf("Error: Failed to add Calendar 1 (Cream).\n"); return 1; } + if (!BACnetStack_AddCalendarObject(g_deviceInstance, CALENDAR_INSTANCE)) { + printf("Error: Failed to make Calendar 1 (Cream) stack-held.\n"); + return 1; + } + // One Date_List entry: December 25 of EVERY year (year 0 = any year, + // weekday 255 = any day of the week). BACnetStack_AddCalendarDateRangeEntry + // and BACnetStack_AddCalendarWeekNDayEntry add the other two + // BACnetCalendarEntry forms (a date range; e.g. "4th Thursday of November"). + if (!BACnetStack_AddCalendarDateEntry(g_deviceInstance, CALENDAR_INSTANCE, + 0 /*any year*/, 12, 25, 255 /*any weekday*/)) { + printf("Error: Failed to add Cream's December 25 Date_List entry.\n"); + return 1; + } + // Let BACnet clients edit the holiday list (WriteProperty, AddListElement, + // RemoveListElement on Date_List). Read-only by default. + if (!BACnetStack_SetPropertyWritable(g_deviceInstance, OBJECT_TYPE_CALENDAR, CALENDAR_INSTANCE, + PROPERTY_IDENTIFIER_DATE_LIST, true)) { + printf("Error: Failed to make Cream's Date_List writable.\n"); + return 1; + } if (!BACnetStack_AddScheduleObject(g_deviceInstance, SCHEDULE_INSTANCE)) { printf("Error: Failed to create the stack-held schedule data for Saffron.\n"); return 1; @@ -1947,24 +1959,23 @@ int main(int argc, char** argv) { printf("Error: Failed to add Saffron's weekly Monday 08:00 transition.\n"); return 1; } - // One exception: an inline calendar-date entry (periodType 0 = a single date, - // here 2026-12-25) rather than a reference to Cream's Date_List - Cream's - // Date_List cannot be populated through the customer API yet (cas-bacnet-stack issue #1758; - // see TODO.md), so a calendar-REFERENCE exception would be stored but would - // never actually match. The inline form has no such dependency. + // One exception: a CALENDAR REFERENCE to Cream. On every date in Cream's + // Date_List (December 25, plus anything a client adds), the exception's + // time-value applies from 00:00 and overrides the weekly schedule. The + // Calendar must be stack-held (above) for a reference to ever match. + // (BACnetStack_AddScheduleExceptionEventWithCalendarEntry is the inline + // alternative: the date lives in the Schedule itself, not in a Calendar.) uint32_t exceptionIndex = 0; - if (!BACnetStack_AddScheduleExceptionEventWithCalendarEntry( - g_deviceInstance, SCHEDULE_INSTANCE, 0 /*periodType: calendar Date*/, - 2026, 12, 25, 255 /*wd1: any*/, - 0, 255, 255, 255 /*y2/m2/d2/wd2: unused for periodType 0*/, + if (!BACnetStack_AddScheduleExceptionEventWithCalendarReference( + g_deviceInstance, SCHEDULE_INSTANCE, CALENDAR_INSTANCE, 1 /*eventPriority: highest*/, &exceptionIndex)) { - printf("Error: Failed to add Saffron's 2026-12-25 exception event.\n"); + printf("Error: Failed to add Saffron's Calendar 1 (Cream) exception event.\n"); return 1; } if (!BACnetStack_AddScheduleExceptionTimeValue(g_deviceInstance, SCHEDULE_INSTANCE, exceptionIndex, 0, 0, 0, 0, 4 /*Real*/, 0, SCHEDULE_EXCEPTION_VALUE)) { - printf("Error: Failed to add Saffron's 2026-12-25 exception time-value.\n"); + printf("Error: Failed to add Saffron's Cream exception time-value.\n"); return 1; } diff --git a/submodules/cas-bacnet-stack b/submodules/cas-bacnet-stack index 22ac3c9..00aa2d0 160000 --- a/submodules/cas-bacnet-stack +++ b/submodules/cas-bacnet-stack @@ -1 +1 @@ -Subproject commit 22ac3c986d3a1c46028527d356ddd80673715bf6 +Subproject commit 00aa2d0e0751b46c839fde1cc1e1bc1c282d410b diff --git a/tests/calendar_reference_check.py b/tests/calendar_reference_check.py new file mode 100644 index 0000000..5b32d7b --- /dev/null +++ b/tests/calendar_reference_check.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +"""Ad hoc check of Calendar 1 "Cream" (stack-held) driving Schedule 1 "Saffron"'s exception. + +Reads Cream's Date_List and Present_Value, writes a Date_List that adds TODAY (the device's +Local_Date), then confirms Cream's Present_Value goes TRUE, Saffron's calendar-reference exception +takes over (Present_Value = the exception value), and Analog Output 1 "Chartreuse" follows. Finally +it writes the original Date_List back. + +Usage (B-BC running on --port 47900 on this host): + python tests/calendar_reference_check.py --target-port 47900 +Prints RESULT: PASS on success. +""" +import asyncio +import datetime + +from bacpypes3.app import Application +from bacpypes3.argparse import SimpleArgumentParser +from bacpypes3.basetypes import CalendarEntry +from bacpypes3.constructeddata import ListOf +from bacpypes3.pdu import Address +from bacpypes3.primitivedata import Date, ObjectIdentifier + +EXCEPTION_VALUE = 5.0 # SCHEDULE_EXCEPTION_VALUE in main.cpp + + +async def main(): + p = SimpleArgumentParser() + p.set_defaults(address="127.0.0.1/32:47903") + p.add_argument("--target-port", type=int, default=47900) + a = p.parse_args() + app = Application.from_args(a) + dev = Address(f"127.0.0.1:{a.target_port}") + cream = ObjectIdentifier("calendar,1") + saffron = ObjectIdentifier("schedule,1") + chartreuse = ObjectIdentifier("analog-output,1") + + async def rd(obj, prop): + return await app.read_property(dev, obj, prop) + + try: + original = await rd(cream, "date-list") + print("Cream Date_List before:", [str(e.date) for e in original]) + print("Cream Present_Value before:", await rd(cream, "present-value")) + print("Saffron Present_Value before:", await rd(saffron, "present-value")) + + today = datetime.date.today() # the device serves Local_Date from local wall-clock time + entries = list(original) + [ + CalendarEntry(date=Date((today.year - 1900, today.month, today.day, today.isoweekday()))) + ] + await app.write_property(dev, cream, "date-list", ListOf(CalendarEntry)(entries)) + print("wrote Cream Date_List + today", today) + + await asyncio.sleep(1.5) # Present_Value is re-derived every tick; the Schedule re-evaluates + cream_pv = await rd(cream, "present-value") + saffron_pv = await rd(saffron, "present-value") + chartreuse_pv = await rd(chartreuse, "present-value") + print("Cream Date_List after:", [str(e.date) for e in await rd(cream, "date-list")]) + print("Cream Present_Value after:", cream_pv) + print("Saffron Present_Value after:", saffron_pv) + print("Chartreuse Present_Value after:", chartreuse_pv) + + ok = bool(cream_pv) and abs(float(chartreuse_pv) - EXCEPTION_VALUE) < 0.01 + await app.write_property(dev, cream, "date-list", ListOf(CalendarEntry)(list(original))) + await asyncio.sleep(1.5) + print("restored Date_List; Cream Present_Value:", await rd(cream, "present-value"), + "Chartreuse:", await rd(chartreuse, "present-value")) + print("RESULT:", "PASS" if ok else "FAIL") + finally: + app.close() + + +if __name__ == "__main__": + asyncio.run(main())