Push Alpha Version
This commit is contained in:
@@ -5,117 +5,104 @@ using Heisig.HMI.AdsManager;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using TwinCAT.TypeSystem;
|
||||
using System.Collections.ObjectModel;
|
||||
using Common;
|
||||
using InfineonHMI.Model;
|
||||
|
||||
using UniperHMI.Model;
|
||||
namespace UniperHMI
|
||||
namespace InfineonHMI
|
||||
{
|
||||
public sealed partial class MediaCabinetPageVM : ObservableValidator, IDisposable
|
||||
{
|
||||
private int _setpoint;
|
||||
|
||||
[Range(-40000, 40000)]
|
||||
public int Setpoint
|
||||
{
|
||||
get => this._setpoint;
|
||||
set => SetProperty(ref this._setpoint, value, true);
|
||||
}
|
||||
private IAdsManager _adsManager;
|
||||
private string? _variableName;
|
||||
|
||||
[ObservableProperty]
|
||||
private int processValue;
|
||||
[ObservableProperty] private MediaContainerVm container1Vm;
|
||||
[ObservableProperty] private MediaContainerVm container2Vm;
|
||||
[ObservableProperty] private MediaContainerVm container3Vm;
|
||||
[ObservableProperty] private MediaContainerVm container4Vm;
|
||||
[ObservableProperty] private MediaContainerVm container5Vm;
|
||||
[ObservableProperty] private MediaContainerVm container6Vm;
|
||||
[ObservableProperty] private MediaContainerVm container7Vm;
|
||||
[ObservableProperty] private MediaContainerVm container8Vm;
|
||||
[ObservableProperty] private MediaContainerVm container9Vm;
|
||||
|
||||
[ObservableProperty]
|
||||
public HMIControlButtonVM? startButton;
|
||||
|
||||
[ObservableProperty]
|
||||
public HMIControlButtonVM? stopButton;
|
||||
|
||||
[ObservableProperty]
|
||||
private E_BMS_CONTROL_MODE bmsControlMode;
|
||||
|
||||
[ObservableProperty]
|
||||
public ObservableCollection<BMSControlModeEntry> reqBMSControlModes =
|
||||
[
|
||||
new BMSControlModeEntry(E_BMS_CONTROL_MODE.AUTO_REMOTE, "Auto Remote"),
|
||||
new BMSControlModeEntry(E_BMS_CONTROL_MODE.AUTO_LOCAL, "Auto Local"),
|
||||
new BMSControlModeEntry(E_BMS_CONTROL_MODE.SAFETY_CHECK, "Safety Check"),
|
||||
new BMSControlModeEntry(E_BMS_CONTROL_MODE.CAPACITY_TEST, "Capacity Test"),
|
||||
new BMSControlModeEntry(E_BMS_CONTROL_MODE.MANUAL, "Manual")
|
||||
];
|
||||
|
||||
[ObservableProperty]
|
||||
private BMSControlModeEntry selectedControlMode;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool canChangeControlMode;
|
||||
|
||||
private readonly string? _variableName;
|
||||
|
||||
private readonly IAdsManager? _adsManager;
|
||||
|
||||
public MediaCabinetPageVM()
|
||||
{
|
||||
StartButton = new HMIControlButtonVM();
|
||||
StopButton = new HMIControlButtonVM();
|
||||
SelectedControlMode = ReqBMSControlModes[1];
|
||||
canChangeControlMode = true;
|
||||
}
|
||||
|
||||
public MediaCabinetPageVM(IAdsManager adsManager, string variableName)
|
||||
{
|
||||
_adsManager = adsManager;
|
||||
public MediaCabinetPageVM(IAdsManager adsManager, string variableName)
|
||||
{
|
||||
_adsManager = adsManager;
|
||||
_variableName = variableName;
|
||||
|
||||
//StartButton = new HMIControlButtonVM(_adsManager, _variableName + ".stStartAutoButton");
|
||||
//StopButton = new HMIControlButtonVM(_adsManager, _variableName + ".stStopAutoButton");
|
||||
Container1Vm = new MediaContainerVm(adsManager, variableName + ".stContainer1");
|
||||
Container2Vm = new MediaContainerVm(adsManager, variableName + ".stContainer2");
|
||||
Container3Vm = new MediaContainerVm(adsManager, variableName + ".stContainer3");
|
||||
Container4Vm = new MediaContainerVm(adsManager, variableName + ".stContainer4");
|
||||
Container5Vm = new MediaContainerVm(adsManager, variableName + ".stContainer5");
|
||||
Container6Vm = new MediaContainerVm(adsManager, variableName + ".stContainer6");
|
||||
Container7Vm = new MediaContainerVm(adsManager, variableName + ".stContainer7");
|
||||
Container8Vm = new MediaContainerVm(adsManager, variableName + ".stContainer8");
|
||||
Container9Vm = new MediaContainerVm(adsManager, variableName + ".stContainer9");
|
||||
|
||||
SelectedControlMode = ReqBMSControlModes[1];
|
||||
Container1Vm.SName = "Container1";
|
||||
Container2Vm.SName = "Container2";
|
||||
Container3Vm.SName = "Container3";
|
||||
Container4Vm.SName = "Container4";
|
||||
Container5Vm.SName = "Container5";
|
||||
Container6Vm.SName = "Container6";
|
||||
Container7Vm.SName = "Container7";
|
||||
Container8Vm.SName = "Container8";
|
||||
Container9Vm.SName = "Container9";
|
||||
|
||||
_adsManager.Register("GVL_SCADA.xCanChangeControlMode", CCCMChanged);
|
||||
}
|
||||
|
||||
_adsManager.Register(_variableName + ".diSetpointAutomatic", SetpointChanged);
|
||||
}
|
||||
public MediaCabinetPageVM()
|
||||
{
|
||||
Container1Vm = new MediaContainerVm();
|
||||
Container2Vm = new MediaContainerVm();
|
||||
Container3Vm = new MediaContainerVm();
|
||||
Container4Vm = new MediaContainerVm();
|
||||
Container5Vm = new MediaContainerVm();
|
||||
Container6Vm = new MediaContainerVm();
|
||||
Container7Vm = new MediaContainerVm();
|
||||
Container8Vm = new MediaContainerVm();
|
||||
Container9Vm = new MediaContainerVm();
|
||||
|
||||
private void SetpointChanged(object? sender, ValueChangedEventArgs e)
|
||||
{
|
||||
Setpoint = (int)e.Value;
|
||||
}
|
||||
|
||||
private void CCCMChanged(object? sender, ValueChangedEventArgs e)
|
||||
{
|
||||
CanChangeControlMode = (bool)e.Value;
|
||||
}
|
||||
Container1Vm.SName = "Container1";
|
||||
Container2Vm.SName = "Container2";
|
||||
Container3Vm.SName = "Container3";
|
||||
Container4Vm.SName = "Container4";
|
||||
Container5Vm.SName = "Container5";
|
||||
Container6Vm.SName = "Container6";
|
||||
Container7Vm.SName = "Container7";
|
||||
Container8Vm.SName = "Container8";
|
||||
Container9Vm.SName = "Container9";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
StartButton?.Dispose();
|
||||
StartButton = null;
|
||||
StopButton?.Dispose();
|
||||
StopButton = null;
|
||||
|
||||
_adsManager?.Deregister("GVL_SCADA.xCanChangeControlMode", CCCMChanged);
|
||||
Container1Vm.Dispose();
|
||||
Container2Vm.Dispose();
|
||||
Container3Vm.Dispose();
|
||||
Container4Vm.Dispose();
|
||||
Container5Vm.Dispose();
|
||||
Container6Vm.Dispose();
|
||||
Container7Vm.Dispose();
|
||||
Container8Vm.Dispose();
|
||||
Container9Vm.Dispose();
|
||||
|
||||
_adsManager?.Deregister(_variableName + ".diSetpointAutomatic", SetpointChanged);
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void StartAutomatic()
|
||||
{
|
||||
_adsManager?.WriteValue(_variableName + ".diSetpointAutomatic", Setpoint);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void StopAutomatic()
|
||||
{
|
||||
_adsManager?.WriteValue(_variableName + ".diSetpointAutomatic", 0);
|
||||
Setpoint = 0;
|
||||
}
|
||||
|
||||
public static ValidationResult ValidatePower(int power, ValidationContext context)
|
||||
{
|
||||
if (power < -40000 || power > 40000)
|
||||
return new("Must be between -40.000 and +40.000");
|
||||
else
|
||||
return ValidationResult.Success!;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user