Skip to content

Commit

Permalink
[NEW-FEATURE] Export Configuration from Tixon components (#716)
Browse files Browse the repository at this point in the history
* Create draft PR for #712

* ***TcoCognexVision***

+TcoDesigner verified with hw
+updated  filter for generating symbols into Designer software

***TcoTixonFeeding***
+Export parameters into json file
+Import prameters from external json files

* ***TcoData**
* fixed layout in selector ( when data are too long)

***TcoElements***
+suspend method  with expression for blocking movement

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: peterbarancek <[email protected]>
  • Loading branch information
github-actions[bot] and peterbarancek authored May 31, 2024
1 parent c7ef91f commit 555a989
Show file tree
Hide file tree
Showing 33 changed files with 376 additions and 129 deletions.
13 changes: 9 additions & 4 deletions src/TcoCognexVision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,19 @@ and where `DesignerUserData` are (here may be placed customized data (what proje

### Export symbols for visions purposes

If filter field is empty all data wil be generated. If you would to ganerate only specific data you may apply filter(see picture below).
If filter field is empty all data wil be generated. If you would to ganerate only specific data you may apply filter or tail filter.(see picture below).


MAIN.myVeryFirstTcoContextInstance._specificData.PcToPlc.AnalogInspector._data.DetectedStatus


![alt text](assets/designerExportDataFilter.png)
![alt text](assets/designerExportDialog.png)

Final data ready to import into designer will be:
Final data suitable for import into designer will be:

```
MAIN.myVeryFirstTcoContextInstance._specificData.PcToPlc.DigitalInspector._data.DetectedStatus;System.Boolean;
MAIN.myVeryFirstTcoContextInstance._specificData.PcToPlc.DataInspector._data.DetectedStatus;System.String;
MAIN.myVeryFirstTcoContextInstance._specificData.PcToPlc.AnalogInspector._data.RequiredMin;System.Double;
MAIN.myVeryFirstTcoContextInstance._specificData.PcToPlc.AnalogInspector._data.RequiredMin;System.Double;
MAIN.myVeryFirstTcoContextInstance._specificData.PcToPlc.AnalogInspector._data.DetectedStatus;System.Double;
```
Binary file modified src/TcoCognexVision/assets/designerExportDataFilter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/TcoCognexVision/assets/designerExportDialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ IF Execute() THEN
_varInfo :=__VARINFO(inoIoData);
Messenger.Programming(_sb.Clear().Append('Invalid reference: </value>
</data>
<data name="___Error_time_is_lower_than_timeout__Please_check_config___" xml:space="preserve">
<value>Error time is lower than timeout. Please check config!</value>
</data>
<data name="___Trigger___" xml:space="preserve">
<value>Trigger!</value>
</data>
Expand Down Expand Up @@ -558,9 +561,6 @@ IF Execute() THEN
<data name="___GeneralResult_FAIL__" xml:space="preserve">
<value>GeneralResult FAIL</value>
</data>
<data name="____Trigger_Date___" xml:space="preserve">
<value> Trigger Date </value>
</data>
<data name="___SystemOnline__" xml:space="preserve">
<value>SystemOnline</value>
</data>
Expand All @@ -585,12 +585,15 @@ IF Execute() THEN
<data name="___Trigger_Counter__" xml:space="preserve">
<value>Trigger Counter</value>
</data>
<data name="___ErrorMsg__" xml:space="preserve">
<value>ErrorMsg</value>
<data name="___Error__" xml:space="preserve">
<value>Error</value>
</data>
<data name="___LiveBit__" xml:space="preserve">
<value>LiveBit</value>
</data>
<data name="___ErrorMsg__" xml:space="preserve">
<value>ErrorMsg</value>
</data>
<data name="___TriggerTimeout__" xml:space="preserve">
<value>TriggerTimeout</value>
</data>
Expand All @@ -609,6 +612,9 @@ IF Execute() THEN
<data name="___ClearResults__" xml:space="preserve">
<value>ClearResults</value>
</data>
<data name="___Timeout_ms___" xml:space="preserve">
<value>Timeout[ms]</value>
</data>
<data name="____PartId___" xml:space="preserve">
<value> PartId </value>
</data>
Expand Down Expand Up @@ -693,9 +699,6 @@ IF Execute() THEN
<data name="___Test_run_ready__" xml:space="preserve">
<value>Test run ready</value>
</data>
<data name="___Error__" xml:space="preserve">
<value>Error</value>
</data>
<data name="___Error_code__" xml:space="preserve">
<value>Error code</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TcoCognexVisionConnector.TcoDesigner
{
public partial class TcoDesigner
{

//public ObservableCollection<TcoMultiAxisMoveParam> Positions { get { return Extensions.ToObservableCollection(((IVortexObject)_positions).GetChildren().OfType<TcoMultiAxisMoveParam>()); } }

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
<data name="SoftEvent" xml:space="preserve">
<value>SoftEvent</value>
</data>
<data name="Tail" xml:space="preserve">
<value>Tail</value>
</data>
<data name="Tasks" xml:space="preserve">
<value>Tasks</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
<data name="SoftEvent" xml:space="preserve">
<value>SoftEvent</value>
</data>
<data name="Tail" xml:space="preserve">
<value>Požadované premenné</value>
</data>
<data name="Tasks" xml:space="preserve">
<value>Ulohy</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Margin="5" Text="{x:Static p:strings.Filter}"></TextBlock>
<TextBox VerticalContentAlignment="Center" Margin="5" MinWidth="100" Text="{Binding Filter}"></TextBox>
<TextBlock VerticalAlignment="Center" Margin="5" Text="{x:Static p:strings.Tail}"></TextBlock>
<TextBox VerticalContentAlignment="Center" Margin="5" MinWidth="100" Text="{Binding TailFilter}"></TextBox>
<Button Margin="5" HorizontalAlignment="Center" Content="{x:Static p:strings.Generate}" Command="{Binding GenerateSpecificSymbolsCommand}"></Button>
</WrapPanel>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
using System.Linq;
using System.Collections.Generic;
using System;
using TcOpen.Inxton.Input;
using RelayCommand = TcOpen.Inxton.Input.RelayCommand;
using Microsoft.Win32;
using System.Windows;
using TcoCore;
using StringBuilder = System.Text.StringBuilder;


namespace TcoCognexVision
{
public class TcoDesigner_v_2_x_xViewModel : RenderableViewModel
Expand All @@ -34,7 +34,7 @@ public TcoDesigner_v_2_x_xViewModel() : base()
private void GenerateGenericSymbols()
{

GetSymbols(this.Component._genericData, Filter, ref _sb);
GetSymbols(this.Component._genericData, Filter,TailFilter, ref _sb);
try
{

Expand All @@ -61,7 +61,7 @@ private void GenerateGenericSymbols()
private void GenerateSpecificSymbols()
{
_sb.Clear();
GetSymbols(this.Component._specificData,Filter,ref _sb );
GetSymbols(this.Component._specificData,Filter,TailFilter,ref _sb );
try
{

Expand All @@ -85,36 +85,55 @@ private void GenerateSpecificSymbols()
}
}

private void GetSymbols(IVortexObject obj, string filter, ref StringBuilder sb)
private void GetSymbols(IVortexObject obj, string symbolFilter,string tailFilter, ref StringBuilder sb)
{

var splitted = filter.Split(';');

var symbolSplited = symbolFilter.Split(';',',');
var tailSplited = tailFilter.Split(';', ',');

foreach (var item in obj.GetValueTags())
{
if (string.IsNullOrEmpty(filter) && !item.Symbol.Contains(Messenger))
{

if (string.IsNullOrEmpty(symbolFilter) && !item.Symbol.Contains(Messenger))
sb.AppendLine($"{item.Symbol};{((dynamic)item).Cyclic.GetType().ToString()}; ;");

}
else
foreach (var split in splitted)
if (!item.Symbol.Contains(Messenger))
{
if (item.Symbol.Contains(split) && !item.Symbol.Contains(Messenger))


var isThere = true;
foreach (var split in symbolSplited)
{
if (!item.Symbol.Contains(split))
{

sb.AppendLine($"{item.Symbol};{((dynamic)item).Cyclic.GetType().ToString()};");
isThere = false;
break;
}
}
if (isThere)
{
if(string.IsNullOrEmpty(tailFilter) && !item.Symbol.Contains(Messenger))
sb.AppendLine($"{item.Symbol};{((dynamic)item).Cyclic.GetType().ToString()};");
else
foreach (var tail in tailSplited)
{
if(item.Symbol.Contains(tail))
sb.AppendLine($"{item.Symbol};{((dynamic)item).Cyclic.GetType().ToString()};");
{

}
}


}
}


}

foreach (var item in obj.GetChildren())
{
GetSymbols(item, filter,ref _sb);
GetSymbols(item, symbolFilter, tailFilter,ref _sb);
}
}
public IEnumerable<IsTask> Tasks
Expand All @@ -137,6 +156,7 @@ public override object Model
}

public string Filter { get; set; } = string.Empty;
public string TailFilter { get; set; } = string.Empty;
public RelayCommand GenerateSpecificSymbolsCommand { get; private set; }
public RelayCommand GenerateGenericSymbolsCommand { get; private set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ STRUCT
ResultPass : BOOL;
{attribute addProperty Name "<#GeneralResult FAIL#>"}
ResultFail : BOOL;
{attribute addProperty Name "<# Trigger Date #>"}
TriggerDate : DATE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ STRUCT
{attribute addProperty Name "<#Trigger Counter#>"}
TriggerCounter : UDINT;
{attribute addProperty Name "<#ErrorMsg#>"}
{attribute addProperty Name "<#Error#>"}
Error : BOOL;
{attribute addProperty Name "<#LiveBit#>"}
LiveBit : BOOL;
Expand All @@ -44,7 +45,6 @@ STRUCT
InspectionResults : TcoDesignerGenericResults_v_2_x_x;
END_STRUCT
END_TYPE
]]></Declaration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ STRUCT
{attribute addProperty Name "<#ClearResults#>"}
ClearResults : BOOL;
{attribute addProperty Name "<#Timeout[ms]#>"}
Timeout : UINT;
{attribute addProperty Name "<# PartId #>"}
PartId : STRING; //napr. DMC Code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ END_VAR
CallTimers(TRUE);
THIS^.ThrowWhen(_errorTimer.Q OR THIS^.inoIoData.PcToPlc.TriggerTimeout OR THIS^.inoIoData.PcToPlc.Error );
THIS^.ThrowWhen(_errorTimer.Q OR THIS^.inoIoData.PcToPlc.Error );
END_IF
]]></ST>
</Implementation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ IF Execute() THEN
ELSIF NOT __ISVALIDREF(inoStatus) THEN
_varInfo :=__VARINFO(inoStatus);
Messenger.Programming(_sb.Clear().Append('<#Invalid reference: #>').Append(_varInfo.Symbol).ToString()).Pin();
// ELSIF NOT __ISVALIDREF(inoResults) THEN
// _varInfo :=__VARINFO(inoResults);
// Messenger.Programming(_sb.Clear().Append('<#Invalid reference: #>').Append(_varInfo.Symbol).ToString()).Pin();
ELSIF inTriggerType = eTcoDesignerTriggerType.TriggerWithTimeout
AND inoConfig.ErrorTime < inoConfig.TriggerTimemout THEN
Messenger.Error(_sb.Clear().Append('<#Error time is lower than timeout. Please check config!#>').ToString()).Pin();
ELSE
_progress := _progress + 1;
CallTimers(FALSE);
Expand All @@ -62,6 +64,11 @@ IF Execute() THEN
IF _progress = 1 THEN
IF inTriggerType = eTcoDesignerTriggerType.TriggerFast THEN
_progress := _progress + 1;
ELSIF inTriggerType = eTcoDesignerTriggerType.TriggerWithTimeout THEN
inoIoData.PlcToPc.Timeout:=TIME_TO_UINT( inoConfig.TriggerTimemout);
IF _clearResultsTask.Invoke().Done THEN
_progress := _progress + 1;
END_IF;
ELSIF _clearResultsTask.Invoke().Done THEN
_progress := _progress + 1;
END_IF
Expand Down Expand Up @@ -103,7 +110,9 @@ IF Execute() THEN
CallTimers(TRUE);
THIS^.ThrowWhen(_errorTimer.Q OR NOT(THIS^.inoIoData.PcToPlc.TriggerTimeout XOR inTriggerType = eTcoDesignerTriggerType.TriggerWithTimeout) OR THIS^.inoIoData.PcToPlc.Error );
THIS^.ThrowWhen(_errorTimer.Q OR THIS^.inoIoData.PcToPlc.Error
OR (inTriggerType = eTcoDesignerTriggerType.TriggerWithTimeout AND THIS^.inoIoData.PcToPlc.TriggerTimeout) );
END_IF
]]></ST>
</Implementation>
Expand Down Expand Up @@ -173,6 +182,7 @@ METHOD PROTECTED OnError
]]></Declaration>
<Implementation>
<ST><![CDATA[THIS^.inoStatus.ActionDescription := '<#Trigger started.#>';
inoIoData.PlcToPc.Timeout:=0;
]]></ST>
</Implementation>
</Method>
Expand Down
Loading

0 comments on commit 555a989

Please sign in to comment.