483 lines
16 KiB
C#
483 lines
16 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using HMIToolkit;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using Heisig.HMI.AdsManager;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using TwinCAT.TypeSystem;
|
|
using System.Collections.ObjectModel;
|
|
using System.Security.Policy;
|
|
using UniperHMI.Model;
|
|
using System.Printing;
|
|
|
|
namespace UniperHMI
|
|
{
|
|
public sealed partial class KukaRobotPageVM : ObservableValidator, IDisposable
|
|
{
|
|
|
|
private readonly string? _variableName = "_adsVariable_";
|
|
|
|
private const string sStartRobotJob = "_adsVariable_kukaStartRobotJob";
|
|
private const string sAbortRobotJob = "_adsVariable_kukaAbortRobotJob";
|
|
private const string sResetState = "_adsVariable_kukaResetState";
|
|
private const string sClearState = "_adsVariable_kukaClearState";
|
|
private const string sAcknPLCJob = "_adsVariable_kukaAcknPLCJob";
|
|
private const string sCoolplateIndex = "_adsVariable_kukaCoolplateIndex";
|
|
private const string sHotplateIndex = "_adsVariable_kukaHotPlateIndex";
|
|
private const string sPieceThickness = "_adsVariable_kukaPieceThickness";
|
|
private const string sJobGrippSide = "_adsVariable_kukaJobGrippSide";
|
|
private const string sJobGrippType = "_adsVariable_kukaJobGrippType";
|
|
private const string sChuckMagazinPlace = "_adsVariable_kukaChuckMagazinPlace";
|
|
private const string sSelectedRobotJob = "_adsVariable_kukaRobotJob";
|
|
private const string sOffsetPick_X = "_adsVariable_kukaOffsetPick_X";
|
|
private const string sOffsetPick_Y = "_adsVariable_kukaOffsetPick_Y";
|
|
private const string sOffsetPlace_X = "_adsVariable_kukaOffsetPlace_X";
|
|
private const string sOffsetPlace_Y = "_adsVariable_kukaOffsetPlace_Y";
|
|
private const string sOffsetNIOPick_X = "_adsVariable_kukaOffsetNIOPick_X";
|
|
private const string sOffsetNIOPick_Y = "_adsVariable_kukaOffsetNIOPick_Y";
|
|
private const string sOffsetNIOPlace_X = "_adsVariable_kukaOffsetNIOPlace_X";
|
|
private const string sOffsetNIOPlace_Y = "_adsVariable_kukaOffsetNIOPlace_Y";
|
|
|
|
|
|
private BMSControlModeEntry currentControlMode;
|
|
public BMSControlModeEntry CurrentControlMode
|
|
{
|
|
get { return currentControlMode; }
|
|
set
|
|
{
|
|
currentControlMode = value;
|
|
ccmChanged();
|
|
}
|
|
}
|
|
private E_BMS_CONTROL_MODE bmsControlMode;
|
|
|
|
[ObservableProperty]
|
|
public bool canChangeRobotJob;
|
|
|
|
[ObservableProperty]
|
|
public RobotJobentry robotJobActiveValue;
|
|
|
|
[ObservableProperty]
|
|
public RobotJobentry robotJobFinishedValue;
|
|
|
|
[ObservableProperty]
|
|
public bool canStartRobotJob;
|
|
|
|
[ObservableProperty]
|
|
public HMIControlButtonVM? startButton;
|
|
|
|
[ObservableProperty]
|
|
public bool canAbortRobotJob;
|
|
|
|
[ObservableProperty]
|
|
public HMIControlButtonVM? abortButton;
|
|
|
|
|
|
private int jobGrippSide;
|
|
public int JobGrippSide
|
|
{
|
|
get { return jobGrippSide; }
|
|
set
|
|
{
|
|
jobGrippSide = value;
|
|
_adsManager?.WriteValue(sJobGrippSide, value);
|
|
}
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public bool canChangeJobGrippSide;
|
|
|
|
|
|
private int jobGrippType;
|
|
public int JobGrippType
|
|
{
|
|
get { return jobGrippType; }
|
|
set
|
|
{
|
|
jobGrippType = value;
|
|
_adsManager?.WriteValue(sJobGrippType, value);
|
|
|
|
}
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public bool canChangeJobGrippType;
|
|
|
|
|
|
private int chuckMagazinPlace;
|
|
public int ChuckMagazinPlace
|
|
{
|
|
get { return chuckMagazinPlace; }
|
|
set
|
|
{
|
|
chuckMagazinPlace = value;
|
|
_adsManager?.WriteValue(sChuckMagazinPlace, value);
|
|
}
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public bool canChangeChuckMagazinPlace;
|
|
|
|
|
|
private double pieceThickness;
|
|
public double PieceThickness
|
|
{
|
|
get { return pieceThickness; }
|
|
set
|
|
{
|
|
pieceThickness = value;
|
|
_adsManager?.WriteValue(sPieceThickness, value);
|
|
}
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public bool canChangePieceThickness;
|
|
|
|
|
|
private double offsetPick_X;
|
|
public double OffsetPick_X
|
|
{
|
|
get { return offsetPick_X; }
|
|
set
|
|
{
|
|
offsetPick_X = value;
|
|
_adsManager?.WriteValue(sOffsetPick_X, value);
|
|
}
|
|
}
|
|
|
|
|
|
private double offsetPick_Y;
|
|
public double OffsetPick_Y
|
|
{
|
|
get { return offsetPick_Y; }
|
|
set
|
|
{
|
|
offsetPick_Y = value;
|
|
_adsManager?.WriteValue(sOffsetPick_Y, value);
|
|
}
|
|
}
|
|
[ObservableProperty]
|
|
public bool canChangeOffsetPick;
|
|
|
|
|
|
private double offsetPlace_X;
|
|
public double OffsetPlace_X
|
|
{
|
|
get { return offsetPlace_X; }
|
|
set
|
|
{
|
|
offsetPlace_X = value;
|
|
_adsManager?.WriteValue(sOffsetPlace_X, value);
|
|
}
|
|
}
|
|
|
|
private double offsetPlace_Y;
|
|
public double OffsetPlace_Y
|
|
{
|
|
get { return offsetPlace_Y; }
|
|
set
|
|
{
|
|
offsetPlace_Y = value;
|
|
_adsManager?.WriteValue(sOffsetPlace_Y, value);
|
|
}
|
|
}
|
|
|
|
|
|
[ObservableProperty]
|
|
public bool canChangeOffsetPlace;
|
|
|
|
|
|
private double offsetNIOPick_X;
|
|
public double OffsetNIOPick_X
|
|
{
|
|
get { return offsetNIOPick_X; }
|
|
set
|
|
{
|
|
offsetNIOPick_X = value;
|
|
_adsManager?.WriteValue(sOffsetNIOPick_X, value);
|
|
}
|
|
}
|
|
|
|
private double offsetNIOPick_Y;
|
|
public double OffsetNIOPick_Y
|
|
{
|
|
get { return offsetNIOPick_Y; }
|
|
set
|
|
{
|
|
offsetNIOPick_Y = value;
|
|
_adsManager?.WriteValue(sOffsetNIOPick_Y, value);
|
|
}
|
|
}
|
|
[ObservableProperty]
|
|
public bool canChangeOffsetNIOPick;
|
|
|
|
|
|
private double offsetNIOPlace_X;
|
|
public double OffsetNIOPlace_X
|
|
{
|
|
get { return offsetNIOPlace_X; }
|
|
set
|
|
{
|
|
offsetNIOPlace_X = value;
|
|
_adsManager?.WriteValue(sOffsetNIOPlace_X, value);
|
|
}
|
|
}
|
|
|
|
private double offsetNIOPlace_Y;
|
|
public double OffsetNIOPlace_Y
|
|
{
|
|
get { return offsetNIOPlace_Y; }
|
|
set
|
|
{
|
|
offsetNIOPlace_Y = value;
|
|
_adsManager?.WriteValue(sOffsetNIOPlace_Y, value);
|
|
}
|
|
}
|
|
[ObservableProperty]
|
|
public bool canChangeOffsetNIOPlace;
|
|
|
|
|
|
private int hotplateIndex;
|
|
public int HotplateIndex
|
|
{
|
|
get { return hotplateIndex; }
|
|
set
|
|
{
|
|
hotplateIndex = value;
|
|
_adsManager?.WriteValue(sHotplateIndex, value);
|
|
}
|
|
|
|
|
|
}
|
|
[ObservableProperty]
|
|
public bool canChangeHotPlateIndex;
|
|
|
|
|
|
private int coolplateIndex;
|
|
public int CoolplateIndex
|
|
{
|
|
get { return coolplateIndex; }
|
|
set
|
|
{
|
|
coolplateIndex = value;
|
|
_adsManager?.WriteValue(sCoolplateIndex, value);
|
|
}
|
|
}
|
|
|
|
|
|
[ObservableProperty]
|
|
public bool canChangeCoolPlateIndex;
|
|
|
|
[ObservableProperty]
|
|
private RobotJobenum robotJob;
|
|
|
|
[ObservableProperty]
|
|
public ObservableCollection<RobotJobentry> robotJobs =
|
|
[
|
|
new RobotJobentry(RobotJobenum.NONE, " ------- "),
|
|
new RobotJobentry(RobotJobenum.PICK_TRAYFEEDER, "10 - Hole Teil von Trayfeeder 'Eingabe' "),
|
|
new RobotJobentry(RobotJobenum.PLACE_TRAYFEEDER, "11 - Lege Teil in Trayfeeder 'Ausgabe' "),
|
|
new RobotJobentry(RobotJobenum.PUT_ALIGNMENT, "15 - Lege Teil auf Ausrichtstation"),
|
|
new RobotJobentry(RobotJobenum.PICK_ALIGNMENT, "16 - Hole Teil von Ausrichtstation"),
|
|
new RobotJobentry(RobotJobenum.PUT_ETCHER_1, "20 - Lege Teil in Ätzer 1"),
|
|
new RobotJobentry(RobotJobenum.PUT_ETCHER_2, "21 - Lege Teil in Ätzer 2"),
|
|
new RobotJobentry(RobotJobenum.PICK_ETCHER_1, "22 - Hole Teil aus Ätzer 1"),
|
|
new RobotJobentry(RobotJobenum.PICK_ETCHER_2, "23 - Hole Teil aus Ätzer 2"),
|
|
new RobotJobentry(RobotJobenum.SWITCH_ETCHER_1, "24 - Tausche Teile in Ätzer 1"),
|
|
new RobotJobentry(RobotJobenum.SWITCH_ETCHER_2, "25 - Tausche Teile in Ätzer 2"),
|
|
new RobotJobentry(RobotJobenum.PUT_HVTEST_HOT, "30 - Lege Teil in HV-Teststation Warm"),
|
|
new RobotJobentry(RobotJobenum.PUT_HVTEST_COLD, "31 - Lege Teil in HV-Teststation Kalt"),
|
|
new RobotJobentry(RobotJobenum.PICK_HVTEST_HOT, "32 - Hole Teil aus HV-Teststation Warm"),
|
|
new RobotJobentry(RobotJobenum.PICK_HVTEST_COLD, "33 - Hole Teil aus HV-Teststation Kalt"),
|
|
new RobotJobentry(RobotJobenum.PUT_HOTPLATE, "40 - Lege Teil auf Heizplatte"),
|
|
new RobotJobentry(RobotJobenum.PICK_HOTPLATE, "41 - Hole Teil von Heizplatte"),
|
|
new RobotJobentry(RobotJobenum.PUT_COOLPLATE, "42 - Lege Teil auf Kühlplatte"),
|
|
new RobotJobentry(RobotJobenum.PICK_COOLPLATE, "43 - Hole Teil von Kühlplatte"),
|
|
new RobotJobentry(RobotJobenum.PICK_GRIPPER, "50 - Hole anderen Greifertyp"),
|
|
new RobotJobentry(RobotJobenum.PICK_CHUCK_ETCHER_1, "60 - Hole Drehteller aus Ätzer 1"),
|
|
new RobotJobentry(RobotJobenum.PICK_CHUCK_ETCHER_2, "61 - Hole Drehteller aus Ätzer 2"),
|
|
new RobotJobentry(RobotJobenum.PUT_CHUCK_ETCHER_1, "62 - Lege Drehteller in Ätzer 1"),
|
|
new RobotJobentry(RobotJobenum.PUT_CHUCK_ETCHER_2, "63 - Lege Drehteller in Ätzer 2"),
|
|
new RobotJobentry(RobotJobenum.PUT_CHUCK_MAGAZIN, "64 - Lege Drehteller in Magazin"),
|
|
new RobotJobentry(RobotJobenum.PICK_CHUCK_MAGAZIN, "65 - Hole Drehteller von Magazin"),
|
|
new RobotJobentry(RobotJobenum.PUT_NIO_STATION, "70 - Lege Teil auf NIO-TRAY"),
|
|
new RobotJobentry(RobotJobenum.PICK_NIO_STATION, "71 - Hole Teil von NIO-TRAY"),
|
|
new RobotJobentry(RobotJobenum.WARMUP, "80 - Aufwärmprogramm")
|
|
];
|
|
|
|
[ObservableProperty]
|
|
public ObservableCollection<PLCJobentry> pLCJobs =
|
|
[
|
|
new PLCJobentry(PLCJobenum.NONE, " ------- "),
|
|
new PLCJobentry(PLCJobenum.SCAN_QR_CODE, "10 - QR Code Scannen"),
|
|
new PLCJobentry(PLCJobenum.VACUUM_ON_ALIGNER, "15 - Vakuum Ausrichtstation einschalten"),
|
|
new PLCJobentry(PLCJobenum.VACUUM_OFF_ALIGNER, "16 - Vakuum Ausrichtstation ausschalten"),
|
|
new PLCJobentry(PLCJobenum.VACUUM_ON_ETCHER_1, "20 - Vakuum Ätzer 1 einschalten"),
|
|
new PLCJobentry(PLCJobenum.VACUUM_ON_ETCHER_2, "21 - Vakuum Ätzer 2 einschalten"),
|
|
new PLCJobentry(PLCJobenum.VACUUM_OFF_ETCHER_1, "22 - Vakuum Ätzer 1 ausschalten"),
|
|
new PLCJobentry(PLCJobenum.VACUUM_OFF_ETCHER_2, "23 - Vakuum Ätzer 2 ausschalten"),
|
|
new PLCJobentry(PLCJobenum.CHUCK_OPEN_ETCHER_1, "60 - Drehteller Ätzer 1 entriegeln"),
|
|
new PLCJobentry(PLCJobenum.CHUCK_OPEN_ETCHER_2, "61 - Drehteller Ätzer 2 entriegeln"),
|
|
new PLCJobentry(PLCJobenum.CHUCK_CLOSE_ETCHER_1, "62 - Drehteller Ätzer 1 verriegeln"),
|
|
new PLCJobentry(PLCJobenum.CHUCK_CLOSE_ETCHER_2, "63 - Drehteller Ätzer 2 verriegeln"),
|
|
];
|
|
|
|
private RobotJobentry selectedRobotJob;
|
|
public RobotJobentry SelectedRobotJob
|
|
{
|
|
get { return selectedRobotJob; }
|
|
set
|
|
{
|
|
selectedRobotJob = value;
|
|
CanChangeChuckMagazinPlace = (value == RobotJobs.First(i => i.eJob == RobotJobenum.PICK_CHUCK_MAGAZIN))
|
|
|| (value == RobotJobs.First(i => i.eJob == RobotJobenum.PUT_CHUCK_MAGAZIN));
|
|
CanChangeJobGrippType = value == RobotJobs.First(i => i.eJob == RobotJobenum.PICK_GRIPPER);
|
|
|
|
_adsManager?.WriteValue(sSelectedRobotJob, SelectedRobotJob.eJob);
|
|
}
|
|
}
|
|
|
|
[ObservableProperty]
|
|
private PLCJobentry selectedPLCJob;
|
|
|
|
|
|
private readonly IAdsManager? _adsManager;
|
|
|
|
public KukaRobotPageVM()
|
|
{
|
|
StartButton = new HMIControlButtonVM();
|
|
AbortButton = new HMIControlButtonVM();
|
|
selectedRobotJob = RobotJobs.First(i => i.eJob == RobotJobenum.WARMUP);
|
|
robotJobActiveValue = RobotJobs.First(i => i.eJob == RobotJobenum.PUT_HVTEST_COLD);
|
|
robotJobFinishedValue = RobotJobs.First(i => i.eJob == RobotJobenum.PICK_HOTPLATE);
|
|
|
|
canChangeRobotJob = true;
|
|
selectedPLCJob = PLCJobs.First(i => i.eJob == PLCJobenum.NONE);
|
|
currentControlMode = new BMSControlModeEntry(E_BMS_CONTROL_MODE.MANUAL, "Manual");
|
|
|
|
}
|
|
|
|
public KukaRobotPageVM(IAdsManager adsManager, string variableName)
|
|
{
|
|
_adsManager = adsManager;
|
|
_variableName = variableName;
|
|
|
|
StartButton = new HMIControlButtonVM(_adsManager, sStartRobotJob);
|
|
AbortButton = new HMIControlButtonVM(_adsManager, sAbortRobotJob);
|
|
currentControlMode = new BMSControlModeEntry(E_BMS_CONTROL_MODE.MANUAL, "Manual");
|
|
CurrentControlMode = new BMSControlModeEntry(E_BMS_CONTROL_MODE.MANUAL, "Manual");
|
|
|
|
selectedRobotJob = RobotJobs.First(i => i.eJob == RobotJobenum.WARMUP);
|
|
canChangeRobotJob = true;
|
|
selectedPLCJob = PLCJobs.First(i => i.eJob == PLCJobenum.NONE);
|
|
|
|
jobGrippSide = 1;
|
|
jobGrippType = 2;
|
|
canChangeJobGrippType = false;
|
|
robotJobActiveValue = RobotJobs.First(i => i.eJob == RobotJobenum.PUT_HVTEST_COLD);
|
|
robotJobFinishedValue = RobotJobs.First(i => i.eJob == RobotJobenum.PICK_HOTPLATE);
|
|
|
|
chuckMagazinPlace = 2;
|
|
canChangeChuckMagazinPlace = false;
|
|
canChangeJobGrippType = false;
|
|
|
|
|
|
|
|
pieceThickness = 2.7;
|
|
|
|
offsetPlace_X = 88;
|
|
offsetPlace_Y = 79;
|
|
|
|
offsetPick_X = 89;
|
|
offsetPick_Y = 81;
|
|
|
|
offsetNIOPick_X = 176;
|
|
offsetNIOPick_Y = 90;
|
|
|
|
offsetNIOPlace_X = 123;
|
|
offsetNIOPlace_Y = 313;
|
|
|
|
hotplateIndex = 3;
|
|
coolplateIndex = 5;
|
|
|
|
//_adsManager.Register("GVL_SCADA.eCurrentControlMode", CurrentControlModeChanged);
|
|
|
|
//_adsManager.Register(_variableName + ".diSetpointAutomatic", SetpointChanged);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
StartButton?.Dispose();
|
|
StartButton = null;
|
|
AbortButton?.Dispose();
|
|
AbortButton = null;
|
|
|
|
_adsManager?.Deregister("GVL_SCADA.eCurrentControlMode", CurrentControlModeChanged);
|
|
|
|
//_adsManager?.Deregister(_variableName + ".diSetpointAutomatic", SetpointChanged);
|
|
}
|
|
|
|
private void CurrentControlModeChanged(object? sender, ValueChangedEventArgs e)
|
|
{
|
|
bmsControlMode = (E_BMS_CONTROL_MODE)e.Value;
|
|
currentControlMode.eMode = bmsControlMode;
|
|
currentControlMode.Name = "Test";
|
|
ccmChanged();
|
|
|
|
}
|
|
|
|
private void ccmChanged()
|
|
{
|
|
if (currentControlMode.eMode == E_BMS_CONTROL_MODE.MANUAL)
|
|
{
|
|
CanChangeCoolPlateIndex = true;
|
|
CanChangeHotPlateIndex = true;
|
|
CanChangeOffsetNIOPick = true;
|
|
CanChangeOffsetNIOPlace = true;
|
|
CanChangeOffsetPick = true;
|
|
CanChangeOffsetPlace = true;
|
|
CanChangePieceThickness = true;
|
|
CanChangeRobotJob = true;
|
|
CanChangeJobGrippSide = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
CanChangeCoolPlateIndex = false;
|
|
CanChangeHotPlateIndex = false;
|
|
CanChangeOffsetNIOPick = false;
|
|
CanChangeOffsetNIOPlace = false;
|
|
CanChangeOffsetPick = false;
|
|
CanChangeOffsetPlace = false;
|
|
CanChangePieceThickness = false;
|
|
CanChangeRobotJob = false;
|
|
CanChangeJobGrippSide = false;
|
|
}
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void ClearState()
|
|
{
|
|
_adsManager?.WriteValue(sClearState, true);
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void ResetState()
|
|
{
|
|
_adsManager?.WriteValue(sResetState, true);
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void StartRobotJob()
|
|
{
|
|
_adsManager?.WriteValue(sStartRobotJob, true);
|
|
}
|
|
|
|
|
|
[RelayCommand]
|
|
private void AbortRobotJob()
|
|
{
|
|
_adsManager?.WriteValue(sAbortRobotJob, true);
|
|
}
|
|
}
|
|
}
|