Table of Contents

Application

A Zeugwerk Application is always held inside a folder called per default ZApp and is integrateable into existing applications (Not using Zeugwerk Framework so far) without interfering with the existing code.

The foundation of the PLC template is its application context. Its main purpose is to fixing the contact points for communication and data and declaring a program were all the units are running. It also provides auxiliary functions for the PLC like logging, alarming, fieldbus handling (Ethercat Master and Slave) and declaring global variables.

Communication and data is kept outside of logic code in the Global Variable List ZGlobal, seperating internal bahavior from interfaces to IT.

The PLC runs in a task which is automatically created when you are using the Zeugwerk template. This task is called ZModuleTask and runs the PRG ZModuleProgram. This program holds all created instances of your units and the application context.

PROGRAM ZModuleProgram
VAR_INPUT
  App : ZApp(displayName:='My-Application', com:=ZGlobal.Com.App);

  Datetime : ZAux.DateTimeUM;

  LoggerHmi : ZApplication.Messaging(parent:=App, datetime:=datetime, com:=ZGlobal.Com.Messages);
  LoggerFile : ZAux.LoggerFile7FF(parent:=App, datetime:=datetime, filePath:='C:\temp\msg.log', target:='192.168.0.80.1.1');
  Logger : ZAux.Logging;

  MyUnit1 : MyUnit(displayName:='My-Unit-1',
                   parent:=App,
                   configdata:=ZGlobal.Data.Config.MyUnit1,
                   machinedata:=ZGlobal.Data.Machine.MyUnit1,
                   calibrationdata:=ZGlobal.Data.Calibration.MyUnit1,
                   com:=ZGlobal.Com.Unit.MyUnit1);
END_VAR
  • App: The first object is the Application instance. It's Cyclic method called in the body of ZModuleProgram drives all objects in a Zeugwerk Application. This object has sequences for Booting ans Running the application.

    • The Booting Sequence makes sure that all instantiated objects (with the root parent App) are getting ready, transitioning from their Booting state to their IDLE state
    • The Running Sequence automatically calls the Cyclic method of all instantiated Objects (with the root parent App), ensuring their operation.
  • Datetime: Next, we have an instance to the date-time function block, which can be synced to an internal or external clock and can be used all over the application.

  • Logging is an integral part of the Zeugwerk Framework, so the next instances refer to the logging mechanism. Essentially, Logging, provides a thread-safe generic implementation for logging. Adding various Appenders to this object makes it possible to write messages into files, to an HMI or a similar program that utilized ADS. Decorators may be used to provide more context to such messages. Find a detailed explaination on logging in the respective tutorial.

  • Units: Last but not least, all units of the application are instantiated, The communication and data structures of every unit are initialized by reference from ZGlobal. Every unit has is a specialized structs with all necessary data types for this unit, but the location where all this data is stored is the same for every Zeugwerk Application, prociding a clear interface to external applications, which are connected to the PLC with ADS or a similar protocol.

Other function blocks, which are usually instantiated in ZModuleProgram include objects, which are shared by multiple unit instances, such as

  • EthercatMaster, observes and controls a single busmaster instance (Device) for monitoring or changing operation modes, respectively.
  • EthercatSyncUnit
  • Mutex, enables one to implement thread-safe operations on other objects over >=1 cycles of the PLC.
  • Alarming, similary to Logging, this object allows to send messages in a thread-safe way. In contrast to the Logging object, the messages that are send with Alarming are meant for operators and may be combined with an action that an operator has to perform in order to acknowledge these messages.
  • Safety