Macros #M


Single or multiple command sequences can be collected in a so-called macro (*.emc) and stored on internal FLASH. A macro could also contain lots of commands to build up a complete screen - including a command that deletes all old objects (#ODI0).


Run macros / Start a screen

Run normal macro

(Macro Run Normal)

#MRN

<Macroname>

Run normal macro conditionally

(Macro Run Conditionally)

#MRC

(Condition), <MacronameTrue>, <MacronameFalse>

Run normal macro delayed

(Macro Run Delayed)

#MRD

Delay-No., Time, <Macroname>

Run I/O-Port macro

(Macro Run Port)

#MRP

Port

Run I/O-Bit macro

(Macro Run Bit)

#MRB

Portpin, Edge

Run analogue macro

(Macro Run Analogue)

#MRA

Channel, Type

Run touch macro

(Macro Run Touch)

#MRT

Obj-ID, Type, Point-No.(0)

Define macros

Define touch macro

(Macro Define Touch)

#MDT

Obj-ID,  <MacronameDown>, <MacronameUp>; <MacronameDrag>

Define macro process

(Macro Process Define)

#MPD

Process-No, Time, <Macroname>, StartNumber(no), EndNumber (StartNumber), Type(1)

Define conditional macro process

(Macro Process Conditionally)

#MPC

Process-No, Time, (Condition), <Macroname>, StartNumber(no), EndNumber (StartNumber), Type(1)

Define automatic macro process

(Macro Process Autochange)

#MPA

Process-No, Time, (Calculation), <Macroname>, StartNumber(no), EndNumber (StartNumber), Type(1)

Change macro process time

(Macro Process Time)

#MPT

Process-No, Time

Define action end macro

(Macro Define Actionend)

#MDA

Obj-ID, <Macroname>

Define I/O/Port macro

(Macro Hardware Port)

#MHP

Port

Define I/O-Bit macro

(Macro Hardware Bit)

#MHB

Portpin, Edge, <Macroname>

Define analogue macro

(Macro Hardware Analogue)

#MHA

Channel, Type, <Macroname>

Define RS232 receive macro

(Macro Hardware RS232 master)

#MHR

BufferSize, <Macroname>

Define second macro (RTC)

(Macro Define Second)

#MDS

<Macroname>

Define sound end macro

(Macro Hardware Soundend)

#MHS

<Macroname>

Define backlight auto-dimming macro

(Macro Define Led)

#MDL

<Macroname>

Define gesture macro

(Macro Define touch Gesture)

#MDG

Obj-ID, <MacronameDoubleClick>, <MacronameLongClick>

Define register change macro

(Macro Observe Register)

#MOR

<Macroname>

Define string register change macro

(Macro Observe StringRegister)

#MOS

<Macroname>

Define array change macro

(Macro Observe Array)

#MOA

<Macroname>

Define callback macro for network changes

(Macro Define Network)

#MDW

<Macroname>

Define callback macro for module connection

(Macro Define Module)

#MDN

<Macroname>

Define callback macro PLC boot finished

(Macro Define PLC)

#MDP

<Macroname>

Delete macro definition

(Macro Clear Defines)

#MCD

Mask

Commands within macros

Skip commands

(Macro File Skip)

#MFS

(Condition), Commands(1)

Jump

(Macro File Jump)

#MFJ

(Condition), Marker-No(0), Delete(0)

Set jump destination (marker)

(Macro File Marker)

#MFM

Marker-No(0)

Jump with call

(Macro File Call)

#MFC

(Condition), Marker-No(0), Delete(0)

Jump to call

(Macro File Return)

#MFR

(Condition) (true)

Exit macro

(Macro File Exit)

#MFE

(Condition) (true), <Macroname>

Delete marker

(Macro File Delete)

#MFD

Marker-No.

Run macros

Run normal macro / Show a screen

#MRN

<Macroname>

This command executes a macro ().

...

#MRN <P:macro/macro.emc>

...

...

#MRN "macro";

...


Alternatively this command runs a macro that set-up a full screen.

...

#MRN <P:macro/screen/Screen1.emc>

...

...

#MRN "screen/Screen1";

...


Run normal macro conditionally

#MRC

(Condition), <MacronameTrue>; <MacronameFalse>

If the Condition is true, <MacronameTrue> is executed, otherwise <MacronameFalse>.

...

#MRC (R0<10),<P:macro/macroTRUE.emc>;<P:macro/macroFALSE.emc>

...

...

#MRC (R0<10),"macroTRUE";"macroFALSE";

...


Run normal macro delayed

#MRD

Delay-No., Time, <Macroname>

The command executes the macro (<MacroName>) with a delay. Up to 10 macros can be started at the same time with a delay (Delay-No. 1 ... 10). The Time is given in 1/100 s. If the command is executed before execution, but without time and macro name, the macro assigned to the Delay-No. will not be started (e.g. #MRD 1) . A re-trigger is also possible. When the command is executed again, the specified delay time starts from the beginning. If time 0 is specified, the macro starts immediately.

...

#MRD 1,100,<P:macro/macro.emc>

...

...

#MRD 1,100,"macro";

...

or

...

#MRD 1,100,<P:macro/screen/Screen2.emc>

...

Run I/O-Port macro manually

#MRP

Port

The command executes a port macro (Port 0 ... 15).


Run I/O-Bit macro manually

#MRB

Portpin, Edge

The command executes a bit macro (Portpin 0 ... 127).

Edge

0

Falling

1

Rising


Run analogue macro manually

#MRA

Channel, Type

The command executes an analog macro (Channel 0 ... 3). The parameterization of the analog input (limits, hysteresis) is set with the command group 'Analog input'.

Type

0

Every change

1

Decrement

2

Increment

3

Lower limit 1

4

Upper limit 1

5

Lower limit 2

6

Upper limit 2

7

Leave window

8

Enter window


Run touch macro

#MRT

Obj-ID, Type, Point-No.(0)

The command executes a touch macro (object Obj-ID). PointNo. (0 ... 4) indicates the finger: 0 = first, 1 = second etc. contact point.

Type

1

Normal

2

Pushed

3

Drag

Define macros


Define touch macro

#MDT

Obj-ID,  <MacronameDown>; <MacronameUp>; <MacronameDrag>

The command defines a touch macro. The macro <MacronameDown> is called when the key is pressed, <MacronameUp> when released, <MacronameDrag> when dragging (especially useful for bar-graphs and instruments). With an empty string ("";) the corresponding macro is deleted.

Modules with capacitive touch panels also support multi-finger operation. Up to 5 points are recognized. The first three macro names then apply to the first point, the next three to the second, etc. If no special macro is defined, the macros for the first point are always called.

...

#MDT 1,<P:macro/macroDOWN.emc>;<P:macro/macroUP.emc>,<P:macro/macroDRAG.emc>

...

...

#MDT 1,"macroDOWN";"macroUP";"macroDRAG";

...


Define macro process

#MPD

Process-No, Time, <Macroname>; StartNumber(no), EndNumber (StartNumber), Type(1)

Macro processes define an automatic chronological sequence of macros. The process (Process-No. 1 ... 10) automatically calls the next macro (<Macroname>) in (Time in 1/100 s). Several macros can be called (StartNumber to EndNumber e.g. #MPD 1,100,"MacroProcess";1,50 → MacroProcess1 .. MacroProcess50 are called. The Type specifies the call order:

Type

1

Cyclic

2

Cyclic backward

3

PingPong

4

PingPong backward

5

Once

6

Once backward

...

#MPD 1,100,<P:macro/MacroProcess.emc>,1,4

...

...

#MPD 1,100,"MacroProcess";1,4

...

Define conditional macro process

#MPC

Process-No, Time, (Codition), <Macroname>; StartNumber(no), EndNumber (StartNumber), Type(1)

Conditional macro processes define an automatic chronological sequence of macros if a condition is fulfilled (true). The process (Process-No. 1 ... 10) automatically calls the next macro (<Macroname>) in (Time in 1/100 s). Several macros can be called (StartNumber to EndNumber e.g. #MPC 1,100,(R1<10),"MacroProcess";1,50 → MacroProcess1 .. MacroProcess50 are called. The type indicates the order of the call:

Type

1

Cyclic

2

Cyclic backward

3

PingPong

4

PingPong backward

5

Once

6

Once backward

...

#MPC 1,100,(R1<10),<P:macro/MacroProcess.emc>

...

...

#MPC 1,100,(R1<10),"MacroProcess";

...



Define automatic macro process

#MPA

Process-No, Time, (Calculation), <Macroname>, StartNumber(no), EndNumber (StartNumber), Type(1)

Conditional macro processes define an automatic chronological sequence of macros if the value of the calculation has changed. The process (Process-No. 1 ... 10) automatically calls the next macro (<Macroname>) in (Time in 1/100 s). Several macros can be called (StartNumber to EndNumber e.g.#MPA 1,100,(R1<10),"MacroProcess";1,50 → MacroProcess1 .. MacroProcess50 are called. The type indicates the order of the call:

Type

1

Cyclic

2

Cyclic backward

3

PingPong

4

PingPong backward

5

Once

6

Once backward

...

#MPA 1,100,(R1),<P:macro/MacroProcess.emc>

...

...

#MPA 1,100,(R1),"MacroProcess";

...

Change macro process time

#MPT

Process-No, Time

The time (1/100 s) for the macro process (Process-No = 0 all) is changed.

Time

-1

Restart with old interval

0

Stop

>0

Reset time


Define action end macro

#MDA

Obj-ID, <Macroname>

After an object animation (Obj-ID) has ended, the macro (<Macroname>) is called.

...

#MDA 1,

...

...

#MDA 1,"Macro";

...


Define I/O-Port macro

#MHP

Port

The port macro is called when the status of the Port (0 ... 15) changes.

...

#MHP 0,<P:macro/Macro.emc>

...

...

#MHP 0,"Macro";

...


Define I/O-Bit macro

#MHB

Portpin, Edge, <Macroname>

The bit macro is called when an Edge is detected at the Portpin (0 ... 127).

Edge

0

Falling

1

Rising

2

Both edges

...

#MHB 16,2,<P:macro/Macro.emc>

...

...

#MHB 16,2,"Macro";

...


Define analogue macro

#MHA

Channel, Type, <Macroname>

A macro (<Macroname>) is assigned to an A / D input (Channel 0 ... 3). Type:

Type

0

Every change

1

Decrement

2

Increment

3

Lower limit 1

4

Upper limit 1

5

Lower limit 2

6

Upper limit 2

7

Leave window

8

Enter window


The parametrization of the analogue input (limits, hysteresis) is set with the command group 'Analog input'.

...

#MHA 0,0,<P:macro/Macro.emc>

...

...

#MHA 0,0,"Macro";

...


Define RS232 receive macro

#MHR

BufferSize<Macroname>

The macro (<Macroname>) is called when the BufferSize (0 = disable) in the master RS232 receive buffer is reached.

...

#MHR 42,<P:macro/Macro.emc>

...

...

#MHR 42,"Macro";

...


Define second macro (RTC)

#MDS

<Macroname>

The macro (<Macroname>) is called every second.

...

#MDS <P:macro/Macro.emc>

...

...

#MDS "Macro";

...


Define sound end macro

#MHS

<Macroname>

The macro (<Macroname>) is called when the sound string has finished playing. The definition must be made before playing the jingle. The macro is not called for automatically played jingles (e.g. button) (only after #HTN )

...

#MHS <P:macro/Macro.emc>

...

...

#MHS "Macro";

...



Define backlight auto-dimming macro

#MDL

<Macroname>

The automatic dimming function of the backlight calls up the specified macro (<Macroname>) when the state changes. Please see command #XAL for parameter setting concerning time and brightness.

...

#MDL <P:macro/Macro.emc>

...

...

#MDL "Macro";

...


Define gesture macro

#MDG

Obj-ID, <MacronameDoubleClick>; <MacronameLongClick>

The command defines a gesture macro. The macro <MacronameDoubleClick> is called with a double click, the macro <MacronameLongClick> with a long click

...

#MDG 1,<P:macro/MacroDoubleClick>;<P:macro/MacroLongClick>

...

...

#MDG 1,"MacroDoubleClick";"MacroLongClick";

...


Define register change macro (from V1.4)

#MOR

<Macroname>

The command defines the Register change macro. The macro <Macroname> is called whenever an observed Register is changed (#VOR). Do not forget to clear status flag (#VDR).


Define string register change macro (from V1.4)

#MOS

<Macroname>

The command defines the StringRegisterr change macro. The macro <Macroname> is called whenever an observed StringRegister is changed (#VOS). Do not forget to clear status flag (#VDS).


Define array change macro (from V1.4)

#MOA

<Macroname>

The command defines the array change macro. The macro <Macroname> is called whenever an observed array is changed (#VOA). Do not forget to clear status flag (#VDA).


Define callback macro for network changes (from V1.5)

#MDW

<Macroname>

The macro is started when changes occurs regarding the network connection of the module, i.e. the WiFi network strength changes or a network cable is plugged in.


Define callback macro for module connection (from V1.5)

#MDN

<Macroname>

The macro is started when changes occurs regarding the connected modules, i.e. a satellite connects or disconnects.


Define callback macro PLC boot finished (from V1.5)

#MDP

<Macroname>

The macro is started when PLC has booted completely. In this macro you can retrieve PLC information, like calculation version(1).



Delete macro definition

#MCD

Mask

The command deletes macro definitions by type:

Mask

0

Second macros (RTC)

2

Process macros

4

Port macros

8

Bit macros

16

Analogue macros

32

Touch/Gesture macros

64

Action macros

128

Delayed macros

256

Backlight macro

512

RS232 receive macro

1024

Sound end macro


The individual types can be added, e.g. Delete all macros: Mask = $ FFFF


Commands within macros

Skip commands

#MFS

(Condition), Commands(1)

If the Condition is true, the command skips the defined number of Commands (blank lines and comments are ignored) in the macro.

...

#MFS (R1<10),2

  #??? /**Command 1

  #??? /**Command 2

#??? /**Command 3

...


Jump (from V.1.1)

#MFJ

(Condition), Marker-No(0), Delete(0)

If the Condition is true, the command jumps to the marker (Marker-No. 0..99) in the macro. A marker can appear multiple times in a macro. The parameter Delete deletes the last marker found and searches for the next marker with the same ID in the macro.

...

#MFJ (R1<10),1

  #??? /**Command 1

  #??? /**Command 2

#MFM 1

#??? /**Command 3

...



Set jump destination (marker)

#MFM

Marker-No(0)

The command sets a jump target (Marker-No. 0..99) in the macro.


Jump with call

#MFC

(Condition), Marker-No(0), Delete(0)

If the Condition is true, the command jumps to the marker (Marker-No. 0..99) in the macro. A marker can appear multiple times in a macro. A return (#MFR) is mandatory to return to the call. The parameter Delete deletes the last marker found and searches for the next marker with the same ID in the macro.

...

#MFC (R1<10),1

#??? /**Command 1

#??? /**Command 2

#MFE


#MFM 1

  #??? /**Command 3

#MFR

...


Jump to call

#MFR

(Condition) (true)

If the Condition is true, the command jumps to the call.


Exit macro

#MFE

(Condition) (true), <Macroname>

If the Condition is true, the macro is exited. Another macro (<Macroname>) can be called optionally.


Delete marker

#MFD

Marker-No.

The command deletes the last marker with the Marker-No..

Comparison between C-Code and Macro-Code

In our uniTFTAcademy you will find a training video that explains exactly the issue if-queries.

if-query one-line

C-Code

Makro-Code

if(R1<10)
  //Command
else
  //Command

#MFS (R1>=10),3

  #??? /**Command

#MFS (R1<10),1

  #??? /**Command

if-query multi-line

C-Code

Makro-Code

if(R1<10)
{
  //Command 1

  //Command 2
}
else
{
  //Command 1

  //Command 2
}

#MFJ (R1>=10),1

  #??? /**Command 1

  #??? /**Command 2

  #MFJ (1),2

#MFM 1

  #??? /**Command 1

  #??? /**Command 2

#MFM 2

In our uniTFTAcademy you will find a training video that highlights exactly the issue of loops.

for-loop

C-Code

Makro-Code

for(int i=0;i<10;i++)
{
  //Command 1

  //Command 2
}

#VRI 0,0

#MFM 1

  #??? /**Command 1

  #??? /**Command 2

#MFJ (++R0<10),1


do-loop

C-Code

Makro-Code

do
{
  //Command 1

  //Command 2
}while(R1<10)

#MFM 1

  #??? /**Command 1

  #??? /**Command 2

#MFJ (R0<10),1


Function call

C-Code

Makro-Code

...
{
  subfunction();

  //Command 1

  //Command 2
}
void subfunction()
{
  //Function Command 1

  //Function Command 2
}

#MFC 1,1

  #??? /**Command 1

  #??? /**Command 2

#MFE


/**---------------subfunction---------------

#MFM 1

  #??? /**Function Command 1

  #??? /**Function Command 1

#MFR