Logicsteps

Only included in Professional version

With Logicsteps you can easily create a sequence of production steps without connected PLC’s or just to simulate your process. Included functions are the control of drives, sensors and Boolean signals. There are several predefined logics that can be used. It is also possible to define user-defined logics The following chapter describes the available logics and the way to define your own logic.

Main advantage of Logicsteps is, that it is very easy to define a sequence of operations and conditions without the need of programming or of any additional installation.

Basics

To use the logic steps, add an empty object. The steps are then attached to this object as a component. The order of the attached components determines the order in which the steps are used. You can use drag and drop to change the sequence. If you have multiple processes, use a separate empty object for each process to define the order. This helps you to keep the overview. It is important that each step must be defined, e.g. start drive, wait until an object reaches a sensor, stop drive. For each step you can define a unique name. This is helpful for orientation within the sequence. For logic steps like goto and jump it is necessary to have these names. Another essential attribute within the steps is the blocking attribute. If a logic has this attribute, the logic is the only one running. For example, the “WaitforSensor” step blocks all other steps until the sensor has the desired value. Each predefined blocking logic contains a progress bar. This way you can see it at first sight. Non-blocking logics are executed in 0 time.

Available Steps

When one logic step is attached to a game object the scene menue provide a quick access to all logic steps. Another possibility to select a logic step is available under the menu item game4automation/AddComponent/Logicstep.

Below you will find an overview of all available logic steps.

Logic step Delay Here you can set a specific delay in seconds during runtime. The step provides also a progress bar which is updated by the unity fixed update.

Logic step Drive to In this step you let a drive move to a certain position. The value is specified in mm. If you select relative, the defined movement is added to the current position of the drive. The progress is visualized within the element.

Logic step Set signal bool A specific bool signal is set to true or false.

Logic step Start drive speed In this step, the speed of a drive is set. This allows you to start a drive. If the speed is set to 0, the drive stops. With a positive value, the drive moves forward. A negative speed leads to a backward movement.

Logic step Start drive to In this step you let a drive move to a certain position. The value is specified in mm. If you select relative, the defined movement is added to the current position of the drive.

Logic step Wait for drives at target Stop each action until the specified drives have reached their destination.

Logic step Wait for sensor This step is used to wait for a specific sensor. Use the “Wait for occupied” check box to determine which sensor state triggers the step.

Logic step Jump to signal Depending on the defined signal, you can jump to the selected logic step.

Develop your own steps

If the currently available logic steps do not provide a function you need, you can implement your own logic step. To do this, create a new script file in the logicsteps folder. Your user class must be of type LogicStep. The image below shows an example of a current script.

public class LogicStep_StartDriveSpeed : LogicStep
   {
       public Drive drive;
       public float Speed;
       
       protected new bool NonBlocking()
       {
           return true;
       }

       protected override void OnStarted()
       {
           if (drive != null)
           {
               drive.TargetSpeed = Mathf.Abs(Speed);
               if (Speed > 0)
               {
                   drive.JogForward = true;
                   drive.JogBackward = false;
               }

               if (Speed == 0)
               {
                   drive.JogForward = false;
                   drive.JogBackward = false;
               }

               if (Speed < 0)
               {
                   drive.JogForward = false;
                   drive.JogBackward = true;
               }
           }
           NextStep(); 
       } 
   }

Main Class

The main class logicstep.cs contains the basic functions required to process multiple steps in the defined sequence. When the last step is reached, the sequence starts again with step one. The class contains the following methods:

  • protected void NextStep() - to call the next step of the sequence

  • public void StartStep() - to start a step

  • protected void Start() - initiate the sequence when the run time starts

The main class needed the following methods to be implemented by the logic step:

  • protected new bool NonBlocking

  • protected override void OnStarted

The method nextStep() has to be called in every logic step when it finished. (see example line 34)

© 2022 in2Sight GmbH https://realvirtual.io - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.

Last updated