コード例 #1
0
 public void OnEvent(BaseEvent evt)
 {
     using (var l = new Logger("ModelRunner::Listener"))
     {
         if (evt is OPCDirectReadEvent)
         {
             var odr = evt as OPCDirectReadEvent;
             if (odr.EventName == "HeatChangeEvent")
             {
                 var hce = new HeatChangeEvent();
                 hce.HeatNumber = /*++*/HeatNumber;
                 Program.m_pushGate.PushEvent(hce);
             }
             else if (odr.EventName == "visAdditionTotalEvent")
             {
                 var vate = new visAdditionTotalEvent();
                 vate.RB5TotalWeight = 5;
                 vate.RB6TotalWeight = 6;
                 vate.RB7TotalWeight = 7;
                 vate.RB8TotalWeight = 8;
                 vate.RB9TotalWeight = 9;
                 vate.RB10TotalWeight = 10;
                 vate.RB11TotalWeight = 11;
                 vate.RB12TotalWeight = 12;
                 Program.m_pushGate.PushEvent(vate);
             }
             else if (odr.EventName == "BoundNameMaterialsEvent")
             {
                 var bnme = new BoundNameMaterialsEvent();
                 bnme.Bunker5MaterialName = ReEncoder("ДОЛОМС");
                 bnme.Bunker6MaterialName = ReEncoder("ALKонц");
                 bnme.Bunker7MaterialName = ReEncoder("KOKS  ");
                 bnme.Bunker8MaterialName = ReEncoder("ИЗВЕСТ");
                 bnme.Bunker9MaterialName = ReEncoder("ИЗВЕСТ");
                 bnme.Bunker10MaterialName = ReEncoder("ФОМ   ");
                 bnme.Bunker11MaterialName = ReEncoder("ДОЛМИТ");
                 bnme.Bunker12MaterialName = ReEncoder("ДОЛОМС");
                 Program.m_pushGate.PushEvent(bnme);
             }
         }
     }
 }
コード例 #2
0
        private static void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            m_vPathIsOutput = !VPathDataIsEqual(HDataList[m_position].Bunkers, m_vPathDataLast);
            if (m_vPathIsOutput) {
                Console.WriteLine(
                    "{17:0000}: {0:00000} > {1:000} | {2:0000.0} | {3:00.0} | {4:00.0} | {5:00.0} | {6:00.0} | {7:00.0} | {8:00.0} " +
                    "| {9:0000} | {10:0000} | {11:0000} | {12:0000} | {13:0000} | {14:0000} | {15:0000} | {16:0000}",
                    m_totalO2,
                    HDataList[m_position].HeightLance,
                    HDataList[m_position].RateO2,
                    HDataList[m_position].H2,
                    HDataList[m_position].O2,
                    HDataList[m_position].CO,
                    HDataList[m_position].CO2,
                    HDataList[m_position].N2,
                    HDataList[m_position].Ar,
                    HDataList[m_position].Bunkers.RB5,
                    HDataList[m_position].Bunkers.RB6,
                    HDataList[m_position].Bunkers.RB7,
                    HDataList[m_position].Bunkers.RB8,
                    HDataList[m_position].Bunkers.RB9,
                    HDataList[m_position].Bunkers.RB10,
                    HDataList[m_position].Bunkers.RB11,
                    HDataList[m_position].Bunkers.RB12,
                    ++m_step
                    );
                m_vPathDataLast = HDataList[m_position].Bunkers;
            }
            else {
                Console.WriteLine(
                    "{9:0000}: {0:00000} > {1:000} | {2:0000.0} | {3:00.0} | {4:00.0} | {5:00.0} | {6:00.0} | {7:00.0} | {8:00.0}",
                    m_totalO2,
                    HDataList[m_position].HeightLance,
                    HDataList[m_position].RateO2,
                    HDataList[m_position].H2,
                    HDataList[m_position].O2,
                    HDataList[m_position].CO,
                    HDataList[m_position].CO2,
                    HDataList[m_position].N2,
                    HDataList[m_position].Ar,
                    ++m_step
                    );
            }
            var le = new LanceEvent();
            le.LanceHeight = HDataList[m_position].HeightLance;
            le.O2Flow = HDataList[m_position].RateO2;
            le.O2TotalVol = (int) m_totalO2;

            var offGA = new OffGasAnalysisEvent();
            offGA.H2 = HDataList[m_position].H2;
            offGA.O2 = HDataList[m_position].O2;
            offGA.CO = HDataList[m_position].CO;
            offGA.CO2 = HDataList[m_position].CO2;
            offGA.N2 = HDataList[m_position].N2;
            offGA.Ar = HDataList[m_position].Ar;

            var fex = new FlexHelper("UDP.OffGasAnalysisEvent");
            fex.AddArg("H2", HDataList[m_position].H2);
            fex.AddArg("O2", HDataList[m_position].O2);
            fex.AddArg("CO", HDataList[m_position].CO);
            fex.AddArg("CO2", HDataList[m_position].CO2);
            fex.AddArg("N2", HDataList[m_position].N2);
            fex.AddArg("Ar", HDataList[m_position].Ar);
            fex.Fire(MainGate);

            var offG = new OffGasEvent();
            offG.OffGasFlow = HDataList[m_position].VOffGas;
            offG.OffGasTemp = (int) Math.Round(HDataList[m_position].TOffGas);

            var bE = new BlowingEvent();
            bE.O2TotalVol = (int) m_totalO2;
            bE.BlowingFlag = 1;

            var vate = new visAdditionTotalEvent();
            vate.RB5TotalWeight = HDataList[m_position].Bunkers.RB5;
            vate.RB6TotalWeight = HDataList[m_position].Bunkers.RB6;
            vate.RB7TotalWeight = HDataList[m_position].Bunkers.RB7;
            vate.RB8TotalWeight = HDataList[m_position].Bunkers.RB8;
            vate.RB9TotalWeight = HDataList[m_position].Bunkers.RB9;
            vate.RB10TotalWeight = HDataList[m_position].Bunkers.RB10;
            vate.RB11TotalWeight = HDataList[m_position].Bunkers.RB11;
            vate.RB12TotalWeight = HDataList[m_position].Bunkers.RB12;

            if ((HDataList[m_position].SublanceC > 0) && !m_sublanceCIsPushed) {
                Int64 reminder = 0;
                Int64 res = Math.DivRem(m_heatNumber, 10000, out reminder);
                Int64 longHN = res*100000 + reminder;
                MainGate.PushEvent(new visSpectrluksEvent() {C = HDataList[m_position].SublanceC, HeatNumber = longHN});
                Console.WriteLine("specroluks push Heat = {0} ", longHN);
                MainGate.PushEvent(new SublanceCEvent() {C = HDataList[m_position].SublanceC});
                m_sublanceCIsPushed = true;
                Console.WriteLine("Carbone pushed C = {0}, heatNumber = {1}", HDataList[m_position].SublanceC, longHN);
            }

            var doge = new DecompressionOffGasEvent();
            m_decompressionOffGas = HDataList[m_position].DecompressionOffGas == Int32.MinValue
                                        ? m_decompressionOffGas
                                        : HDataList[m_position].DecompressionOffGas;
            doge.Decompression = m_decompressionOffGas;

            MainGate.PushEvent(le);
            MainGate.PushEvent(offGA);
            MainGate.PushEvent(offG);
            MainGate.PushEvent(bE);
            MainGate.PushEvent(doge);

            m_totalO2 += HDataList[m_position].RateO2*0.01666666666666666666666666666667;

            if (m_vPathIsOutput) MainGate.PushEvent(vate);

            //Console.WriteLine("m_position -- {0}; HDataList.Count -- {1}", m_position, HDataList.Count);
            if (m_position < HDataList.Count - 1)
                m_position++;
            else {
                Console.WriteLine("Exit 0");
                System.Environment.Exit(0);
                m_timer.Enabled = false;
            }
        }
コード例 #3
0
        private void React(object data)
        {
            var e = data as BaseEvent;
            if (e != null)
            {
                Type eventType = e.GetType();
                Console.WriteLine("Incoming event. Event type is " + eventType);
                if (eventType == typeof(OPCDirectReadEvent))
                {
                    var opcDirectReadEvent = e as OPCDirectReadEvent;
                    if (opcDirectReadEvent != null)
                        Console.WriteLine("OPCDirectReadEvent asking for " + opcDirectReadEvent.EventName);
                    if (opcDirectReadEvent != null &&
                        (opcDirectReadEvent).EventName == typeof(BoundNameMaterialsEvent).Name)
                    {
                        var reaction = new BoundNameMaterialsEvent
                                           {
                                               Bunker5MaterialName = "ДОЛОМС",
                                               Bunker6MaterialName = "ALКонц",
                                               Bunker7MaterialName = "KOKS  ",
                                               Bunker8MaterialName = "ИЗВЕСТ",
                                               Bunker9MaterialName = "ИЗВЕСТ",
                                               Bunker10MaterialName = "ДОЛОМС",
                                               Bunker11MaterialName = "ФОМ   ",
                                               Bunker12MaterialName = "МАХГ  "
                                           };
                        _gate.PushEvent(reaction);
                        //HeatChangeEvent HCE = new HeatChangeEvent();
                        //HCE.HeatNumber = 23989;
                        //_gate.PushEvent(HCE);
                        //Thread.Sleep(3000);
                        Console.WriteLine("BoundNameMaterialsEvent send");
                        var realO = new BlowingEvent() { O2TotalVol = 0 };
                        _gate.PushEvent(realO);
                        for (int i = 1; i < 11; i++)
                        {
                            var additions = new visAdditionTotalEvent
                            {
                                RB5TotalWeight = 100 * i,
                                RB6TotalWeight = 100 * i,
                                RB7TotalWeight = 100 * i,
                                RB8TotalWeight = 100 * i,
                                RB9TotalWeight = 100 * i,
                                RB10TotalWeight = 100 * i,
                                RB11TotalWeight = 100 * i,
                                RB12TotalWeight = 100 * i
                            };
                            _gate.PushEvent(additions);
                            Thread.Sleep(5000);
                        }
                        for (int i = 0; i < 10; i++)
                        {
                            var realO2 = new BlowingEvent() { O2TotalVol = 1 };
                            _gate.PushEvent(realO2);
                            Thread.Sleep(1000);
                        }

                        var realzeroO2 = new BlowingEvent() { O2TotalVol = 0 };
                        _gate.PushEvent(realzeroO2);
                    }
                    if (opcDirectReadEvent != null &&
                        (opcDirectReadEvent).EventName == typeof(ModeVerticalPathEvent).Name)
                    {
                        var reaction = new ModeVerticalPathEvent
                        {
                            VerticalPathMode = 1
                        };
                        _gate.PushEvent(reaction);
                        Console.WriteLine("ModeVerticalPathEvent send");
                    }

                    if (opcDirectReadEvent != null &&
                        (opcDirectReadEvent).EventName == typeof(ModeLanceEvent).Name)
                    {
                        var reaction = new ModeLanceEvent
                        {
                            LanceMode = 3,
                            O2FlowMode = 3
                        };
                        _gate.PushEvent(reaction);
                        Console.WriteLine("ModeLanceEvent send");
                    }

                }
                if (eventType == typeof(SteelMakingPatternEvent))
                {
                    if (_processingHeat)
                    {
                        return;
                    }
                    _processingHeat = true;
                    var steelMakingPatternEvent = e as SteelMakingPatternEvent;
                    if (steelMakingPatternEvent != null)
                    {
                        int stepsCount = steelMakingPatternEvent.steps.Count;
                        for (int i = 0; i < stepsCount; i++)
                        {
                            var reaction = new HeatSchemaStepEvent
                                               {
                                                   Step = i
                                               };
                            var realO2 = new BlowingEvent() { O2TotalVol = 25000 * i / stepsCount };
                            var realLance = new LanceEvent() { LanceHeight = 700 - (700 * i / stepsCount) };
                            _gate.PushEvent(reaction);
                            Console.WriteLine("HeatSchemaStepEvent send");
                            InstantLogger.log(DateTime.Now.ToString() + " Новый шаг, HeatSchemaStepEvent send\r\n");
                            _gate.PushEvent(realO2);
                            Console.WriteLine("BlowingEvent send");
                            _gate.PushEvent(realLance);
                            Console.WriteLine("LanceEvent send");

                            Thread.Sleep(5000);
                        }
                    }
                    //var fex = new FlexHelper("CorrectionCT.RecommendBalanceBlow");
                    //fex.AddArg("CorrectionOxygenT", 18700);
                    //fex.AddArg("CorrectionOxygenC", 18710);
                    //fex.AddArg("CurrentC", 0.432);
                    //fex.AddArg("TargetC", 0.432);
                    //fex.AddArg("CurrentT", 1670);
                    //fex.AddArg("TargetT", 1680);
                    //fex.Fire(_gate);

                    var lastReaction = new HeatSchemaStepEvent
                                           {
                                               Step = -1
                                           };
                    _gate.PushEvent(lastReaction);
                    Console.WriteLine("HeatSchemaStepEvent with stop signal send");
                    _processingHeat = false;
                }
            }
        }