Hello everyone, and welcome to this video tutorial.
My name is Tomas, and I am a member of the Inxton developer team.
In the previous video tutorial, 
we have explained how to create an own visualisation component
for the complete structure or instance of the PLC element. 
In this video tutorial, we are going to explain four
standard presentation types and differences between them.
So, please check if you meet the requirements on the screen,
proceed to www.github.com/inxton,
navigate to the section Tutorials-Inxton.Package.Vortex.Essentials,
Click on the CODE button, 
and click on the copy link icon.
Those who are not very familiar with git 
could also download the whole folder as a zip file.
Open Folder C:\WORK,
Right-click and select Git Bash Here,
Type git clone and hold Shift+Insert or 
Right-click and select Paste, 
type INXTON_ESSENTIALS.
Open the folder 205_EssentialsStandardPresentationTypes,
open the folder init and start the XAE solution.
Open the Package Manager Console,
and restore packages.
Just to be sure,
let's also update and reinstall packages.
Check if the Solution Platform is set to Twincat Realtime 64bits
and if MainPlcHmi project is set as the startup project, if not change it.
Activate configuration and start the PLC.
Let's now little bit explore the PLC project.
Open the MAIN program. 
It contains just one instance of the function block fbStation.
So navigate to its definition. 
fbStation contains the mode selector that enables to change between
Manual mode, Ground mode and Automat mode.
Then it contains ReadOnly variable _modeCurrent 
displaying currently selected mode.
Next to it, there is a _stepInfo
containing the description of the operation currently being performed.
_errorInfo contains the description of the actual error if any happened.
Structure _components contains all hardware-related components. 
All pneumatic components are grouped in the structure _pneumatics,
that contains four instances of the fbPneumaticActuator, 
horizontal, vertical piston, gripper and end-stopper.
Then the _components structure contains one instance of the fbStepConveyor
and two instances of the fbDigitalSensor.
And at the end of the definition section, we have three real values
of the three sensors measuring dimensions in three directions.
Let's move back to the fbStation.
Another item is the _data structure containing 
three measurement data structures for each dimension.
This structure contains Measured value so as the Minimum and Maximum values.
As we are running without physical hardware,
these three instances provide simulated analogue value in the desired range.
In the body of the fbStation, there are function calls of all pneumatic actuators  
bound with the variables linked to the physical IO. 
Then we have here the calls of the instances of the digital sensor also bound to hardware.
So as the call of the step conveyor also bound to the hardware.
These three function block calls generate pseudorandom values in the desired range 
and then these values are passed to the values of the sensors,
as they are not linked with the hardware.
This section provides the calls of the specified methods for each mode of the machine.
In our example, we have one 16 channel input terminal 
and one 16 channel output terminal in the hardware configuration.
As we are running without real hardware, complete Ethercat device is disabled.
OK, so start the application.
Click on the Manual button to select Manual mode.
You can see that the machine mode has changed. 
Open the Service tab, and try to manipulate with some pistons.
You can see that the outputs are changing, but the inputs not,
because of no sensors connected to the input terminals. 
To get the feedback from the sensors as well, just resize the application, 
navigate to the root directory of the solution and copy its path. 
Proceed again to www.github.com/inxton,
and navigate again to the section Tutorials-Inxton.Package.Vortex.Essentials.
Click on the Releases, download the UnityProjectExecutable.7z
and paste the copied path as the download location.
After download, navigate to the download directory and unpack the downloaded archive.
Switch back to our running application,
click on the Mode tab and click on the Simulation button.
Select the screen resolution and click play.
This visualisation is made with Unity, which is a powerful 3D tool mostly for games,
but also very strong in movies and engineering.
The Unity application reads via ADS the output variables linked with the output terminal 
and trigger the desired motion.
All mechanical actuators have virtual sensors and the Unity application writes these values
to the input variables linked with the input terminal.
So now you can move with all actuators in the manual mode.
If you crash for example with the yellow bumper,
move the manipulator back to the ground position and restart the simulation
by clicking again on the Simulation button.
The running instance is going to be closed
and the new instance is going to be started.
Select again the manual mode, open Service tab 
and move manipulator out of the ground position.
 
Switch to the Mode tab and start Ground mode.
The manipulator should return to the ground position.
Now you could start the Automat mode.
All bricks are thrown away as the bad parts 
because all minimum and maximum values are set to zero.
Start again the Ground mode.
Navigate to the body of the function block fbStation in the PLC project
and open the tab Settings in the visualisation.
Set the values of the minimum of each dimension
slightly greater than the minimum value of the function block
that simulates values in the PLC.
Set the values of the maximum of each dimension
slightly lower than the maximum value of the function block
that simulates values in the PLC.
Click on the LOAD TO PLC button.
 So now the brick having all its dimensions in the desired range
is transferred to the output conveyor.
The brick having one of its dimension out of the desired range is thrown away.
Let's stop the application and let's look closer at the presentation types
used in this example.
The tab "Online data" has its data context set to 
Main._station._data using presentation type "Display".
The tab "Settings" has the same data context but using different presentation type 
"ShadowControl". 
To see the differences between all types possible, let's add them on one separate tab.
Add the new tab, set its header property to Standard Data Types
and bind its data context to MAIN._station._data.
Add the grid with four columns and three rows.
Into the first row add four TextBox-es with descriptions
Display, Control, ShadowDisplay and ShadowControl.
Into the second row add four RederableContentControl-s
with binding to their parent tab, using presentation types:
Display, Control, ShadowDisplay and ShadowControl. 
Into the last row add two buttons: online to shadow and shadow to online.
Create the event handlers to the click event of each button and 
inside them call the FlushOnlineToShadow() and FlushShadowToOnline()
methods over the _data structure for the corresponding direction.
Start the application and keep the simulation running to see the measured values changing.
In the first column, we have used "Display" as the presentation type,
that means the data are not editable from the .NET side.
In the second column "Control" presentation type has been used.
You can try to change any value and you can see that it changes 
immediately after leaving the edited field.
You may also notice that "Aquired" values are missing so as in the case of "ShadowControl".
The reason why will be explained a little bit later.
Click on the online to shadow button,
that triggers copying actual values to the shadow copy.
The "shadow" values are the extensions to the "online" values
and exist only in the .NET representation. 
As we might expect, the values ​​in "ShadowDisplay" are also not editable.
Let's move on to the last column. 
You can change any value, but it changes in the PLC only after
clicking on the shadow to online button that triggers overwriting actual online values.
The "Shadow" values are mostly used for settings, recipes etc.
We have already used the "ShadowControl" to set minimal and maximal values 
of each dimension of the brick.
As the complete structure contains also measured or aquired value, let's look closer,
why this value is not displayed, when "Control" or "ShadowControl"
is used as the presentation type.
Stop the application and navigate to the definition of the data structure 
stContinuosValueData.
You can notice the RenderIgnore attribute with
"Control" and "ShadowControl" values inside the brackets.
This tells to the renderer, that in case of such a presentation type used,
this value isn't going to be displayed.
Let's try to comment out this line, to see its effect.
Run the Inxton builder.
Start the application.
You can see that "Aquired" value has been added into all views.
As we could expect, the values are also writable, immediately from the "Control" type
and on-demand from the "ShadowControl" type.
Ok, so stop the application.
Uncomment the commented line and run the Inxton builder.
Remove the added tab "Standard Data Types" so as the unnecessary event handlers
for the buttons to return to the initial state of the project.
OK, so that was all for this video tutorial.
The complete project is downloadable at www.github.com/inxton, in the tutorial section.
Just to be sure here is the link:
Thank you for your attention, and I look forward to the next tutorials.
If you have some troubles, please feel free to write an email to hello@inxton.com.
