DALI application (0x5f) MMI messages

Discussion in 'General Discussion' started by zigenz, Jan 20, 2013.

  1. zigenz

    zigenz

    Joined:
    Jun 5, 2012
    Messages:
    14
    Likes Received:
    1
    Location:
    Perth, WA
    Hello,

    Been working for the last couple of weeks after work on a Windows Phone 8 application for CBus control. Managed to build and link the CBus module and have written an efficient multithreaded transport adaptation layer using the new parallel processing libraries that come with VC++11. For those of you that enjoy C++, if you haven't played with the new ppltasks library yet I'd recommend you do if you get a chance - they're terribly elegant. I'm able to bring the link up, issue commands and get responses.

    In my CBus installation, the majority of my lights are on DALI, but I am as of yet unable to get the CBus module to populate the database with the current state of the DALI units. The process I am going through is the following:
    1. I've modified the source code to add DALI to the list of pre-registered applications by including the following line:
    cbus_lighting_i_app_list[3] = CBUS_DALI_APP; // CBUS_DALI_APP = 0x5f
    2. I register a callback using the "cbus_lighting_vf_register_MMI_event_handler" API
    3. Once the CBus connection comes up, I issue the following command: cbus_lighting_vf_initiate_level_MMI( 0, 0x5f, 1 );
    4. I receive no MMI messages from application 0x5f, and in fact I receive a number of messages in the MMI event handler with an application of 0x38 (i.e. the default lighting application), telling me the current level of all active group in application 0x38.

    I'm still pretty green around the API (have only started using it this afternoon in earnest after getting the comms working nicely), so I could be doing something silly, but since I'm yet to delve through the CBus Module code, a bit of guidance would be appreciated.

    Thanks in advance. :)

    Cheers,
    Zyrus
     
    zigenz, Jan 20, 2013
    #1
  2. zigenz

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,397
    Likes Received:
    26
    Location:
    Adelaide, South Australia
    Simple answer to all this: You can't.

    Long answer:

    Firstly, DALI has no persistant state. This means you can't interrogate a thing somewhere in DALI-land and get the state of everything. You can visit every ballast / driver and get its current level, but this is very slow and tedious.

    Secondly, DALI has non-deterministic group / scene / address mapping. That is, (for example), you can make dali group 1 contain short addresses 1, 2, 3. Then you can make dali group 2 contain short addresses 1, 2 (but not 3). Then you can do control by short address, or group (or scene just to add even more complexity). So to find the state of something, do you ask for the group state (oops, thats broken if I control a short address), or the short address state (but I can't get that w/o interrogating every ballast if I do control by groups or scenes).

    The C-Bus / DALI gateway treats a DALI line as a big fat 64 channel dimmer. It converts C-Bus groups to DALI short addresses, and pushes the appropriate DALI messages out the other side.

    The C-Bus / DALI gateway does not response to MMI requests, and can't model the DALI line(s) - because as above the way DALI works is close on orthogonal to how C-Bus works. Doubly so when there are other control devices pushing DALI control messages out which the DALI gateway *could* see and partially model.... but this just makes it far more complex and error-prone (so it does not).

    C-Bus allows symmetric setup, monitoring, control, and easy interrogation. C-Bus has persistent and guaranteed consistent state information scattered through the network. DALI is essentially a stateless lump of write-only memory. Mapping C-Bus -> DALI is fairly straightforward, because you can make a 1:1 mapping. But mapping DALI -> C-Bus is very difficult because DALI allows 1:N control from single commands, and mapping N:1 back to C-Bus is damn near impossible.

    The only solution if you are lucky enough to have C-Bus present is:

    - Have a device on the C-Bus network which monitors the communication and builds a state model
    - Have your mobile device interrogate that C-Bus connected device to get its view the universe, built from the state model.

    Now, before you go "oh you are a bunch of dumb clucks for not solving this", consider that during design this single issue caused untold hours of discussion, meetings, drawing pictures on whiteboards, and suggestions of possible (sucky) solutions. It was not ignored, it was considered. Rather a lot.

    The problem with sucky solutions that might work some of the time is that nobody reads all the qualifications and caveats that you need in order to say "here is something you might do, it works 15% of the time, the rest of the time stuff will happen but it will be the wrong stuff and when that happens don't complain because we warned you." What happens is that the warning is ignored, bad stuff happens, and there is much wailing and gnashing of teeth. So this then becomes "but why did you not stop me doing bad stuff", and the answer is: we did. That's why you can't do things using the DALI gateway that are bad.
     
    Last edited by a moderator: Jan 21, 2013
    ashleigh, Jan 21, 2013
    #2
  3. zigenz

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,427
    Likes Received:
    64
    Location:
    Adelaide
    Sounds like you have done everything right, unfortunately the reason you are not seeing any MMIs on the DALI application is because there aren't any!

    There are 2 things required for an MMI to work

    1) You need key input units set to that application. These are what initiate (and listen to) the MMI.

    2) You need an output unit that is controlling groups on that application. IT is the output units that are the keepers of the group state.

    Unfortunately for you, the DALI gateway is not an output unit (it's just a gateway to DALI), and there's no way to quickly interrogate the state of the DALI side.

    There is a roundabout way to get the state using the Error Reporting feature of the DALI gateway, as the on/off state is included in the error report data, however this report takes some time to complete, so it's not really suitable for a mobile client that needs to get state quickly, and the client would also need to know the C-Bus group to DALI ballast mapping.

    Nick
     
    Last edited by a moderator: Jan 21, 2013
    NickD, Jan 21, 2013
    #3
  4. zigenz

    zigenz

    Joined:
    Jun 5, 2012
    Messages:
    14
    Likes Received:
    1
    Location:
    Perth, WA
    Thanks for the responses guys.

    I suspected the "stateless" nature of DALI may have been the reason why. After working on various engineering projects for many years, I know not to assume something is "stupid" at first glance - there are often complex reasons behind something seemingly silly.

    That said, it seems like I should be able to do the following:
    - include a one-off configuration step which:​
    - initiates a discovery and keeps a local store of input units / channels with the DALI application​
    - requests the user to name the DALI groups​

    And then each time the device joins the network:
    on thread A:​
    - render the UI on the device with relevant input method for each group (sliders for dimmers, on/off for digital I/O etc.) all disabled​
    on thread B:​
    - perform an MMI to obtain the levels of applications / groups that have a persisted CBus state​
    - perform a level request on input units which have the DALI application to obtain the levels of the DALI groups​
    - notify thread A each time a level becomes available at which point input control on the device will be set to the current value and become enabled​

    Given that it's unlikely that I will want to use the application the minute I join the network, this can occur in the background the moment the device detects I am connected to the relevant network, so I suspect that at least 80% of the time, when I want to actuate "something", its state will have been identified and I shan't have to wait.

    Another question: In my comms adaptation layer, I have replicated the 50ms loop in cbus_comms.c which I suspect may cause battery life issues. As my TCP socket notifies me when data is available in the receive buffer and/or the send buffer is not empty, do you envisage an issue in simply firing off the loop when there is data pending in the send / receive buffers?

    Appreciate the help.

    Cheers,
    Zyrus
     
    zigenz, Jan 21, 2013
    #4
  5. zigenz

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,397
    Likes Received:
    26
    Location:
    Adelaide, South Australia
    The 50 ms loop is there so that regular updates can be run.

    This gives the following:

    - it keeps the internal models of the C-Bus Module up-to-date (example: C-Bus ramp commands initiate a ramp, but then every unit that has an interest in that group and the running ramp run their own independent models, this requires regular timers to run updates so that the internal level model can be updated)

    - it is used to form a timeout / health check for the connectivity to the C-Bus PCI or CNI. The reason here is that otherwise there is no way to know the connection is down until you come to use it. Often this is not a problem - but people like to know the connection is down, when its down (or very soon thereafter) and for a serial PCI this allows a determination of an interface failure within about 4 seconds [on a CNI, TCP will be a determining factor and a detection period of about 90 seconds should be expected].

    There are also numerous other places where the regular timer ticks are used, so just turning it off *may* be problematic.

    -----------

    The approach you propose for trying to find state is still going to be prone to error. The reason being that the state information which is populated into MMI's (be they state MMIs that only contain on/off, or Level MMIs) comes from C-Bus output units only. Input units, eg switches, will perform reconciliation of state error, and they arbitrate amongst themselves to determine who will initiate MMIs. But input units don't have any state that can be interrogated using MMIs.

    The fundamental problem you face when using the DALI gateway is that the mapping from C-Bus groups to DALI Short Addresses is done in the gateway, making "stuff" happen in DALI. But there is no C-Bus output unit which stores the levels, has the state, and populates the MMI. You can run MMI's, but there won't be anything to drop the information into the MMI for you*.

    A Client/server approach using 2 devices (one permanently attached, the other mobile) WILL work, provided the fixed device watches all the network traffic and builds its own internal state model by watching the changes as they whiz by on the network. This device will still suffer the problem of finding the initial state because on power up, the groups + DALI short address + state model will all be unsynchronised - and there is no way of forcing them to become synchronised.

    I might add: The Wiser product does all this, there's a reason Wiser is the way it is :) Wiser actually uses the C-Bus Module to build the state model.

    ----

    * Nitpickers corner: If you have a C-Bus group, and an relay or dimmer unit which uses that group, and that group is also shared with and used in the DALI gateway, then there will be a source of information to populate the MMI. However, this is not the case which you described so it very likely does not apply.
     
    Last edited by a moderator: Jan 21, 2013
    ashleigh, Jan 21, 2013
    #5
  6. zigenz

    zigenz

    Joined:
    Jun 5, 2012
    Messages:
    14
    Likes Received:
    1
    Location:
    Perth, WA
    Thanks Ashleigh.

    This exchange has given me a few ideas - I will try them out and post the results here.

    Nick: Can you explain how one would retrieve the error report data using the CBus Module?

    Cheers,
    Zyrus
     
    Last edited by a moderator: Jan 21, 2013
    zigenz, Jan 21, 2013
    #6
  7. zigenz

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,427
    Likes Received:
    64
    Location:
    Adelaide
    1) In cbus_config.h, ensure CBUS_USE_ERROR_REPORTING_APPLICATION is defined
    2) Register a handler for error reporting messages
    3) Configure your DALI gateway with a trigger group/action selector to trigger error reports
    4) Send the trigger message to kick off the error reports.
    5) Wait for 128 error reports to trickle in

    Note that in the DALI gateway, when error reporting is enabled, the ballast status is polled as a background task. This takes several minutes to complete all 128 possible ballast addresses.

    When you trigger an error report, it starts sending the error reports with the most up to date value it has retireved from the DALI network. Because these two processes are asynchronous, you may not always see the result of a state change until the latest error report (for example if the state change happened just after the ballast was polled, you will not see the result until it is polled the next time).

    Nick

    You should then receive a
     
    NickD, Jan 21, 2013
    #7
  8. zigenz

    zigenz

    Joined:
    Jun 5, 2012
    Messages:
    14
    Likes Received:
    1
    Location:
    Perth, WA
    Thanks Nick - I don't envisage that a 3 min delay will pose an unbearable issue in this application.

    Will let you know how I go.

    Cheers,
    Zyrus
     
    zigenz, Jan 21, 2013
    #8
  9. zigenz

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    Sorry to breaker in on this thread but I was wondering the other day if the DMX gateway responded to MMI requests? I know it is a gateway but becasue it is DMX there is no 2 way comms and the likely hood in most cases of other DMX transmitters being merged in are slim.
     
    jboer, Jan 21, 2013
    #9
  10. zigenz

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,427
    Likes Received:
    64
    Location:
    Adelaide
    The DMX Gateway does actually contribute to MMIs (as does the DSI Gateway.. for the record). I guess my assertion that the DALI GAteway didn't because it was a gateway was a bit misleading :)

    Nick
     
    NickD, Jan 21, 2013
    #10
  11. zigenz

    zigenz

    Joined:
    Jun 5, 2012
    Messages:
    14
    Likes Received:
    1
    Location:
    Perth, WA
    Hi Nick,

    Did as you suggested last night and am getting the error messages streaming through. :)

    I know this is a RTFM qn, but can you either explain to me how to interpret the callback arguments or at the very least point me to the right doco to interpret the message data correctly?

    Thanks for your help.

    Cheers,
    Zyrus
     
    zigenz, Jan 22, 2013
    #11
  12. zigenz

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,427
    Likes Received:
    64
    Location:
    Adelaide
    Ah.. good point. You will need the Error Reporting Application documenation.

    You can get this here.

    AS far as the parameters, you are really only interested in the System Category (to check the message is actually from a DALI Gateway), the Device ID (which tels you which DALI Gateway), and then the Error Data bytes. The protocol doco will tell you what each of these mean.

    Nick
     
    NickD, Jan 23, 2013
    #12
  13. zigenz

    zigenz

    Joined:
    Jun 5, 2012
    Messages:
    14
    Likes Received:
    1
    Location:
    Perth, WA
    Been a busy week or so and now have a chance to get back to things!

    I've had a cursory look through the Open C-Bus Serial Protocol docs and can't seem to find too much on "discovery". Specifically in regards to input units, I can fire off a discovery sequence and make sense of the messages, but it is not directly obvious to me as to how one figures out which application is assigned to which key.

    May I ask for some guidance as to how to achieve this?

    Thank you. :)

    Cheers,
    Zyrus
     
    zigenz, Jan 31, 2013
    #13
  14. zigenz

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,397
    Likes Received:
    26
    Location:
    Adelaide, South Australia
    You can't.

    Keys emit messages on either the unit primary or secondary application, depending on how the unit has been set up.

    You can discover devices on the network, and the status (on/off) or level of groups.

    Group status and level comes from output units (only).

    All units can report their presence for determining if they exist.

    You can't delve deeper than that in the programming of key units. Doing that requires the non-published commands used for commissioning.
     
    ashleigh, Jan 31, 2013
    #14
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.