Logic Machine Forum
Using time controls from scripts - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Using time controls from scripts (/showthread.php?tid=3366)



Using time controls from scripts - JRP - 12.05.2021

Hello
Perhaps in a future installation it will be necessary for me to implement a quite complex lighting circuit schedule control system.

I still don't know exactly what the requirements are, what I do know is that wiser will have to supplant a BMS system made with a PC and Siemens WinCC. Apparently the time control is developed in VisualBasic and is quite complete.

As far as I remember, the system allows in the runtime mode of the visualization, that is, running; the selection of loads to be controlled by the schedule.

To advance the solution of the problem, would it be possible for the client to select on the display the different loads that he wants to control and establish the time control values for all of them?
That is, on the floor of the building I select an object that symbolizes the load and this is added to the list of loads to control, then the time is set.

The time control that is already implemented in wiser is fine but it does not allow you to do this.

Naturally, it was necessary to have the management of vacation days.


Greetings


RE: Using time controls from scripts - Erwin van der Zwart - 12.05.2021

Yes this is possible..

What you need to do is create a range of KNX objects for your loads 1/1/1 to 1/1/50 for example, create a range of virtual objects 32/1/1 to 32/1/50 and tag the virtual objects with a TAG 'Input' 

Add toggle buttons (for selecting the load) on your visu and attach those to the virtual object (not the KNX objects!)

Then add this script as event on your scheduler
Code:
for index, object in ipairs(grp.tag('Input')) do
  grptable = string.split(object.address, '/')
  if object.value == true then
     grp.checkwrite('1/' .. grptable[2] .. '/' .. grptable[3], event.getvalue())
  end
end
 If you need the load to be synced with the scheduler state when selected/deselected you need to add another script to the "Input" TAG
Code:
scheduler = '4/7/0'
grptable = string.split(event.dst, '/')
if event.getvalue() == true then
   grp.checkwrite('1/' .. grptable[2] .. '/' .. grptable[3], grp.getvalue(scheduler))
else
   grp.checkwrite('1/' .. grptable[2] .. '/' .. grptable[3], false)
end



RE: Using time controls from scripts - JRP - 13.05.2021

Thanks Edwin for answering

I understand the instructions:
1. I start with the creation of the range of objects of the charges. These should be the group addresses that control them right?
2. I create the range of virtual addresses and give all the input label, which Dpt selects, the one of the objects?
3. I add toggle buttons and associate them with virtual objects.
4. I create the time control (this is where I have doubts).
        I add a schedule, which object do I select in the first option?
        Once created, how do I add the script as an event. When adding an event if the above object is 1 bit, it just lets me select on / off and I don't see any more options.

All the best.


RE: Using time controls from scripts - Erwin van der Zwart - 13.05.2021

For the scheduler you can also use a virtual object, for example 31/1/0 and the script is attached to this bit object.

When the scheduler changes state it triggers the script, the script will fetch all virtual objects that you have created with the TAG ‘Input’ and itterates over all these objects, when the value is ‘true’ (enabled load in your visu) it will write the scheduler value to the normal object. So is 32/x/x is enabled it writes the scheduler value to 1/x/x

See this small recording: 
.zip   Recording.zip (Size: 1.61 MB / Downloads: 25)


It is also possible without script, create in the ETS your addresses for the toggles and use the blocking object of the actuator channel, this way you can write to all channels from the scheduler and when the blocking is active it won’t respond on the scheduler. I would do it like that as i aways use as much as possible in the KNX devices itself and as less possible in a central controller.

In this scenario you are already depending on the controller as the scheduler is hosted there so if the controller is not available it would not work either so single point of failure is the same however it reduces your KNX traffic as script sends to each channel separate and when using the blocking object you only send 1 telegram from the scheduler…


RE: Using time controls from scripts - JRP - 13.05.2021

Hello Thank you very much for your new indications. Modifying the script provided for the addresses shown in the animation, it has worked perfectly for me.

When
a) All virtual objects are at 1.
b) The timer object is activated at 1.
c) The outputs are activated at 1.
d) Change one of the virtual objects from 1 to 0.
e) Change the object of the timing to 0.
f) All are set to zero except the one I have removed which remains at 1.
Indeed this makes me think about the need to synchronize them, as you very well indicate.

Edited. 
I had not understood well about the synchronization script, it must be added to the functions tab and select the "input" tag as the script event.
Now it works.

It only syncs the output when deactivating / activating when the schedule is active which seems correct to me.

Last questions:

What if the objects are separated, that is, they are not correlative? Could it be done with a fixed table of objects?

On the other hand, could it be that removing or placing the load will preserve its status?

Thank you.

Greetings


RE: Using time controls from scripts - Erwin van der Zwart - 13.05.2021

There can be gaps in the objects but they must be related to the virtual objects, so you can have 1/1/1, 1/2/3, 1/5/6, in that scenario you also must have 32/1/1, 32/2/3, 32/5/6 as virtual objects as the script replace only 32 with 1 and the middle/end address is replicated by the script.

Replacing a load would not effect anything as its behind the actuator..


RE: Using time controls from scripts - JRP - 14.05.2021

Hello

Thank you for responding.

You are absolutely right, by staying only with the intermediate group and the subgroup, respecting the order, there will be no problems.

To do the same with several time controls on the same loads, how could it be done? Duplicating the scripts, modifying their addresses and labels?
or would there be another way to do it?

Thank you very much for your invaluable help.

Greetings


RE: Using time controls from scripts - Erwin van der Zwart - 14.05.2021

If they are on the same loads you can just attach your scheduler on the same object as the other scheduler, but I don’t see why .. just enter multiple events in your current scheduler..