Hi Again,
finally I found solution I mentioned It described on russian, below will translate it to English.
Link: http://logicmachine.net.ru/solutions/sve...zovatelem/
Script itself:
The principle of the script :
We get the script name from the function parameters - event.dst.
We determine the mode of operation of the system. If the learn_mode variable is 1, then the learning mode is on and writing to the script occurs, if the variable is 0, then the learning mode is off and scripts will be launched.
If the record, then we get all the objects of the system that have the tag (tag) "light" and save it under the name of the script.
If the launch, then by the name of the script load the list of objects, and send commands to the system according to the loaded list of objects.
Using the script: After all group addresses and scripts are installed, the display of objects participating in the scripts, the script call buttons and the learning mode enable button can be displayed in any visualization system, such as built-in EVIKA LogicMachine, as well as any other such as iRidium Mobile. Moreover, you can do without visualization at all by linking these addresses to really existing switches or touch panels.
To record scripts, the user turns on the 'learn_mode' object, and after that selects which fixtures should be turned on, which ones are turned off and clicks on the script button. Writes a sequence of objects to memory. After disables the object 'learn_mode'. Now when you click on the script button, the script starts.
Alex
finally I found solution I mentioned It described on russian, below will translate it to English.
Link: http://logicmachine.net.ru/solutions/sve...zovatelem/
Script itself:
Code:
function scene_manager(event)
-- получаем имя переменной, она является именем сценария - receiving name of variable, it will be name of scenario
name_scenario = grp.alias(event.dst)
-- определяемся находимся ли мы в режиме обучения - checking, is learning mode switched on or not
is_learn_mode = grp.getvalue('learn_mode')
-- если переменная определена в системе - if this variable existing in system
if(is_learn_mode ~= nil) then
-- включен режим обучения, записываем в память - and learning mode is on than saving to memory
if(is_learn_mode == true) then
-- сохраняем массив в память под именем переменной сценария --saving array to memory under variable - scenario's name
-- получаем все объекты системы с меткой 'light' -- receiving all objects with tag "light"
lights = grp.tag('light')
-- сохраняем список объектов и --saving list of objects and it's statuses under scenario variable
-- их состояния под именем переменной сценария
storage.set(name_scenario, lights)
else
-- иначе считываем массив из памяти -- or reading array from memory
lights = storage.get(name_scenario, 'no data')
-- и устанавливаем в цикле значения по имени объекта -- and setting in cycle values by object's names
-- для установки по групповому адресу нужно использовать -- for group addresses usage
-- light.address вместо light.name -- use light.address instead light.name
if type(lights) == 'string' then
alert('No data')
end
log (type(lights))
if type(lights) == 'table' then
for index, light in ipairs(lights) do
log(light.name, light.data)
grp.write(light.name, light.data)
end
end
end
end
end
full page translated below:
logicmachine.net.ru Technical solutions at LogicMachine User Editable Light Scenarios
User Editable Light Scenarios
Purpose: To create the ability for the user to change predefined light scenes by himself using visualization on an iPad or computer.
Hardware requirements : a solution can only be implemented using the freely programmable LogicMachine controller.
Solution: We determine the group addresses that will participate in the script. For them we define tags (tags) " light ". We determine the group addresses that will be responsible for the scripts. It is important to give meaningful names to the variables corresponding to these addresses (Scene_1, Scene_2 and so on).
To switch the system from the script learning mode to the script display mode, we determine the group address in which information about the system status will be stored. Name the variable learn_mode. It is important that the variable type is binary (boolean).
For each group address selected as a button handler (Scene 1, Scene 2, etc.), create a script in Scripts -> Event-based (Scripts -> Event-based).
We add one entry to each script:
scene_manager (event)
Here, a function common to all scripts is called, which is used to create or execute a script, where a structure containing information about the event source is passed through the event parameter. Next, in the Scripts -> General functions (Scripts -> Common functions) we write the following script, where we define this function.
Source
function scene_manager ( event )
- get the name of the variable, it is the name of the script
name_scenario = grp.alias ( event.dst )
- determine whether we are in training mode
is_learn_mode = grp.getvalue ( 'learn_mode' )
- if the variable is defined in the system
if ( is_learn_mode ~ = nil ) then
- learning mode is on, write to memory
if ( is_learn_mode == true ) then
- save the array in memory under the name of the script variable
- we get all the objects of the system labeled 'light'
lights = grp.tag ( 'light' )
- save the list of objects and
- their state under the name of the script variable
storage.set ( name_scenario, lights )
else
- otherwise, read the array from memory
lights = storage.get ( name_scenario, 'no data' )
- and set the values in the loop by the name of the object
- to install at a group address you need to use
- light.address instead of light.name
if type ( lights ) == 'string' then
alert ( 'No data' )
end
log ( type ( lights ) )
if type ( lights ) == 'table' then
for index, light in ipairs ( lights ) do
log ( light.name, light.data )
grp. write ( light.name, light.data )
end
end
end
end
end
The principle of the script :
We get the script name from the function parameters - event.dst.
We determine the mode of operation of the system. If the learn_mode variable is 1, then the learning mode is on and writing to the script occurs, if the variable is 0, then the learning mode is off and scripts will be launched.
If the record, then we get all the objects of the system that have the tag (tag) "light" and save it under the name of the script.
If the launch, then by the name of the script load the list of objects, and send commands to the system according to the loaded list of objects.
Using the script: After all group addresses and scripts are installed, the display of objects participating in the scripts, the script call buttons and the learning mode enable button can be displayed in any visualization system, such as built-in EVIKA LogicMachine, as well as any other such as iRidium Mobile. Moreover, you can do without visualization at all by linking these addresses to really existing switches or touch panels.
To record scripts, the user turns on the 'learn_mode' object, and after that selects which fixtures should be turned on, which ones are turned off and clicks on the script button. Writes a sequence of objects to memory. After disables the object 'learn_mode'. Now when you click on the script button, the script starts.
Alex