Benutzer-Werkzeuge

Webseiten-Werkzeuge


advanced_macro

Mehr zu Makro und Accessory

In diesem Kapitel werden tiefergehende Erläuterungen zu Makro und Accessory beschrieben.

The following sections describe the options of the Port Type column.

Some Port Types have the Delay column enabled. A delay value is used to wait before the step is executed. If you want to add a delay before the step you must use the Port Type Delay.

Macro

The port type Macro allows to start or stop another macro from the selected macro. This is required if more macros are running that control the same ports.

Input Port

The port type Input Port allows to block the current macro execution in this step until the selected option in the Action column is satisfied. If you choose Wait until value=0 then the macro will be blocked in this step until the selected input port has a value of 0 (off). If you choose Wait until value=1 then the macro will be blocked in this step until the selected input port has a value of 1 (on).

Other Port Types

The other simple port types like

  • Light Port
  • Servo Port
  • Switch Port
  • SwitchPair Port

allows to perform an action on the selected port.

For Servo ports the Destination value must be entered in the Extra column. This value is used as target value for the servo in this step.

Await servo move

The type Await servo move will block the current macro in this step until the selected servo has reached the target value.

Delays

The type Delay allows to wait for the configured delay in this step.

The Random Delay allows to wait for a random delay with a maximum of the configured delay in this step.

The Ticks is a time specification for the waiting time before the action is executed. The basic unit is a macro tick and is 20ms.

Flag

The type Flag is used to clear, query or set a flag. A flag is a global marker in the assembly and is shared between all macros. If you set or clear the flag in one macro, the all other macros see the same flag value.
This can be used to let one macro wait (block in this step) until a flag value gets 0 (Query 0) or 1 (Query 1) before the macro continues.

Flags are only available internally in the assembly and the current value cannot be queried or set from outside a macro execution.

Critical Section

The type Critical Section is used to protect the steps between the step Critical Section, Action Start and step Critical Section, Action End from being interrupted or aborted.

:!: The step Critical Section is an envelope around some steps and therefore you must have a step Start and a step End to work correctly.

Accessory notify

The port type 'Accessory notify' must only be used if the accessory should send the result before the accessory has finished (really finished). The accessory is normally finished when the assigned macro has finished. But think of the case where the macro closes the gates of a railway crossing. The signal lights start blinking, the bars are moved down with the servo, they reach their end position and the signal lights should blink for some time. The following image shows the required macros.

If you assign the aspect of the accessory and press the test button, the accessory is in state 'pending' (the clock icon in the Wizard) until the input with name 'Servo end right reached' (or left reached) gets the value '1' ( I tested with a shortcut on GPIO 0 which is port 25), and then reaches the state 'finished' (the green mark icon in the Wizard). If this input port does not get the value '1' then the accessory will not be signalled as finished and stays in 'pending' state.

This description was the „normal execution“ of an accessory.

If you want to signal that the accessory has finished earlier, for example because you added a sound that is played from start and during the bars going down, and 20s after the bars (the servo) reached the end position the sound should be turned off, then you could use the 'accessory notify'-actions.

You can use 'Accessory Notify' here because the train does not care if the sound has stopped playing, they only care about the fact, that the bars are down and the 'Switch servo right/left reached)' input is 'happy'. In this case you can use an 'accessory notify' step after the end position was reached (confirmed by the input), before the sound has finished (and therefore the macro has finished).

Accessory notify - ' Okay, if value = 0 / 1'

In the macro below the accessory will always be finished with an error because in step 4 the input 24: 'Servo end left reached' waits until it becomes '1' and some ms later the check in step 6 for the same input with a value = '0' is performed.
So the Action should be interpreted as 'Return result Okay, if value = '0' and error otherwise'.

Change I/O behaviour of input port

You can switch between INPUT_PULLUP and INPUT_PULLDOWN only in the CV Definitions-Tab.

  1. Load the CV values from the node (see the steps here)
  2. Change the Bit 1 of GPIO port you want to change (press Memorize before store the changes back on the node)
  3. Restart of the node is required (use context menü of the node)
  4. After restart the I/O Behaviour of the port has changed.

After Restart:

advanced_macro.txt · Zuletzt geändert: 2023/11/14 09:32 von akuhtz

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki