/// <summary> /// Creates a new SfcTransition with the given transitionPatchId /// </summary> private static SfcTransition CreateTransition(int transitionPatchId, ProgrammableLogicController pu) { string transitionText = pu.SfcProgramData.SfcEntity.Lookup(transitionPatchId).TransitionText; BooleanExpression expression = TransitionMaster.InterpretTransitionText(transitionText, pu); SfcTransition transition = new SfcTransition(expression, transitionPatchId); return(transition); }
public EngineTest() { var plcCommunication = PLCFactory.GetPLCS71500("127.0.0.1"); _plc = new ProgrammableLogicController(plcCommunication); _plc.MapBitVariable("StartButton", 2, 0, 0) .MapBitVariable("Engine", 4, 0, 0); }
public StationOneBottleMachineTest() { var plcCommunication = PLCFactory.GetPLCS71500("127.0.0.1"); _plc = new ProgrammableLogicController(plcCommunication); _plc.MapBitVariable("Sensor1", 2, 0, 1) .MapBitVariable("Sensor2", 2, 0, 2) .MapBitVariable("Engine1", 4, 0, 1); }
static void Main(string[] args) { using (var plc = new ProgrammableLogicController(new PLCS71500("127.0.0.1"))) { plc.MapBitVariable("BotaoLigaMotor", 2, 0, 0) .MapBitVariable("Motor", 2, 0, 1) .SetValueByTag("BotaoLigaMotor", false) .GetValueByTag("Motor"); } }
public SfcTestHelper(List <PatchEntity> stepEntities, Test testContext) { SfcEntity sfcEntity = new SfcEntity(); foreach (PatchEntity step in stepEntities) { sfcEntity.AddPatch(step); } SimulationPageMock simulationPageMock = new SimulationPageMock(); _controller = new ProgrammableLogicController(simulationPageMock, sfcEntity); _controller.Startup(); testContext.Assert.IsTrue(_controller.IsLogicValid(), "ProgrammableLogicController->IsLogicValid"); }
/// <summary> /// Looks for all transitions connected to this step /// </summary> public static List <SfcTransition> CollectTransitionSources(SfcStep source, ProgrammableLogicController pu) { List <SfcTransition> alternativeBranches = CollectUpperAlternativeBranches(source, source.Id, pu); List <SfcTransition> SimultaneousMerge = CollectUpperSimultaneousMerge(source.Id, pu); if (alternativeBranches.Count > 1) { return(alternativeBranches); } else if (SimultaneousMerge != null) { return(SimultaneousMerge); } else if (alternativeBranches.Count > 0) { return(alternativeBranches); } return(new List <SfcTransition>() { }); }
/// <summary> /// Collects all Simultaneous branches to merge from this step. /// null if there is none. /// </summary> private static List <SfcTransition> CollectUpperSimultaneousMerge(int sourceId, ProgrammableLogicController pu) { List <int> collected = Collector.CollectHorizontal(sourceId, pu.SfcProgramData, BranchType.Double, true); if (collected.Count <= 1) { PatchEntity currentPatch = pu.SfcProgramData.SfcEntity.Lookup(sourceId); int lowerId = sourceId + 1; PatchEntity lowerPatch = pu.SfcProgramData.SfcEntity.Lookup(lowerId); if (!currentPatch.ContainsTransition() && lowerPatch != null && lowerPatch.SfcStepType == StepType.Pass) { return(CollectUpperSimultaneousMerge(lowerId, pu)); } return(null); } PatchEntity transitionPatch = FindSimultaneousTransition(collected, pu.SfcProgramData); List <SfcStep> connectedSteps = CollectConnectedSteps(collected, pu.SfcProgramData); SfcTransition transition = CreateTransition(transitionPatch.Key, pu); transition.DependingSteps = connectedSteps; return(new List <SfcTransition> { transition }); }
/// <summary> /// Collects all alternative branches from this step. /// If it returns only one transition is not an alternative branch but a normal transition. /// </summary> private static List <SfcTransition> CollectUpperAlternativeBranches(SfcStep source, int patchId, ProgrammableLogicController pu) { List <SfcTransition> transitions = new List <SfcTransition>(); List <int> collected = Collector.CollectHorizontal(patchId, pu.SfcProgramData, BranchType.Single, true); foreach (int step in collected) { if (pu.SfcProgramData.SfcEntity.Lookup(step).ContainsTransition()) { SfcTransition transition = CreateTransition(step, pu); transition.DependingSteps.Add(source); transitions.Add(transition); } else { int lowerStepId = step + 1; PatchEntity lowerEntry = pu.SfcProgramData.SfcEntity.Lookup(lowerStepId); if (lowerEntry != null && lowerEntry.SfcStepType == StepType.Pass) { transitions.AddRange(CollectUpperAlternativeBranches(source, lowerStepId, pu)); } } } return(transitions); }
public Master(SfcEntity sfcEntity, SimulationPage simulationPage) { SimulationPage = simulationPage; Plc = new ProgrammableLogicController(simulationPage, sfcEntity); Plc.Startup(); }