Hello All,
One of my colleagues/friend pointed me to your community here suggesting, I would be able to discuss my problem/dilemma I came across while writing some program-objects.
I am sure my problem comes from the limited knowledge of java and baja as although I do write code (apart from ‘normal’ DDC programming) in C or more hardware close languages the object oriented programming is a bit of a hit and miss with me.
I learnt to use the program-objects from the examples in the module itself mostly and due to this, my first (well most) programs I have interfaced data to my programs via creating slots of baja → StatusNumeric and StatusBoolean, etc. type and then I created ‘handles’ to get and set their values. I think something called dereferencing in java which I think actually means referring to the address of the data and using it that way.
This worked very well but I wrote some new code and as I saw when the slots are generated, the setting and getting functions are all created and also that I can use simple boolean and double, etc slot types which allowed me to ommit the creation of the ‘handles’.
Now interestingly, this works very well too.
I can see, that one big difference (for me) between the two method is the first ‘picks up’ the status of the slot too (in case of a writeable slot, you can set it to null for example) and the slot itself has an icon of a green or purple bar which is the same as you see on Niagara standard blocks (writables, or blocks, etc.). In the other case, the slot created will only ‘show’ the value of the slot and it only has a 3D block (representing an object?) for an icon and (for example) cannot be set to null.
So far you could ask, what is the problem? Yes, correct, no problems BUT:
I accidentally noticed, when I link the slots (inputs) to put the program-object to use on a wiresheet, although the programs run without an issue, its compilation status chages to orange. If I remove the links, the status changes back to compiled.
The only difference I saw with the two different methods used on the slots, is when I use the ‘handle’ type solution, than it will ‘sometimes’ require 2 links to be made for the compilation status to become orange, sometimes one. Agaon, when removed, the compilation state becomes green again.
I wrote a little test code to do the same thing with both methods to filter out other issues in the program itself and they behave the same way as descirbed above. Even the examples in the module behave the same way.
I have checked the kitcontrol blocks to see what slots these use for inputs and outputs but funny enough for example, the ‘Or’ block uses ‘StatusBoolean’ inputs but the ‘ExprLogic’ block in the same place uses simple booleans as inputs. So it does not seem to be coherent.
So, my question(s) to you is the following if you could comment on:
- Which is the ‘proper’ baja type, usage method of slots in a program? The ‘Status’ kind or the ‘simple’ boolean or double, etc. type slot?
- Do you think this ‘change’ to be ‘Program is out-of-date and requires compile’ is a bug or I am causing it due to limited exposure to java/baja?
- Reading up on Tridium’s notes on the Program-Object, should I really try to compile the programs to modules rather as these are ‘for one offs’ or for protoyping/testing?
For reference please see below the two methods I am using to read the different kind of slots:
Slot type is StatusNumeric (InA):
public void onExecute() throws Exception
{
double InputA;
BStatusNumeric InA = getInA();
InputA = InA.getValue();
…
Slot type is double (InA):
public void onExecute() throws Exception
{
double InputA;
InputA = getInA();
…