public SimulationStatus InicializeModuleByStream(System.IO.Stream XMLInputstream)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(TS_Descriptor));
            try
            {
                using (XmlReader reader = XmlReader.Create(XMLInputstream))
                {
                    InputDescriptor = (TS_Descriptor)serializer.Deserialize(reader);
                }
            }
            catch (Exception e)
            {
                return SimulationStatus.Corrupted;
            }

            try
            {
                SimulatorViewModel.SimulatorModel = new TS_SimulatorModel();
                SimulatorViewModel.SimulatorModel.CreateSimulatorDomain(InputDescriptor);
                SimulatorViewModel.InputDescriptor = InputDescriptor;
            }
            catch (Exception e)
            {
                return SimulationStatus.Corrupted;
            }


            return SimulationStatus.Runnable;
        }
Пример #2
0
        public Metrics(TS_SimulatorModel simulatorModel, TS_Descriptor descriptor)
        {
            this.simulatorModel = simulatorModel;

            avarageOverheadTimeInOneThousandthMs = (double)descriptor.AvarageOverheadTime/1000.0;
            countOfMillisecondsWhereProcessWasRunning = countOfMillisecondsWhereProcessWasNotRunning = 0;
            countOfContextSwitchings = CountOfTaskSchedulings = 0;
        }
        public void CreateSimulatorDomain(TS_Descriptor descriptor)
        {
            // erőforrások létrehozása
            foreach (ResourceDescriptor resourceDescriptor in descriptor.Resources)
            {
                Resource resource = new Resource(resourceDescriptor, this);
                Resources.Add(resource);
            }
            // processzek létrehozása és használt erőforrásainak ellenőrzése
            foreach (ProcessDescriptor processDescriptor in descriptor.Processes)
            {
                Process process = new Process(this, MyCloner.DeepClone<ProcessDescriptor>(processDescriptor), Resources);
                InitialProcessList.Add(process);
            }

            Metrics = new Metrics(this, descriptor);

            LoadSchedulerAlgorithm(descriptor.SchedulerAlgorithm);

            Process runningProcess = ArrivedProcesses.FirstOrDefault(x => x.ProcessStatus == ProcessStatusEnum.Running);
            GanntHistory.AddToHistory(ActualStep, runningProcess, queue);

            InitiateProcesses();
            RunSchedulerIfNecassary();
        }