Пример #1
0
 public ProgrammableLogicController(SimulationPage simulationPage, SfcEntity sfcEntity)
 {
     _simulationPage  = simulationPage;
     _inputRegisters  = new ResettingStateTable(_simulationPage.SimulationOutput);
     _outputRegisters = new ResettingStateTable(_simulationPage.SimulationInput);
     SfcProgramData   = new SfcProgramData(sfcEntity);
     SfcProgram       = new SfcProgram(this);
 }
        private static IDiagramSimulationMaster LoadSfc(ILessonEntity openedLesson, SimulationPage simulationPage)
        {
            SfcEntity sfcEntity = SfcEntity.TryLoadFromFile(openedLesson.TemporaryDiagramFilePath);

            if (sfcEntity == null)
            {
                return(null);
            }
            return(new Master(sfcEntity, simulationPage));
        }
        /// <summary>
        /// Loads the plant node and links the I/O Table
        /// </summary>
        private ProcessingData InitialisePlant(ILessonEntity openedLesson)
        {
            _lessonView = GetNode <LessonView>("HscRelative/LessonView");
            _lessonView.LoadAndShowInfo(openedLesson);
            _loadedSimulationNode = _lessonView.PlantView.LoadedSimulationNode;
            ProcessingData data = new ProcessingData
            {
                InputRegisters  = new StateTable(_loadedSimulationNode.SimulationOutput),
                OutputRegisters = new StateTable(_loadedSimulationNode.SimulationInput)
            };

            return(data);
        }
 /// <summary>
 /// Exchanges the current simulation view to the given simulation.
 /// </summary>
 public void UpdateLessonEntity(ILessonEntity lessonEntity)
 {
     if (LoadedSimulationNode != null && IsInstanceValid(LoadedSimulationNode))
     {
         LoadedSimulationNode.QueueFree();
         LoadedSimulationNode = null;
     }
     if (!string.IsNullOrEmpty(lessonEntity.SimulationPath))
     {
         LoadedSimulationNode = (SimulationPage)((PackedScene)GD.Load(lessonEntity.SimulationPath)).Instance();
         GetNode(ViewportPath).AddChild(LoadedSimulationNode);
     }
 }
        /// <summary>
        /// Loads the TemporaryDiagramFilePath and creates a simulation master from it.
        /// </summary>
        /// <param name="openedLesson">The opened lesson we want to create a simulation master from.</param>
        /// <param name="simulationPage">the target simulation page we want to control.</param>
        /// <returns>the simulation master if the data could be loaded. Null otherwise.</returns>
        public static IDiagramSimulationMaster LoadTemp(ILessonEntity openedLesson, SimulationPage simulationPage)
        {
            string tempFile = openedLesson.TemporaryDiagramFilePath;

            if (string.IsNullOrEmpty(tempFile))
            {
                return(null);
            }
            if (tempFile.EndsWith(SFC))
            {
                return(LoadSfc(openedLesson, simulationPage));
            }
            return(null);
        }
Пример #6
0
 private void OnSimulationClick()
 {
     ChangeMenuButtonCheckedStatus(simulation: true);
     _Content = new SimulationPage();
 }
 /// <summary>
 /// Is called to calculate the next steps of the simulation with the given time in ms.
 /// We update first the simulation and then the controller.
 /// </summary>
 public void UpdateSimulation(int deltaTimeMs)
 {
     SimulationPage.UpdateModel(deltaTimeMs);
     Plc.Update(deltaTimeMs);
 }
 public Master(SfcEntity sfcEntity, SimulationPage simulationPage)
 {
     SimulationPage = simulationPage;
     Plc            = new ProgrammableLogicController(simulationPage, sfcEntity);
     Plc.Startup();
 }