Skip to content

Commit 76a6b5f

Browse files
psteibPhilipp Steib
andauthored
Update chapters 1 + 2 (#8)
* Update chapters 1 + 2 * Remove link to internal (publicly not available) URL * Update images and snippets to reflect the current state of the software * Removed note to solve issue from current template * Template-url parameter redundant * Removed parameter from sample and example, as this should not be required * Template and branch parameter removed * Updated doc to fit current state * Added note to ch.1 mentioning ADT specific branch * Added note in ch.3 to explain separation of Attributes * Function names and wording were brought into line with current ones * Code snippets and description updated * Missing explanation of used CLI parameters added * Unified database helpsection entry * Added missing braces in snippet * Shortened explanation of CLI parameters * Updated note to feature link to documentation of CLI * Unified syntax for notes * Added braces to IFs * Added missing $ for command in chapter-2 --------- Co-authored-by: Philipp Steib <[email protected]>
1 parent f449bcb commit 76a6b5f

12 files changed

+70
-30
lines changed

chapter-1-basics.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ only the `Assembling` step should be covered by MORYX. These information result
4444
in the following command:
4545

4646
```
47-
$ moryx new PencilFactory --steps Assembling --products GraphitePencil
47+
$ moryx new PencilFactory --steps Assembling --products GraphitePencil --branch adp
4848
```
4949

50+
> **Note** This training uses a simplified application template that is tailored to this scenario. It is provided by the --branch parameter here.
51+
> For real world applications you would probably omit --branch for a more advanced default setup or customize it to your needs (see [Moryx.Cli README](https://www.nuget.org/packages/Moryx.Cli#readme-body-tab) or moryx --help for more information).
52+
5053
This should not only leave you with a solution `PencilFactory.sln` inside
5154
the new folder `PencilFactory`. It also does some initial configuration
5255
and ships empty databases.
@@ -56,7 +59,7 @@ you run the app, you might need to [install licenses](#encountering-wupiexceptio
5659

5760
Run the application (press `F5`).
5861

59-
> *Note* Starting it for the first time will restore NuGet packages.That can
62+
> **Note** Starting it for the first time will restore NuGet packages.That can
6063
> take a few minutes.
6164
6265
![Application dashboard](./chapter-1/HomePageOfPencilApp.PNG)
@@ -103,7 +106,7 @@ From the details above, the `GraphitePencilType` needs
103106
You will find the `GraphitePencilType` among all other `<Product>Types` in the
104107
`PencilFactory` package within the `Products` folder.
105108

106-
For properties to be shown in the UI, add the [EntrySerialize](https://github.com/PHOENIXCONTACT/MORYX-Framework/blob/dev/docs/articles/Core/Serialization/EntryConvert.md#entryserialize-attribute)
109+
Paste the following code and for properties to be shown in the UI, add the [EntrySerialize](https://github.com/PHOENIXCONTACT/MORYX-Framework/blob/dev/docs/articles/Core/Serialization/EntryConvert.md#entryserialize-attribute)
107110
attribute. For properties to be saved in the database, use the [DataMember](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.datamemberattribute?view=net-7.0) attribute.
108111

109112
``` cs
@@ -146,7 +149,7 @@ To create a product, you need to run the application now and head to the
146149
Click on the plus button to open the 'Product Importer' menu. This title may
147150
sound a bit confusing, but it lets you add new products.
148151

149-
> *Note* The naming here comes from the fact, that you wouldn't necessarily add
152+
> **Note** The naming here comes from the fact, that you wouldn't necessarily add
150153
> products here, but 'import' them from other systems.
151154
152155
![New product](./chapter-1/create-product.png)
@@ -181,8 +184,8 @@ similar to the image below.
181184

182185
![Products list](./chapter-1/productList.PNG)
183186

184-
Now you should have your products `100001-00 Brown Pencil GP-1B` and
185-
`100002-00 Green Pencil GP-HB`.
187+
Now you should have your products `100001-00 Green Pencil GP-1B` and
188+
`100002-00 Brown Pencil BP-HB`.
186189
The next challenge is to actually let a resource produce the pencils. So far there is
187190
no script that describes how the pencils are produced.
188191
Therefore, the next step is to model a resource after which we can create a **Recipe** and a
@@ -219,12 +222,12 @@ Based on these requirements
219222

220223
### Add worker support
221224

222-
The `AssemblingCell`, which you will find in `PencilFactory.Resources`,
225+
The `AssemblingCell`, which you will find in `PencilFactory.Resources.Assembling`,
223226
already has an instructor.
224227

225228
``` cs
226229
[ResourceReference(ResourceRelationType.Extension)]
227-
public IVisualInstructor Instructor { get; set; }
230+
public IVisualInstructor VisualInstructor { get; set; }
228231
```
229232

230233
`IVisualInstructor`
@@ -329,7 +332,7 @@ public override void StartActivity(ActivityStart activityStart)
329332
switch (activityStart.Activity)
330333
{
331334
case AssemblingActivity activity:
332-
VisualInstructor.Execute(Name, activityStart, CompleteInstruction);
335+
VisualInstructor.Execute(Name, activityStart, InstructionCompleted);
333336
break;
334337
}
335338
}
@@ -341,7 +344,7 @@ have to implement `CompleteInstruction()`, that gets called, when an instruction
341344
has finished, i.e.: When a worker has finished their task.
342345

343346
```cs
344-
private void CompleteInstruction(int instructionResult, ActivityStart activity)
347+
private void InstructionCompleted(int instructionResult, ActivityStart activity)
345348
{
346349
var result = activity.CreateResult(instructionResult);
347350
_currentSession = result;
@@ -463,7 +466,9 @@ Now the production is running!
463466
That's it, you should now be able to let the pencils flow through the assembling
464467
cell.
465468

466-
In order to see the visual instructions, go to the module `Worker Support` and select for VisualInstructor as Display
469+
In order to see the visual instructions, go to the module `Worker Support`.
470+
Select VisualInstructor as Display, if this is not already done by default.
471+
You can manually select it by clicking on the Settings icon at the top right.
467472

468473
![Select Display](./chapter-1/SelectDisplay.png)
469474

@@ -487,3 +492,23 @@ They ship with developer licenses, that need to be activated:
487492
* Drag & Drop the `.WibuCmRau` files onto it
488493

489494
![Activate developer licenses](./chapter-1/drag-licenses.png)
495+
496+
### Encountering database issues after setup section
497+
498+
> Something went wrong on the server.
499+
500+
> The connection to the server could not be established. Please check your network connection or try again later.
501+
502+
If you encounter issues when opening Products or Resources for the first time at the end of the setup,
503+
consider checking the databases in the command center.
504+
There you may have to create the missing databeses.
505+
506+
If the issue occurs during the APD at a later stage due to messing up the order of stps or making changes to classes, of existing entires, you may also need to delete the DB.
507+
#### Step 1: Open the Command Center
508+
![Open the Command Center](./chapter-1/commandCenter.png)
509+
510+
#### Step 2: Check the databases and create missing ones
511+
![2. Check the databases and create missing ones](./chapter-1/commandCenterDB.png)
512+
513+
#### Step 3: Reincarnate the failed services
514+
![3. Reincarnate the failed services](./chapter-1/commandCenterModules.png)

chapter-1/NewWorkplan.png

-44.8 KB
Loading

chapter-1/assign-instructor.png

-2.39 KB
Loading

chapter-1/commandCenter.png

163 KB
Loading

chapter-1/commandCenterDB.png

71.7 KB
Loading

chapter-1/commandCenterModules.png

97.6 KB
Loading

chapter-1/create-resources.png

34.2 KB
Loading

chapter-2-drivers.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Common interfaces for drivers are `IMessageDriver<TMessage>` and `IInOutDriver`.
1212
* The `IInOutDriver` can read and write variables on a server. A typical protocol is OPC UA.
1313

1414
## Simulated InOutDriver
15-
You will start with the ColorizingCell. Since the cell isn't finished yet, the manufacturer wants you to [simulate](https://git-ctvc.europe.phoenixcontact.com/moryx/moryx-simulation/-/blob/dev/docs/tutorials/how_to_simulate_my_production.md) the communication first.
15+
You will start with the ColorizingCell. Since the cell isn't finished yet, the manufacturer wants you to simulate the communication first.
1616

1717
Use the CLI to add the Colorizing step to the project.
1818
```
19-
moryx add step Colorizing
19+
$ moryx add step Colorizing
2020
```
2121
Now, in order to use simulation, add the package `Moryx.Drivers.Simulation` to the project `PencilFactory.Resources`.
2222

@@ -31,7 +31,7 @@ For a protocol like that the `IInOutDriver` makes the most sense. Open the Color
3131

3232
```cs
3333
[ResourceRegistration]
34-
public class Colorizing : Cell
34+
public class ColorizingCell : Cell
3535
{
3636
private const string ProcessStart = "ProcessStart";
3737
private const string ProcessResult = "ProcessResult";
@@ -45,6 +45,7 @@ public class Colorizing : Cell
4545
```
4646

4747
In order to recognize, when an input changes, subscribe to that in `OnInitialize` and when the driver is set. If you don't also subscribe to the event in the setter of the driver, you will always have to restart the system after changing the driver of a cell.
48+
Adjust the Driver variable and functions to match the following.
4849

4950
```cs
5051
private IInOutDriver<bool,bool> _driver;
@@ -57,7 +58,9 @@ public IInOutDriver<bool, bool> Driver
5758
{
5859
_driver = value;
5960
if (_driver != null)
61+
{
6062
_driver.Input.InputChanged += OnInputChanged;
63+
}
6164
}
6265
}
6366
```
@@ -68,18 +71,21 @@ protected override void OnInitialize()
6871
...
6972

7073
if (_driver != null)
74+
{
7175
_driver.Input.InputChanged += OnInputChanged;
76+
}
7277
}
7378
```
7479

7580

7681

7782
In the method `OnInputChanged` you will check, if the value of `Ready` has changed. If it is true, send a `ReadyToWork` to the ProcessEngine.
83+
Replace the contents of the function with the following two code segments.
7884

7985
```cs
80-
private void OnInputChanged(object sender, InputChangedEventArgs e)
86+
private void OnInputChanged(object sender, InputChangedEventArgs args)
8187
{
82-
if (e.Key.Equals(ReadyToWork) && _driver.Input[ReadyToWork] && !(_currentSession is ActivityStart))
88+
if (args.Key.Equals(ReadyToWork) && _driver.Input[ReadyToWork] && !(_currentSession is ActivityStart))
8389
{
8490
var rtw = Session.StartSession(ActivityClassification.Production, ReadyToWorkType.Pull);
8591
_currentSession = rtw;
@@ -93,10 +99,10 @@ private void OnInputChanged(object sender, InputChangedEventArgs e)
9399
If the changed input is `ProcessResult`, read the result from the input and publish it as `ActivityCompleted`. Also set the input `ProcessStart` back to false, so that the physical cell is able to detect when to start the next process. If you don't reset the value of `ProcessStart`, the physical cell is not able to recognize the specific moment an activity should start. Some physical cells also only recognize rising or falling edges. Constant values would trigger nothing.
94100

95101
```cs
96-
private void OnInputChanged(object sender, InputChangedEventArgs e)
102+
private void OnInputChanged(object sender, InputChangedEventArgs args)
97103
{
98104
...
99-
else if (e.Key.Equals(ProcessResult) && _currentSession is ActivityStart activitySession)
105+
else if (args.Key.Equals(ProcessResult) && _currentSession is ActivityStart activitySession)
100106
{
101107
_driver.Output[ProcessStart] = false;
102108
var processResult = _driver.Input[ProcessResult];
@@ -144,7 +150,7 @@ public override IEnumerable<Session> ControlSystemAttached()
144150
}
145151
```
146152

147-
Now you have to implement the driver. Create a new driver `SimulatedColorizingDriver` in the project `PencilFactory.Resources`, which is derived from `SimulatedInOutDriver<bool, bool>` and add the constants for the variable names.
153+
Now you have to implement the driver. Create a new driver `SimulatedColorizingDriver` in the project `PencilFactory.Resources.Colorizing`, which is derived from `SimulatedInOutDriver<bool, bool>` and add the constants for the variable names.
148154

149155
```cs
150156
[ResourceRegistration]
@@ -182,9 +188,13 @@ protected override void OnOutputSet(object sender, string key)
182188
{
183189
SimulatedInput.Values[ReadyToWork] = false;
184190
if (SimulatedOutput.Values[ProcessStart])
191+
{
185192
SimulatedState = SimulationState.Executing;
193+
}
186194
else
195+
{
187196
SimulatedState = SimulationState.Idle;
197+
}
188198
}
189199
}
190200
```
@@ -214,11 +224,3 @@ Then create a new workplan containing both steps and add it through a recipe to
214224
![Complete workplan](./chapter-2/CompleteWorkplan.png)
215225

216226
Now you should be able to start a new production.
217-
218-
219-
220-
221-
222-
223-
224-

chapter-2/ColorizingCell.png

-6.52 KB
Loading

chapter-2/Driver.png

-12.7 KB
Loading

0 commit comments

Comments
 (0)