Esempio n. 1
0
        static void Main(string[] args)
        {
            //初始化配置
            var    setting = new Setting();
            Logger logger  = new Logger();

            //初始化db
            new StorageService(setting);

            //开始恢复数据
            var rt = new RestoreTrack(setting);

            rt.Start();

            //开启服务
            ISystem systemL = PipelineSystem.CreatePipelineSystemV1(logger);

            systemL.OpenNetwork(new PeerOption());
            systemL.OpenListen(new IPEndPoint(IPAddress.Parse(setting.BindAddress), setting.Port));
            systemL.RegistModule("server", new ServerModule());


            systemL.Start();
            Console.ReadKey();
        }
        public void MainAlgo()
        {
            PipelineSystem p = new PipelineSystem();

            GetBasePlots(p);

            var tu3Interval = Accord.Math.Vector.EnumerableRange(12 * 24, 19 * 24).ToArray();
            var interval    = Accord.Math.Vector.EnumerableRange(0, p.Period).ToArray();

            PipelineSystem.PumpsParameters targets = new PipelineSystem.PumpsParameters(new List <string> {
                "ТУ0", "ТУ1", "ТУ2", "ТУ3", "Труба откачка У НПЗ", "Труба подкачка ГНПС 2"
            });
            targets.SetUniformity("ТУ0", true);
            targets.SetUniformity("Труба откачка У НПЗ", true);
            targets.SetUniformity("Труба подкачка ГНПС 2", true);
            targets.AddBatch("ТУ0", new double[] { 1584.27 }, interval);
            targets.AddBatch("ТУ1", new double[] { 1586.6, 221.6, 15, 1586.6 + 221.6 + 14 }, interval);
            targets.AddBatch("ТУ2", new double[] { 1650.0 }, interval);
            targets.AddBatch("ТУ3", new double[] { 350, 15.0, 350 - 15.0 }, tu3Interval);
            targets.AddBatch("ТУ3", new double[] { 1640 - 350, 0, 1640 - 350 }, interval.Except(tu3Interval).ToArray());
            targets.AddBatch("Труба откачка У НПЗ", new double[] { 269.0 }, interval);
            targets.AddBatch("Труба подкачка ГНПС 2", new double[] { 162.847 }, interval);

            var reservoir2Pumps = Algorithms.AlgorithmHelper.CreateListOfElements(p.Period, (-targets.batches["Труба откачка У НПЗ"][0].Item1[0] + targets.batches["Труба подкачка ГНПС 2"][0].Item1[0]) / p.Period).ToArray();

            var tankersStartVolume = new double[] { 30, 30.6, 17.7 };

            DateTime time = DateTime.Now;
            Dictionary <string, List <double[]> > tuSchedules = p.Algorithm(targets, tankersStartVolume, (str) => SetWinTitle(str));

            //MessageBox.Show((DateTime.Now - time).TotalSeconds.ToString());

            if (tuSchedules == null)
            {
                return;
            }

            double[] zeros         = new double[p.Period];
            double[] inputSchedule = Algorithms.AlgorithmHelper.CreateListOfElements(p.Period, targets.batches["ТУ0"][0].Item1[0] / p.Period).ToArray();

            SetPlots(
                inputSchedule,
                tuSchedules["ТУ1"].Select(x => x[0]).ToArray(),
                tuSchedules["ТУ1"].Select(x => x[1]).ToArray(),
                tuSchedules["ТУ1"].Select(x => x[2]).ToArray(),
                tuSchedules["ТУ1"].Select(x => x[3]).ToArray(),
                tuSchedules["ТУ2"].Select(x => x[0]).ToArray(),
                tuSchedules["ТУ3"].Select(x => x[0]).ToArray(),
                tuSchedules["ТУ3"].Select(x => x[1]).ToArray(),
                tuSchedules["ТУ3"].Select(x => x[2]).ToArray(),
                tankersStartVolume[0],
                tankersStartVolume[1],
                tankersStartVolume[2],
                zeros,
                reservoir2Pumps,
                zeros);
        }
Esempio n. 3
0
        public static SimpleServerDB Open(Setting setting)
        {
            var logger  = new Logger();
            var systemC = PipelineSystem.CreatePipelineSystemV1(logger);
            var db      = new SimpleServerDB(setting);

            systemC.RegistModule("client", db);
            systemC.OpenNetwork(new PeerOption());
            systemC.Start();
            db.actor = systemC.GetPipeline(null, "this/client");
            return(db);
        }
        private void GetBasePlots(PipelineSystem p)
        {
            LineSeries
                tu1InMaxFlows = new LineSeries()
            {
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            },
                tu1Pump1MaxFlows = new LineSeries()
            {
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            },
                tu1Pump2MaxFlows = new LineSeries()
            {
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            },
                tu1OutMaxFlows = new LineSeries()
            {
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            },
                tu2MaxFlows = new LineSeries()
            {
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            },
                tu3InMaxFlows = new LineSeries()
            {
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            },
                tu3PumpMaxFlows = new LineSeries()
            {
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            },
                tu3OutMaxFlows = new LineSeries()
            {
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            },
                zeros = new LineSeries()
            {
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            };

            Func <LineSeries, LineSeries> CopySerie = (source) =>
            {
                return(new LineSeries()
                {
                    ItemsSource = source.ItemsSource as List <DataPoint>,
                    StrokeThickness = source.StrokeThickness,
                    Color = source.Color,
                    LineStyle = source.LineStyle
                });
            };

            List <double[]>
            tu1MaxFlowsList     = p.GetTechnologicalSectionInputOutputMax("ТУ1"),
                tu2MaxFlowsList = p.GetTechnologicalSectionInputOutputMax("ТУ2"),
                tu3MaxFlowsList = p.GetTechnologicalSectionInputOutputMax("ТУ3");

            zeros.ItemsSource = tu1MaxFlowsList.Aggregate(new List <DataPoint>(), (total, current) =>
            {
                int i = total.Count() / 2;
                total.Add(new DataPoint(i + 0.001, 0));
                total.Add(new DataPoint(i + 1, 0));
                return(total);
            });

            InSchedule                = new PlotModel();
            TU1InputSchedule          = new PlotModel();
            TU1Pump1Schedule          = new PlotModel();
            TU1Pump2Schedule          = new PlotModel();
            TU1OutputSchedule         = new PlotModel();
            tu1InMaxFlows.ItemsSource = tu1MaxFlowsList.Aggregate(new List <DataPoint>(), (total, current) =>
            {
                int i = total.Count() / 2;
                total.Add(new DataPoint(i + 0.001, current[0]));
                total.Add(new DataPoint(i + 1, current[0]));
                return(total);
            });
            tu1Pump1MaxFlows.ItemsSource = tu1MaxFlowsList.Aggregate(new List <DataPoint>(), (total, current) =>
            {
                int i = total.Count() / 2;
                total.Add(new DataPoint(i + 0.001, current[1]));
                total.Add(new DataPoint(i + 1, current[1]));
                return(total);
            });
            tu1Pump2MaxFlows.ItemsSource = tu1MaxFlowsList.Aggregate(new List <DataPoint>(), (total, current) =>
            {
                int i = total.Count() / 2;
                total.Add(new DataPoint(i + 0.001, current[2]));
                total.Add(new DataPoint(i + 1, current[2]));
                return(total);
            });
            tu1OutMaxFlows.ItemsSource = tu1MaxFlowsList.Aggregate(new List <DataPoint>(), (total, current) =>
            {
                int i = total.Count() / 2;
                total.Add(new DataPoint(i + 0.001, current[3]));
                total.Add(new DataPoint(i + 1, current[3]));
                return(total);
            });
            TU1InputSchedule.Series.Add(tu1InMaxFlows);
            TU1Pump1Schedule.Series.Add(tu1Pump1MaxFlows);
            TU1Pump2Schedule.Series.Add(tu1Pump2MaxFlows);
            TU1OutputSchedule.Series.Add(tu1OutMaxFlows);
            TU1InputSchedule.Series.Add(CopySerie(zeros));
            TU1Pump1Schedule.Series.Add(CopySerie(zeros));
            TU1Pump2Schedule.Series.Add(CopySerie(zeros));
            TU1OutputSchedule.Series.Add(CopySerie(zeros));

            TU2Schedule             = new PlotModel();
            tu2MaxFlows.ItemsSource = tu2MaxFlowsList.Aggregate(new List <DataPoint>(), (total, current) =>
            {
                int i = total.Count() / 2;
                total.Add(new DataPoint(i + 0.001, current[0]));
                total.Add(new DataPoint(i + 1, current[0]));
                return(total);
            });
            TU2Schedule.Series.Add(tu2MaxFlows);
            TU2Schedule.Series.Add(CopySerie(zeros));


            TU3InputSchedule          = new PlotModel();
            TU3PumpSchedule           = new PlotModel();
            TU3OutputSchedule         = new PlotModel();
            tu3InMaxFlows.ItemsSource = tu3MaxFlowsList.Aggregate(new List <DataPoint>(), (total, current) =>
            {
                int i = total.Count() / 2;
                total.Add(new DataPoint(i + 0.001, current[0]));
                total.Add(new DataPoint(i + 1, current[0]));
                return(total);
            });
            tu3PumpMaxFlows.ItemsSource = tu3MaxFlowsList.Aggregate(new List <DataPoint>(), (total, current) =>
            {
                int i = total.Count() / 2;
                total.Add(new DataPoint(i + 0.001, current[1]));
                total.Add(new DataPoint(i + 1, current[1]));
                return(total);
            });
            tu3OutMaxFlows.ItemsSource = tu3MaxFlowsList.Aggregate(new List <DataPoint>(), (total, current) =>
            {
                int i = total.Count() / 2;
                total.Add(new DataPoint(i + 0.001, current[2]));
                total.Add(new DataPoint(i + 1, current[2]));
                return(total);
            });
            TU3InputSchedule.Series.Add(tu3InMaxFlows);
            TU3PumpSchedule.Series.Add(tu3PumpMaxFlows);
            TU3OutputSchedule.Series.Add(tu3OutMaxFlows);
            TU3InputSchedule.Series.Add(CopySerie(zeros));
            TU3PumpSchedule.Series.Add(CopySerie(zeros));
            TU3OutputSchedule.Series.Add(CopySerie(zeros));

            Reservoir tank1 = (p.GetPoint("РП1") as Reservoir);

            Tank1 = new PlotModel();
            Tank1.Series.Add(new LineSeries()
            {
                ItemsSource = new List <DataPoint>()
                {
                    new DataPoint(0, tank1.Volume),
                    new DataPoint(p.Period, tank1.Volume)
                },
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            });
            Tank1.Series.Add(new LineSeries()
            {
                ItemsSource = new List <DataPoint>()
                {
                    new DataPoint(0, 0),
                    new DataPoint(p.Period, 0)
                },
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            });
            Reservoir tank2 = (p.GetPoint("РП2") as Reservoir);

            Tank2 = new PlotModel();
            Tank2.Series.Add(new LineSeries()
            {
                ItemsSource = new List <DataPoint>()
                {
                    new DataPoint(0, tank2.Volume),
                    new DataPoint(p.Period, tank2.Volume)
                },
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            });
            Tank2.Series.Add(new LineSeries()
            {
                ItemsSource = new List <DataPoint>()
                {
                    new DataPoint(0, 0),
                    new DataPoint(p.Period, 0)
                },
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            });
            Reservoir tank3 = (p.GetPoint("РП3") as Reservoir);

            Tank3 = new PlotModel();
            Tank3.Series.Add(new LineSeries()
            {
                ItemsSource = new List <DataPoint>()
                {
                    new DataPoint(0, tank3.Volume),
                    new DataPoint(p.Period, tank3.Volume)
                },
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            });
            Tank3.Series.Add(new LineSeries()
            {
                ItemsSource = new List <DataPoint>()
                {
                    new DataPoint(0, 0),
                    new DataPoint(p.Period, 0)
                },
                Color           = OxyColors.Red,
                StrokeThickness = 2,
                LineStyle       = LineStyle.LongDash
            });

            UpdateDatacontext();
        }