Ejemplo n.º 1
0
        public static ControlSystemDataSample FromCloseSample(CloseLoopDataSample closeLoopSample)
        {
            var data = new ControlSystemDataSample();

            data.time             = closeLoopSample.time;
            data.mode             = ControlSystemMode.CloseLoop;
            data.input            = closeLoopSample.input;
            data.error            = closeLoopSample.error;
            data.controllerOutput = closeLoopSample.controllerOutput;
            data.systemOutput     = closeLoopSample.systemOutput;
            return(data);
        }
Ejemplo n.º 2
0
        public static ControlSystemDataSample FromOpenSample(BareSystemDataSample openLoopSample)
        {
            var data = new ControlSystemDataSample();

            data.time             = openLoopSample.time;
            data.mode             = ControlSystemMode.OpenLoop;
            data.input            = openLoopSample.input;
            data.error            = 0d;
            data.controllerOutput = 0d;
            data.systemOutput     = openLoopSample.output;
            return(data);
        }
        public void Initialize(double dt)
        {
            Data.Clear();
            ControlSystemDataSample dataSample;

            if (mode == ControlSystemMode.OpenLoop)
            {
                dataSample = ControlSystemDataSample.FromOpenSample(openScheme.Initialize(0d, dt));
                Data.Add(dataSample);
            }
            else
            {
                dataSample = ControlSystemDataSample.FromCloseSample(closeScheme.Initialize(0d, dt));
                Data.Add(dataSample);
            }
        }
        public void NextIteration(double input, double time, double dt)
        {
            ControlSystemDataSample dataSample;

            if (mode == ControlSystemMode.OpenLoop)
            {
                var openData = openScheme.NextIteration(input, time, dt);
                dataSample = ControlSystemDataSample.FromOpenSample(openData);
            }
            else
            {
                double previousSystemOutput = Data.Last().systemOutput;
                var    closeData            = closeScheme.NextIteration(input, previousSystemOutput, time, dt);
                dataSample = ControlSystemDataSample.FromCloseSample(closeData);
            }
            Data.Add(dataSample);
        }