Hard coded tags in PICED

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by abg, Mar 19, 2008.

  1. abg

    abg

    Joined:
    Dec 25, 2007
    Messages:
    208
    Likes Received:
    2
    Location:
    Sydney
    Hi All

    This is my first post so please be gentle with me! I've been reading the forums for many months and the open nature of the communications within the C-Bus world is what convinced me to go this way. It is an excellent forum and greatly appreciated !

    I am currently building a new house and installing C-Bus. The sparky is doing all the 240v and C-Bus terminations (and has done this before) and I'll be doing the setup and programming. I am pretty comfortable with what needs to be done to make things work. I've also done all the Clipsal training courses.

    Looking at PICED (and having done the Logic course) it seems that all the examples use hard-code the tag names such as GetLightingLevel("Kitchen").

    I know that PICED is a modified version of PASCAL and that "Kitchen" is interpreted by the compiler and translates this tag to an integer value representing the actual group address.

    Hard coding strings have always been a big no-no in (most) software development so I was hoping to find a way not to do this. My query is if there is a way to generate the group address dynamically either by initialising a variable or using a constant and passing this to the function. That way it is only necessary to change the value in one place, and not in (potentially) many places throughout code.

    The compiler doesn't like using a string variable in the functions such as GetLightingLevel(myString) - it only seems to accept literal double-quoted strings GetLightinglevel("Kitchen").

    I'd thought perhaps I could fool the compiler by using the StringToInt function and passing a string initialised by
    declared as

    myString : string;

    and intialised as

    myString := '"Kitchen"'; (Double-quoted string in real single quoted string)

    so the call in the logic would be
    GetLightingLevel(StringToInt(myString))

    but unfortunately whilst this compiles and runs it doesn't give actually use the proper integer value from the tag.

    Hope this makes sense (at least a little) and isn't too silly a question. Any feedback greatly appreciated.
     
    abg, Mar 19, 2008
    #1
  2. abg

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    You are correct in what you say above - however you need to click the handbrake on for a second and consider what the above means - The "Kitchen" reference is the tag description for a Group Address which is normally established via Toolkit when commissioning the underlying C-Bus install.

    Again you need to remember when it comes to working with actual C-Bus groups (as opposed to trigger, enable etc type groups) associated with output channels, wiring, loads - (stuff that happens) these group addresses (objects) will be established at the Toolkit stage. Now ask yourself how many times are you going to physically change the kitchen ?
    Even if you add another circuit / channel of lights in the Kitchen then you will commission the C-Bus spare channel etc with say "Kitchen Bench" and off to PICED to hack some some code around the new channel.

    Keep your life simple dude !
     
    Last edited by a moderator: Mar 20, 2008
    Lucky555, Mar 20, 2008
    #2
  3. abg

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You are welcome.

    The logic help file gives examples for every C-Bus function with tags and with numerical values.

    Correct.

    You could just use an integer variable which gets set dynamically and then use that. For example :

    Code:
    { global variables }
    TheLight : integer;
    
    { module code }
    TheLight := 20;
    ...
    SetLightingState(TheLight, On);
    
    A more commonly used method is to use constants :

    Code:
    { constants }
    TheLight = 20;
    
    { module code }
    SetLightingState(TheLight, On);
    
    I will update the help file to provide the above examples.

    Your problems from here on are caused by confusing tags and string. They are completely different concepts. See the logic help file topic "tags" for clarification.
     
    Darren, Mar 24, 2008
    #3
  4. abg

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    The logic help file topic "Logic Templates" sort of covered this general idea, but needed to be more specific. It will be updated to read :

    Do you think this will cover it, or will more explanation be required ?
     
    Darren, Mar 24, 2008
    #4
  5. abg

    abg

    Joined:
    Dec 25, 2007
    Messages:
    208
    Likes Received:
    2
    Location:
    Sydney
    Appreciate the feedback.

    Lucky555 you're right - these won't change very often (if at all) - just being fussy about these tags scattered around the code......

    Darren - using constants with names matching the group name and setting them as integer values matching the group address will certainly solve the problem. Your example is fine - no further explanation needed!

    Many thanks

    Andrew
     
    abg, Mar 25, 2008
    #5
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.