This commit is contained in:
@@ -10,6 +10,14 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
public bool OverridePathClearances { get => _overridePathClearnaces; set { _overridePathClearnaces = value; UpdateInterlocks(); } }
|
||||
public bool OverrideDryRunClearances { get => _overrideDryRunClearances; set { _overrideDryRunClearances = value; UpdateInterlocks(); } }
|
||||
|
||||
internal bool MP1_WantActive { get; private set; }
|
||||
internal bool MP2_WantActive { get; private set; }
|
||||
internal bool P12_WantActive { get; private set; }
|
||||
internal bool P3_WantActive { get; private set; }
|
||||
internal bool P4_WantActive { get; private set; }
|
||||
internal bool P5_WantActive { get; private set; }
|
||||
internal bool P6_WantActive { get; private set; }
|
||||
|
||||
protected LegacyPamhagenPlc Plc;
|
||||
public PamhagenState State { get; private set; }
|
||||
|
||||
@@ -17,9 +25,9 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
public T1.Status? LastStatus => Plc?.LastStatus;
|
||||
public T1Error? LastError => Plc?.LastError;
|
||||
|
||||
protected LegacyPamhagenPlc.ActuatorStates Actuators;
|
||||
protected LegacyPamhagenPlc.ActuatorStates LastActuators;
|
||||
protected LegacyPamhagenPlc.SensorStates Sensors = new(default, default, default, default, default, default, default, [
|
||||
internal LegacyPamhagenPlc.ActuatorStates Actuators;
|
||||
internal LegacyPamhagenPlc.ActuatorStates LastActuators;
|
||||
internal LegacyPamhagenPlc.SensorStates Sensors = new(default, default, default, default, default, default, default, [
|
||||
FillState.Unknown, FillState.Unknown, FillState.Unknown, FillState.Unknown, FillState.Unknown, FillState.Unknown, FillState.Unknown, FillState.Unknown, FillState.Unknown
|
||||
], default);
|
||||
|
||||
@@ -37,7 +45,7 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
Actuators = await Plc.ReadOutputs();
|
||||
LastActuators = Actuators;
|
||||
Sensors = await Plc.ReadInputs();
|
||||
State = new(Sensors, () => Actuators, OverridePathClearances, OverrideDryRunClearances);
|
||||
State = new(Sensors, this);
|
||||
}
|
||||
|
||||
public async Task Shutdown() {
|
||||
@@ -52,7 +60,7 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
await Plc.WriteOutputs(LastActuators);
|
||||
}
|
||||
Sensors = await Plc.ReadInputs();
|
||||
State = new(Sensors, () => Actuators, OverridePathClearances, OverrideDryRunClearances);
|
||||
State = new(Sensors, this);
|
||||
|
||||
UpdateInterlocks();
|
||||
}
|
||||
@@ -73,6 +81,19 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
|
||||
if (State.MP1_IsActive && !State.MP1_HasClearance) StopMP1();
|
||||
if (State.MP2_IsActive && !State.MP2_HasClearance) StopMP2();
|
||||
if (State.P12_IsActive && !State.P12_HasClearance) DisableP12();
|
||||
if (State.P3_IsActive && !State.P3_HasClearance) DisableP3();
|
||||
if (State.P4_IsActive && !State.P4_HasClearance) DisableP4();
|
||||
if (State.P5_IsActive && !State.P5_HasClearance) DisableP5();
|
||||
if (State.P6_IsActive && !State.P6_HasClearance) DisableP6();
|
||||
|
||||
if (MP1_WantActive && State.MP1_HasClearance) StartMP1Forward();
|
||||
if (MP2_WantActive && State.MP2_HasClearance) StartMP2Forward();
|
||||
if (P12_WantActive && State.P12_HasClearance) EnableP12();
|
||||
if (P3_WantActive && State.P3_HasClearance) EnableP3();
|
||||
if (P4_WantActive && State.P4_HasClearance) EnableP4();
|
||||
if (P5_WantActive && State.P5_HasClearance) EnableP5();
|
||||
if (P6_WantActive && State.P6_HasClearance) EnableP6();
|
||||
|
||||
if (!ManualControlMode) {
|
||||
if (State.MP1_State == MotorState.Forward && State.MW1_FillLevel >= FillState.Half && !State.MW1_Stirrer_IsActive) {
|
||||
@@ -86,12 +107,6 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
StopStirrerMW2();
|
||||
}
|
||||
}
|
||||
|
||||
if (State.P12_IsActive && !State.P12_HasClearance) DisableP12();
|
||||
if (State.P3_IsActive && !State.P3_HasClearance) DisableP3();
|
||||
if (State.P4_IsActive && !State.P4_HasClearance) DisableP4();
|
||||
if (State.P5_IsActive && !State.P5_HasClearance) DisableP5();
|
||||
if (State.P6_IsActive && !State.P6_HasClearance) DisableP6();
|
||||
}
|
||||
|
||||
public void OpenV(int n) => SetV(n, true);
|
||||
@@ -128,6 +143,7 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
public void StopRebler() {
|
||||
if (!ManualControlMode) StopTroughAuger();
|
||||
Actuators.Rebler = false;
|
||||
if (!ManualControlMode) StopAuger1();
|
||||
}
|
||||
|
||||
public void StartStirrerMW1() {
|
||||
@@ -154,6 +170,8 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
public void StopAuger1() {
|
||||
if (!ManualControlMode && State.Rebler_IsActive) throw new NoClearanceException("Rebler aktiv");
|
||||
Actuators.Auger1 = false;
|
||||
if (!ManualControlMode && !State.PressCrossAuger_IsActive)
|
||||
StopAuger2();
|
||||
}
|
||||
|
||||
public void StartAuger2() {
|
||||
@@ -165,6 +183,8 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
if (!ManualControlMode && State.PressCrossAuger_IsActive) throw new NoClearanceException("Presse-Querschnecke aktiv");
|
||||
if (!ManualControlMode && State.Auger1_IsActive) throw new NoClearanceException("Förderschnecke 1 aktiv");
|
||||
Actuators.Auger2 = false;
|
||||
if (!ManualControlMode)
|
||||
StopAuger3();
|
||||
}
|
||||
|
||||
public void StartAuger3() {
|
||||
@@ -185,83 +205,135 @@ namespace PamhagenSysCtrl.Helpers.Plc {
|
||||
}
|
||||
|
||||
public void StartMP1Forward() {
|
||||
if (!State.MP1_HasClearance) throw new NoClearanceException("MP1 hat keine Freigabe");
|
||||
if (!State.MP1_HasClearance) {
|
||||
if (!State.MP1_HasDryRunClearance || !State.MP1_WantsPathClearance)
|
||||
throw new NoClearanceException("MP1 hat keine Freigabe");
|
||||
MP1_WantActive = true;
|
||||
return;
|
||||
}
|
||||
MP1_WantActive = false;
|
||||
if (Actuators.MP1 == MotorState.Backward) throw new NoClearanceException("MP1 läuft bereits (zurück)");
|
||||
Actuators.MP1 = MotorState.Forward;
|
||||
if (State.MW1_FillLevel >= FillState.Half) StartStirrerMW1();
|
||||
}
|
||||
|
||||
public void StartMP1Backward() {
|
||||
MP1_WantActive = false;
|
||||
if (!State.MP1_HasClearance) throw new NoClearanceException("MP1 hat keine Freigabe");
|
||||
if (Actuators.MP1 == MotorState.Forward) throw new NoClearanceException("MP1 läuft bereits (vor)");
|
||||
Actuators.MP1 = MotorState.Backward;
|
||||
}
|
||||
|
||||
public void StopMP1() {
|
||||
MP1_WantActive = false;
|
||||
Actuators.MP1 = MotorState.Halt;
|
||||
if (!ManualControlMode) StopStirrerMW1();
|
||||
}
|
||||
|
||||
public void StartMP2Forward() {
|
||||
if (!State.MP2_HasClearance) throw new NoClearanceException("MP2 hat keine Freigabe");
|
||||
if (!State.MP2_HasClearance) {
|
||||
if (!State.MP2_HasDryRunClearance || !State.MP2_WantsPathClearance)
|
||||
throw new NoClearanceException("MP2 hat keine Freigabe");
|
||||
MP2_WantActive = true;
|
||||
return;
|
||||
}
|
||||
MP2_WantActive = false;
|
||||
if (Actuators.MP2 == MotorState.Backward) throw new NoClearanceException("MP2 läuft bereits (zurück)");
|
||||
Actuators.MP2 = MotorState.Forward;
|
||||
if (State.MW2_FillLevel >= FillState.Half) StartStirrerMW2();
|
||||
}
|
||||
|
||||
public void StartMP2Backward() {
|
||||
MP2_WantActive = false;
|
||||
if (!State.MP2_HasClearance) throw new NoClearanceException("MP2 hat keine Freigabe");
|
||||
if (Actuators.MP2 == MotorState.Forward) throw new NoClearanceException("MP2 läuft bereits (vor)");
|
||||
Actuators.MP2 = MotorState.Backward;
|
||||
}
|
||||
|
||||
public void StopMP2() {
|
||||
MP2_WantActive = false;
|
||||
Actuators.MP2 = MotorState.Halt;
|
||||
if (!ManualControlMode) StopStirrerMW1();
|
||||
}
|
||||
|
||||
public void EnableP12() {
|
||||
if (!State.P12_HasClearance) {
|
||||
if (!State.P12_HasDryRunClearance || !State.P12_WantsPathClearance)
|
||||
throw new NoClearanceException("P1/2 hat keine Freigabe");
|
||||
P12_WantActive = true;
|
||||
return;
|
||||
}
|
||||
P12_WantActive = false;
|
||||
if (!State.P12_HasClearance) throw new NoClearanceException("P1/2 hat keine Freigabe");
|
||||
Actuators.P12 = MotorState.Forward;
|
||||
}
|
||||
|
||||
public void DisableP12() {
|
||||
P12_WantActive = false;
|
||||
Actuators.P12 = MotorState.Halt;
|
||||
}
|
||||
|
||||
public void EnableP3() {
|
||||
if (!State.P3_HasClearance) throw new NoClearanceException("P3 hat keine Freigabe");
|
||||
if (!State.P3_HasClearance) {
|
||||
if (!State.P3_HasDryRunClearance || !State.P3_WantsPathClearance)
|
||||
throw new NoClearanceException("P3 hat keine Freigabe");
|
||||
P3_WantActive = true;
|
||||
return;
|
||||
}
|
||||
P3_WantActive = false;
|
||||
Actuators.P3 = MotorState.Forward;
|
||||
}
|
||||
|
||||
public void DisableP3() {
|
||||
P3_WantActive = false;
|
||||
Actuators.P3 = MotorState.Halt;
|
||||
}
|
||||
|
||||
public void EnableP4() {
|
||||
if (!State.P4_HasClearance) throw new NoClearanceException("P4 hat keine Freigabe");
|
||||
if (!State.P4_HasClearance) {
|
||||
if (!State.P4_HasDryRunClearance || !State.P4_WantsPathClearance)
|
||||
throw new NoClearanceException("P4 hat keine Freigabe");
|
||||
P4_WantActive = true;
|
||||
return;
|
||||
}
|
||||
P4_WantActive = false;
|
||||
Actuators.P4 = MotorState.Forward;
|
||||
}
|
||||
|
||||
public void DisableP4() {
|
||||
P4_WantActive = false;
|
||||
Actuators.P4 = MotorState.Halt;
|
||||
}
|
||||
|
||||
public void EnableP5() {
|
||||
if (!State.P5_HasClearance) throw new NoClearanceException("P5 hat keine Freigabe");
|
||||
if (!State.P5_HasClearance) {
|
||||
if (!State.P5_HasDryRunClearance || !State.P5_WantsPathClearance)
|
||||
throw new NoClearanceException("P5 hat keine Freigabe");
|
||||
P5_WantActive = true;
|
||||
return;
|
||||
}
|
||||
P5_WantActive = false;
|
||||
Actuators.P5 = MotorState.Forward;
|
||||
}
|
||||
|
||||
public void DisableP5() {
|
||||
P5_WantActive = false;
|
||||
Actuators.P5 = MotorState.Halt;
|
||||
}
|
||||
|
||||
public void EnableP6() {
|
||||
if (!State.P6_HasClearance) throw new NoClearanceException("P6 hat keine Freigabe");
|
||||
if (!State.P6_HasClearance) {
|
||||
if (!State.P6_HasDryRunClearance || !State.P6_WantsPathClearance)
|
||||
throw new NoClearanceException("P6 hat keine Freigabe");
|
||||
P6_WantActive = true;
|
||||
return;
|
||||
}
|
||||
P6_WantActive = false;
|
||||
Actuators.P6 = MotorState.Forward;
|
||||
}
|
||||
|
||||
public void DisableP6() {
|
||||
P6_WantActive = false;
|
||||
Actuators.P6 = MotorState.Halt;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user