Skip to content

Commit

Permalink
[BUG] Users are able to enter manual mode without adequate permission…
Browse files Browse the repository at this point in the history
…s, potentially leading to unauthorized actions (#143)

* Create draft PR for #120

* +not possible start any modes if user dont have  a proper rights to do that (also  valid forcontext  menu)

+ReworkInstructor -added as sinbgle project , allow us find best suitable  rework defined in table .

* +sln file

---------

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 Jul 17, 2024
1 parent 12d3c47 commit 192a5d8
Show file tree
Hide file tree
Showing 31 changed files with 1,909 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
</System>
<Plc>
<Project GUID="{1F826822-78EF-46D2-B0C2-A803A090596D}" Name="x_template_xPlc" PrjFilePath="x_template_xPlc\x_template_xPlc.plcproj" TmcFilePath="x_template_xPlc\x_template_xPlc.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" SymbolicMapping="true">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="x_template_xPlc\x_template_xPlc.tmc" TmcHash="{1F9D1A1A-2F73-CE6D-ACAE-C20B46BB167B}">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="x_template_xPlc\x_template_xPlc.tmc" TmcHash="{EAD70BAD-0C4C-0592-AEDD-56DCCC2D4E2C}">
<Name>x_template_xPlc Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="1">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ReworkData" Id="{5d026743-fc1e-4aff-9945-5025b1a556e3}">
<Declaration><![CDATA[TYPE ReworkData :
STRUCT
{attribute addProperty Name "<#Entity Id#>"}
EntityId: STRING;
{attribute addProperty Name "<#ReworkId#>"}
ReworkId: STRING;
{attribute addProperty Name "<#Rework Instrukcia#>"}
ReworkInstruction:STRING;
{attribute addProperty Name "<#Rework Instrukcia najdena#>"}
ReworkInstructionFound:BOOL;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="ReworkInstructionTask" Id="{3ef14e60-716c-4442-a5d9-2c2bffc56045}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK ReworkInstructionTask EXTENDS TcoCore.TcoRemoteTask
VAR
_data:ReworkData;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[SUPER^();]]></ST>
</Implementation>
<Property Name="Data" Id="{32b6d340-2bfe-4579-a993-a9b7903ce5f3}">
<Declaration><![CDATA[PROPERTY Data : REFERENCE TO ReworkData
]]></Declaration>
<Get Name="Get" Id="{6b950daa-f7da-454b-8ac3-6244534c7457}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[Data ref= _data;]]></ST>
</Implementation>
</Get>
</Property>
<Method Name="Run" Id="{dea1cab6-aaae-41ee-91e0-076daafab7df}">
<Declaration><![CDATA[METHOD Run : REFERENCE TO ReworkInstructionTask
VAR_INPUT
inEntityId:STRING;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[_data.EntityId:=inEntityId;
Run REF= THIS^;
]]></ST>
</Implementation>
</Method>
</POU>
</TcPlcObject>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="eReworkResults" Id="{d19c3b1f-0111-4597-b007-1c1a1e19722e}">
<Declaration><![CDATA[{attribute 'qualified_only'}
{attribute 'strict'}
TYPE eReworkResults :
(
None:=0,
Pass := 1,
FailedEntityInProgress:=4,
FailedEntityOk:=3,
FailedEntityHasLessProgress:=2
);
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ VAR
{attribute addProperty Name "<#Test multi positions#>"}
_positionsMulti : CU00xTestMultiPositions(THIS^);
END_VAR
]]></Declaration>
<Implementation>
Expand Down Expand Up @@ -266,6 +268,7 @@ END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[
Components.PairTagTask();
Components.ReworkInstructionTask();
(*
components.Group1.horizontalCylinder(inoAtHomePos:=GVL_iXlinker.EC1.EK1200.IA1_EL1809.Channel_1.Input,
inoAtWorkPos:=GVL_iXlinker.EC1.EK1200.IA1_EL1809.Channel_2.Input,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ TYPE
Supply : TcoAimTtiPowerSupply.TcoQl355P_v_1_x_x (THISSTRUCT);
{attribute wpf [Container(Layout.Stack)]}
PairTagTask: PairTagTask(THISSTRUCT);
{attribute wpf [Container(Layout.Stack)]}
{attribute addProperty Name "<#ReworkInstruction#>"}
ReworkInstructionTask : ReworkInstructionTask(THISSTRUCT);
{attribute wpf [Container(Layout.Stack,"DRIVES AND MANIPULATORS")]}
{attribute wpf [Group(Layout.Scroll)]}
{attribute addProperty Name "MultiAxis"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
CU00xProcessData EXTENDS CUProcessDataBase :
STRUCT
{attribute wpf [Container(Layout.Stack)]}
{attribute addProperty Name "Bolt present inspection"}
BoltPresenceInspector : TcoInspectors.TcoDigitalInspector(THISSTRUCT);
{attribute addProperty Name "Bolt Dimension inspection"}
BoltDimensionPresenceInspector : TcoInspectors.TcoAnalogueInspector(THISSTRUCT);
{attribute addProperty Name "Bolt code inspection"}
BoltDatacodePresenceInspector : TcoInspectors.TcoDataInspector(THISSTRUCT);
{attribute addProperty Name "Dimension inspection 1"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
<Compile Include="Abstractions\Components\MtsFeeding\TcoPlsPaletizator_Status_v_1_x_x.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="Abstractions\Components\Rework\eReworkResults.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="Abstractions\Components\Rework\ReworkData.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="Abstractions\Components\Rework\ReworkInstructionTask.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Abstractions\Components\WrappedComponent\WrappedComponentExample.TcPOU">
<SubType>Code</SubType>
</Compile>
Expand Down Expand Up @@ -373,6 +382,7 @@
<Folder Include="Abstractions" />
<Folder Include="Abstractions\Components\ArrayRenderingExample" />
<Folder Include="Abstractions\Components\MtsFeeding" />
<Folder Include="Abstractions\Components\Rework" />
<Folder Include="Abstractions\Components\WrappedComponent" />
<Folder Include="Abstractions\CUBase" />
<Folder Include="Abstractions\CUBase\Data" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Text;
Expand Down Expand Up @@ -137,7 +138,7 @@ private IEnumerable<string> ReqProperty(object obj)
var retVal = new List<string>();
switch (obj)
{
// here you define properties witch are relevant for reqired types to change by rework
// here you define properties witch are relevant for required types to change by rework
case TcoInspectors.PlainTcoDigitalInspectorData c:
return PropertyHelper.GetPropertiesNames(c, p => p.RetryAttemptsCount ,p =>p.IsByPassed,p => p.IsExcluded);
case TcoInspectors.PlainTcoAnalogueInspectorData c:
Expand All @@ -156,7 +157,7 @@ private IEnumerable<string> ReqProperty(object obj)

private bool Exclude(object obj)
{
// some special conditions to exluce
// some special conditions to exclude
return false;
}

Expand All @@ -165,8 +166,12 @@ private bool Include(object obj)
switch (obj)
{
// here is definitions of all types and condition witch are relevat to change by rework (source)
case TcoInspectors.PlainTcoInspectorData c:
case TcoInspectors.PlainTcoDigitalInspectorData c:
return c is TcoInspectors.PlainTcoDigitalInspectorData;
case TcoInspectors.PlainTcoAnalogueInspectorData c:
return c is TcoInspectors.PlainTcoAnalogueInspectorData;
case TcoInspectors.PlainTcoDataInspectorData c:
return c is TcoInspectors.PlainTcoDataInspectorData;
case PlainCuHeader c:
return c is PlainCuHeader;
//&& (c.NextOnPassed != 0
Expand Down
50 changes: 47 additions & 3 deletions templates/mts-s-template/t/src/x_template_xHmi.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using Newtonsoft.Json;
using x_template_xReworkInstructor.Instructor;
using x_template_xReworkInstructor.Instructor.View;

namespace x_template_xHmi.Wpf
{
Expand Down Expand Up @@ -368,8 +370,6 @@ private void SetUpRepositoriesUsingRavenDb()
CuxInstructor = new InstructorController(_instructionPlanHandler, new InstructableSequencer(x_template_xPlc.MAIN._technology._cu00x._automatTask));
CuxParalellInstructor = new InstructorController(_instructionPlanHandler, new InstructableSequencer(x_template_xPlc.MAIN._technology._cu00x._automatTask._paralellTask));



}


Expand Down Expand Up @@ -420,9 +420,52 @@ private void SetUpRepositoriesUsingMongoDb()
CuxParalellInstructor = new InstructorController(_instructionPlanHandler, new InstructableSequencer(x_template_xPlc.MAIN._technology._cu00x._automatTask._paralellTask));




Log.Information(@"Initialize Rework instructor repository...");



//Rework Instructor
var _reworkInstructionPlanHandler = RepositoryDataSetHandler<ReworkInstructionItem>.CreateSet(new MongoDbRepository<EntitySet<ReworkInstructionItem>>(new MongoDbRepositorySettings<EntitySet<ReworkInstructionItem>>(Entry.Settings.GetConnectionString(), Entry.Settings.DbName, "ReworkInstructions")));

CuxReworkInstructor = new ReworkInstructorController(_reworkInstructionPlanHandler, new MongoDbRepository<PlainProcessData>(ProcessDataRepoSettings), x_template_xPlc.MAIN._technology._cu00x._processData._data);

Action getReworkInstruction = () => GetReworkInstruction(x_template_xPlc.MAIN._technology._cu00x._components.ReworkInstructionTask,CuxReworkInstructor);
x_template_xPlc.MAIN._technology._cu00x._components.ReworkInstructionTask.InitializeExclusively(getReworkInstruction);

Log.Information(@"Initialize Rework instructor repository... Done");

}

private void GetReworkInstruction(ReworkInstructionTask task, ReworkInstructorController reworkInstructor)
{
try
{
task.Read();
reworkInstructor.FindInsturction(task._data.EntityId.Cyclic);
if (string.IsNullOrEmpty(reworkInstructor.CurrentInstruction.ReworkName))
{
task._data.ReworkId.Cyclic = "";
task._data .ReworkInstruction.Cyclic = "AUTO REWORK NOT FOUND!";
task._data.ReworkInstructionFound.Cyclic = false;

}
else
{
task._data.ReworkId.Synchron = reworkInstructor.CurrentInstruction.ReworkName;
task._data.ReworkInstruction.Cyclic = "AUTO REWORK FOUND - " + reworkInstructor.CurrentInstruction.ReworkName;
task._data.ReworkInstructionFound.Cyclic = true;

}
task.Write();
}
catch (Exception ex)
{

Console.WriteLine(ex.ToString());
}

}
private void GetProductionPlan(ProductionPlaner productionPlaner)
{
ProductionItem item;
Expand Down Expand Up @@ -459,6 +502,7 @@ public static x_template_xPlcTwinController x_template_xPlc
public static LanguageSelectionViewModel LanguageSelectionModel { get; private set; }
public static ShutdownViewModel AppShutdownModel { get; private set; } = new ShutdownViewModel();
public bool DataExchangeActive { get; private set; } = true;
public static ReworkInstructorController CuxReworkInstructor { get; private set; }


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ void Update()
var automatTask = Component.GetType().GetProperty("_automatTask")?.GetValue(Component) as TcoTaskedSequencer;
if (automatTask != null)
{
automatTask._task.ExecuteDialog = () =>
automatTask._task.Roles = x_template_xPlcConnector.DefaultRoles.automat_start;
automatTask._task.ExecuteDialog = () =>
{
return MessageBox.Show(x_template_xHmi.Wpf.Properties.strings.AutomatWarning, "Automat", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes;
};
Expand All @@ -114,7 +115,8 @@ void Update()
var groundTask = Component.GetType().GetProperty("_groundTask")?.GetValue(Component) as TcoTaskedSequencer;
if (groundTask != null)
{
groundTask._task.ExecuteDialog = () =>
groundTask._task.Roles = x_template_xPlcConnector.DefaultRoles.ground_position_start;
groundTask._task.ExecuteDialog = () =>
{
return MessageBox.Show(x_template_xHmi.Wpf.Properties.strings.GroundWarning, "Ground", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes;
};
Expand All @@ -123,6 +125,7 @@ void Update()
var manualTask = Component.GetType().GetProperty("_manualTask")?.GetValue(Component) as TcoTaskedService;
if (manualTask != null)
{
manualTask.Roles = x_template_xPlcConnector.DefaultRoles.manual_start;
manualTask.ExecuteDialog = () =>
{
return MessageBox.Show(x_template_xHmi.Wpf.Properties.strings.ManualWarning, "Manual", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vortex="http://vortex.mts/xaml" xmlns:vortexs="http://vortex.security.mts/xaml"
xmlns:view="clr-namespace:x_template_xProductionPlaner.Planer.View;assembly=x_template_xProductionPlaner"
xmlns:x_template_xinstructor="clr-namespace:x_template_xInstructor;assembly=x_template_xInstructor" xmlns:view1="clr-namespace:x_template_xStatistic.Statistics.View;assembly=x_template_xStatistic" xmlns:view2="clr-namespace:x_template_xTagsDictionary.View;assembly=x_template_xTagsDictionary"

xmlns:x_template_xinstructor="clr-namespace:x_template_xInstructor;assembly=x_template_xInstructor" xmlns:view1="clr-namespace:x_template_xStatistic.Statistics.View;assembly=x_template_xStatistic" xmlns:view2="clr-namespace:x_template_xTagsDictionary.View;assembly=x_template_xTagsDictionary" xmlns:view3="clr-namespace:x_template_xReworkInstructor.Instructor.View;assembly=x_template_xReworkInstructor"
mc:Ignorable="d"
d:DesignHeight="450"
d:DesignWidth="800">
Expand Down Expand Up @@ -114,6 +115,27 @@

</TabItem>

<TabItem Header="REWORK INSTRUCTOR">

<vortexs:PermissionBox Permissions="Administrator|rework_instructor_access" SecurityMode="Disabled">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>

</Grid.RowDefinitions>
<StackPanel>
<vortex:RenderableContentControl DataContext="{Binding x_template_xPlc.MAIN._technology._cu00x._components.ReworkInstructionTask}" PresentationType="Base"></vortex:RenderableContentControl>
<vortex:RenderableContentControl DataContext="{Binding x_template_xPlc.MAIN._technology._cu00x._components.ReworkInstructionTask._data}" PresentationType="DisplaySlim"></vortex:RenderableContentControl>

</StackPanel>
<view3:ReworkInstructionView Grid.Row="1" DataContext="{Binding ReworkInstructorViewModel}"></view3:ReworkInstructionView>
</Grid>
</vortexs:PermissionBox>


</TabItem>

</TabControl>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using x_template_xStatistic.Statistics.View;
using x_template_xTagsDictionary.View;
using x_template_xPlcConnector;
using x_template_xReworkInstructor.Instructor.View;

namespace x_template_xHmi.Wpf.Views.Operator
{
Expand All @@ -35,6 +36,8 @@ public OperatorViewModel()
InstructorParalellViewModel = new InstructorViewModel(App.CuxParalellInstructor);
StatisticViewModel = new StatisticsDataViewModel(App.CuxStatistic);
TagsPairingViewModel = new TagsPairingViewModel(App.CuxTagsPairing);
ReworkInstructorViewModel = new ReworkInstructionViewModel(App.CuxReworkInstructor);




Expand All @@ -47,5 +50,6 @@ public OperatorViewModel()
public InstructorViewModel InstructorParalellViewModel { get; private set; }
public StatisticsDataViewModel StatisticViewModel { get; private set; }
public TagsPairingViewModel TagsPairingViewModel { get; private set; }
public ReworkInstructionViewModel ReworkInstructorViewModel { get; private set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<ProjectReference Include="..\x_template_xDataMerge\x_template_xDataMerge.csproj" />
<ProjectReference Include="..\x_template_xPlcConnector\x_template_xPlcConnector.csproj" />
<ProjectReference Include="..\x_template_xProductionPlaner\x_template_xProductionPlaner.csproj" />
<ProjectReference Include="..\x_template_xReworkInstructor\x_template_xReworkInstructor.csproj" />
<ProjectReference Include="..\x_template_xStatistic\x_template_xStatistic.csproj" />
<ProjectReference Include="..\x_template_xTagsDictionary\x_template_xTagsDictionary.csproj" />

Expand Down
Loading

0 comments on commit 192a5d8

Please sign in to comment.