Ejemplo n.º 1
0
        public static void EventsHandler(BaseEvent evt, Logger l)
        {
            if (evt is BlowingEvent) {
                var be = evt as BlowingEvent;
                Keeper.SetBlowingStatus(be.BlowingFlag == 1);
            } else

            if (evt is FlexEvent) {
                var fxe = evt as FlexEvent;
                if (fxe.Operation.StartsWith("UDP.OffGasAnalysisEvent")) {
                    var fxh = new FlexHelper(fxe);

                    var co = fxh.GetDbl("CO");
                    var co2 = fxh.GetDbl("CO2");

                    SetGasAnalysis(co, co2);
                } else

                if (fxe.Operation.StartsWith("OPC.WatchdogsFromL1"))
                {
                    var fxh = new FlexHelper(fxe);
                    var wd1 = fxh.GetInt("WDPLC1");
                    var wd2 = fxh.GetInt("WDPLC2");
                    var wd3 = fxh.GetInt("WDPLC3");
                    var wd01 = fxh.GetInt("WDPLC01");

                    SetWatchdogReceive(wd1, wd2, wd3, wd01);
                }
            }
        }
 public static void FireCarbon(double c, int periodlNumber)
 {
     var fex = new FlexHelper("CarbonSwitcher.Result");
     fex.AddArg("C", c);
     fex.AddArg("PeriodlNumber", periodlNumber);
     fex.Fire(Program.MainGate);
 }
 public static void ReqCalc(Client CoreGate, InData modelInData)
 {
     var fex = new FlexHelper("UI.Calc");
     fex.AddArg("SteelType", modelInData.SteelType);
     fex.AddArg("MHi", modelInData.MHi);
     fex.AddArg("MSc", modelInData.MSc);
     fex.AddArg("SiHi", modelInData.SiHi);
     fex.AddArg("THi", modelInData.THi);
     fex.AddArg("IsProcessingUVS", modelInData.IsProcessingUVS);
     fex.Fire(CoreGate);
 }
 public static void FireTimerHandler(object source, ElapsedEventArgs e)
 {
     var fex = new FlexHelper("CoreMeteringEvent");
     fex.AddArg("SendTime", DateTime.Now);
     FlexList.Add(fex.evt);
     fex.Fire(MainGate);
     var last = ResultList.Count - 1;
     ResultList[last].FieredEvents++;
     //Console.Write(".");
     //SaveMatrix(ArchPath);
 }
 public void Init()
 {
     mixerTimer.Interval = 1000;
     mixerTimer.AutoReset = false;
     mixerTimer.Enabled = true;
     mixerTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
     // список доступных миксеров
     var fex = new FlexHelper("OPC.Read-OPC.HM-Chemistry.Event.");
     fex.Fire(Program.MainGate);
     // текущий номер плавки
     Program.MainGate.PushEvent(new OPCDirectReadEvent() { EventName = typeof(HeatChangeEvent).Name });
 }
 public void Init()
 {
     MainGate = new Client(ClientName, this);
     MainGate.Subscribe();
     mixerTimer.Interval = 1000;
     mixerTimer.AutoReset = false;
     mixerTimer.Enabled = true;
     mixerTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
     // список доступных миксеров
     var fex = new FlexHelper("OPC.Read-OPC.HM-Chemistry.Event.");
     ClientFace.ironTable.dgw.RowCount = 0;
     fex.Fire(MainGate);
     // текущий номер плавки
     MainGate.PushEvent(new OPCDirectReadEvent() {EventName = typeof (HeatChangeEvent).Name});
 }
Ejemplo n.º 7
0
        public static void SendResultCalc(OutData outData)
        {
            var fex = new FlexHelper("Charge5.ResultCalc");

            fex.AddArg("MDlm", outData.MDlm); // int
            fex.AddArg("MDlms", outData.MDlms); // int
            fex.AddArg("MFom", outData.MFom); // int
            fex.AddArg("MHi", outData.MHi); // int
            fex.AddArg("MLi", outData.MLi); // int
            fex.AddArg("MSc", outData.MSc); // int
            fex.AddArg("IsFound", outData.IsFound); // bool

            fex.Fire(Program.MainGate);

            Implements.InstantLogger.msg(fex.evt.ToString());
        }
        public void OnEvent(BaseEvent evt)
        {
            using (var l = new Logger("Listener")) {
                if (evt is FlexEvent) {
                    lock (Program.ResultList) {
                        var last = Program.ResultList.Count - 1;
                        var fxe = evt as FlexEvent;
                        if (fxe.Operation.StartsWith("CoreMeteringEvent")) {
                            for (int i = 0; i < Program.FlexList.Count; i++) {
                                if (fxe.Id == Program.FlexList[i].Id) {
                                    var fxhReceived = new FlexHelper(fxe);
                                    var fxhSended = new FlexHelper(Program.FlexList[i]);

                                    var timeReceive = DateTime.Now;
                                    var timeSend = (DateTime) fxhSended.GetArg("SendTime");
                                    var deltaTime = timeReceive - timeSend;
                                    var delayMs = deltaTime.TotalMilliseconds;

                                    delayMs = delayMs > 0 ? delayMs : 0;
                                    Program.ResultList[last].TotalDelayMs += delayMs;
                                    var previousDelay = Program.ResultList[last].MaxDelayMs;
                                    Program.ResultList[last].MaxDelayMs = delayMs > previousDelay
                                                                              ? delayMs
                                                                              : previousDelay;
                                    if (Program.ResultList[last].ReceivedEvents > 0) {
                                        Program.ResultList[last].AverageDelayMs =
                                            (Program.ResultList[last].TotalDelayMs/
                                             Program.ResultList[last].ReceivedEvents);
                                    }
                                    //Console.WriteLine(Program.ResultList[last].AverageDelayMs);
                                    //Console.WriteLine(delayMs);
                                    //Console.WriteLine(Program.ResultList[last].MaxDelayMs);
                                    //Console.WriteLine("send time = {0}; receive time = {1}", fxhSended.GetArg("SendTime"), fxhReceived.GetArg("SendTime"));
                                    Program.FlexList.RemoveAt(i);
                                    break;
                                }
                            }

                            Program.ResultList[last].ReceivedEvents++;
                            //Program.ResultList[last].LostEvents = Program.ResultList[last].FieredEvents -
                            //                                      Program.ResultList[last].ReceivedEvents;
                            //Console.WriteLine(Program.ResultList[last].LostEvents);
                        }
                    }
                }
            }
        }
        public void OnEvent(BaseEvent evt)
        {
            using (Logger l = new Logger("OnEvent"))
            {
                if (evt is FlexEvent)
                {
                    var fex = new FlexHelper(evt as FlexEvent);
                    if (fex.evt.Operation.StartsWith("OPC.HM-Chemistry.Event."))
                    {
                        lock (mixers)
                        {
                            mixers.Enqueue(fex);
                            mixerTimer.Interval = 1000;
                        }
                    }
                    else if (fex.evt.Operation.StartsWith("Model.Shixta-I"))
                    {
                        l.msg("{0}", fex.evt);
                    }
                }
                else if (evt is HeatChangeEvent)
                {
                    var hce = evt as HeatChangeEvent;
                    if (HeatNumber == hce.HeatNumber) return;
                    Int64 rem;
                    Int64 res = Math.DivRem(hce.HeatNumber, 10000, out rem);
                    var newHeatNumber = res * 100000 + rem;
                    HeatNumber = newHeatNumber;
                    Program.face.Invoke(new MethodInvoker(delegate()
                    {
                        Program.face.txbHeatNum.Text = Convert.ToString(HeatNumber);
                        Program.face.lblTitleHeading.Text
                            += Program.face.txbHeatNum.Text.Substring(0, 1);
                        Program.face.txbSteelTemp.Text = "1650";
                        Program.face.txbCarbonPercent.Text = "0,03";
                        Program.face.txbMgO.Text = "10";
                        Program.face.txbFeO.Text = "27";
                        Program.face.txbBasiticy.Text = "2,7";
                        Program.face.txbIronTask.Text = "300";
                        Program.face.txbIronTemp.Text = "1380";

                    }));
                }
            }
        }
 public void OnEvent(BaseEvent evt)
 {
     using (Logger l = new Logger("Corelistener.OnEvent")) {
         if (evt is FlexEvent) {
             var fex = new FlexHelper(evt as FlexEvent);
             if (fex.evt.Operation.StartsWith("OPC.HM-Chemistry.Event.")) {
                 lock (mixers) {
                     mixers.Enqueue(fex);
                     mixerTimer.Interval = 1000;
                     ClientFace.ironTable.dgw.RowCount = 0;
                 }
             }
             else if (fex.evt.Operation.StartsWith("Model.Shixta-I")) {
                 l.msg("{0}", fex.evt);
             }
         }
         else if (evt is HeatChangeEvent) {
             var hce = evt as HeatChangeEvent;
             Int64 rem;
             Int64 res = Math.DivRem(hce.HeatNumber, 10000, out rem);
             var newHeatNumber = res*100000 + rem;
             HeatNumber = newHeatNumber;
             ClientFace.Invoke(new MethodInvoker(delegate() {
                 ClientFace.txbHeatNum.Text = Convert.ToString(HeatNumber + 1);
                 if (ClientFace.m_cn !=
                     ClientFace.txbHeatNum.Text.Substring(0, 1)) {
                     ClientFace.m_cn = ClientFace.txbHeatNum.Text.Substring(
                         0, 1);
                     ClientFace.lblTitleHeading.Text =
                         ClientFace.lblTitleHeading.Text.Replace("X",
                                                                 ClientFace.
                                                                     m_cn);
                 }
                 ClientFace.lblTitleHeading.Text =
                     ClientFace.lblTitleHeading.Text.Replace(WhatToFind,
                                                             Convert.ToString
                                                                 (HeatNumber));
                 WhatToFind = Convert.ToString(HeatNumber);
             }));
         }
     }
 }
Ejemplo n.º 11
0
 public static void fireFlex(FlexEvent d)
 {
     var fex = new FlexHelper(d.Operation);
     fex.evt.Flags = d.Flags;
     foreach (var a in d.Arguments) {
         var v = ((Element) a.Value).val;
         if (v is byte[]) {
             var vv = v as byte[];
             string s = "";
             for (var i = 0; i < vv.Length; i++) {
                 int c = vv[i];
                 if (c > 127) c += 0x0350;
                 s += Convert.ToChar(c);
             }
             ///!sb.AppendFormat("/{0}", s);
             v = s;
         }
         fex.AddArg(a.Key, v);
     }
     fex.Fire(MainGate);
 }
Ejemplo n.º 12
0
 public static void StopBlowFlagRelease()
 {
     var fex = new ConnectionProvider.FlexHelper("OPC.ComEndBlowing");
     fex.AddArg("EndBlowingSignal", 0);
     fex.Fire(Program.MainGate);
     InstantLogger.log(fex.evt.ToString());
 }
        private void PatternSave()
        {
            for (int i = 0; i < CountTables; i++)
                Tables[i] = UpdateCsvtpFromTd(DGTables[i], Tables[i]);

            CSVTP_FlexEventConverter.AppName = "UI";
            var flex = CSVTP_FlexEventConverter.PackToFlex(PatternLoadedName, InitTbl, Tables);
            ConsolePush("Паттерн запакован");
            var fex = new FlexHelper(flex.Operation);
            fex.evt.Arguments = flex.Arguments;
            fex.Fire(Requester.MainGate);
            StatusChange("Паттерн отправлен на сохранение...");
        }
Ejemplo n.º 14
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;
            }
        }
Ejemplo n.º 15
0
        public static void Iterator()
        {
            var msg = "";

            CorrectionOxyT = CalcT(MatrixT, Data);
            //CorrectionOxyC = CalcC(MatrixC, Data);
            CorrectionOxyC = -1; // != 0
            //EndBlowingOxygen = CorrectionOxyT; // додувать по температуре
            if (IsFiered) {
                InstantLogger.msg("End blowing oxygen: {0} || Current Oxygen: {1} || End: {2}", EndBlowingOxygen,
                                  CurrentOxygen, ((int) (EndBlowingOxygen - CurrentOxygen)).ToString());
            }
            if (CorrectionOxyT != 0)
                Console.WriteLine("CorrectionOxyT = " + CorrectionOxyT);
            //if (CorrectionOxyC != 0)
            //{
            //    Console.WriteLine("CorrectionOxyC = " + CorrectionOxyC);
            //}
            if (IsUncorrectMetering) {
                CorrectionOxyT = -5;
                msg += String.Format("\nнекорректный замер");
            }
            if (CorrectionOxyT != 0 && CorrectionOxyC != 0 && !IsFiered) {
                if ((CorrectionOxyT == -3) && (Data.TargetTuMax != 0)) {
                    //CorrectionDoloms = CalcDolmsCooling(Math.Abs(Data.CurrentT - Data.TargetT), Data.CurrentC);
                    CorrectionDoloms = CalcDolmsCooling(Math.Abs(Data.CurrentT - (((Data.TargetT + Data.TargetTuMax) + Data.TargetT) * 0.5)), Data.CurrentC); // до середины между максимальным целевым и целевым
                    msg += String.Format("\nрекомендуется выполнить охлаждение Doloms = {0} тонны", CorrectionDoloms);
                    GiveDlmsCooling(Data.CurrentT, Data.TargetT);
                }

                var fex = new ConnectionProvider.FlexHelper("CorrectionCT.RecommendBalanceBlow");
                fex.AddArg("CorrectionOxygenT", CorrectionOxyT); // int
                fex.AddArg("CorrectionOxygenC", CorrectionOxyC); // int
                fex.AddArg("CorrectionDoloms", CorrectionDoloms); // double
                fex.AddArg("CurrentC", Data.CurrentC); // double
                fex.AddArg("TargetC", Data.TargetC); // double
                fex.AddArg("CurrentT", Data.CurrentT); // int
                fex.AddArg("TargetT", Data.TargetT); // int
                fex.AddArg("SId", SidB); // Guid

                fex.Fire(Program.MainGate);

                IsFiered = true;

                InstantLogger.msg(fex.evt.ToString());

                EndBlowingOxygen = CorrectionOxyT + CurrentOxygen; // додувать по температуре

                InstantLogger.msg("End blowing oxygen {0}{1}", EndBlowingOxygen, msg);
            }
            if ((CurrentOxygen > EndBlowingOxygen) && !BlowStopSignalPushed && AutomaticStop && IsActualOxygen)
                DoStopBlow();
        }
Ejemplo n.º 16
0
 public static void ReqScheme(int schemaN)
 {
     var fex = new FlexHelper("DBFlex.Request");
     fex.AddArg(Implements.DBFlex.ArgEventName, "SQL.Corrections");
     fex.AddArg(Implements.DBFlex.ArgCommandName, "GetScheme");
     fex.AddArg("Schema", schemaN);
     fex.Fire(MainGate);
 }
Ejemplo n.º 17
0
 public static void SublanceDataLost(object source, ElapsedEventArgs e)
 {
     WaitSublanceData.Enabled = false;
     var fex = new ConnectionProvider.FlexHelper("CorrectionCT.SublanceDataLost");
     fex.Fire(Program.MainGate);
     InstantLogger.log(fex.evt.ToString());
 }
        public void OnEvent(BaseEvent evt)
        {
            using (var l = new Logger("Listener")) {
                if (evt is LanceEvent) {
                    var le = evt as LanceEvent;
                    Iterator.Receiver.LanceHeight = le.LanceHeight;
                    Iterator.Receiver.QO2 = le.O2Flow;
                    Iterator.Receiver.QO2I = le.O2TotalVol;
                }
                if (evt is BlowingEvent) {
                    var be = evt as BlowingEvent;
                    Iterator.Receiver.HeatIsStarted = be.BlowingFlag == 1;
                }

                if (evt is OffGasEvent) {
                    var oge = evt as OffGasEvent;
                    Iterator.Receiver.OffGasV.Add(oge.OffGasFlow);
                    Iterator.Receiver.OffGasT.Add(oge.OffGasTemp);
                }
                if (evt is DecompressionOffGasEvent) {
                    var doge = evt as DecompressionOffGasEvent;
                    Iterator.Receiver.OffGasDecompression.Add(doge.Decompression);
                }
                if (evt is HeatChangeEvent) {
                    var hce = evt as HeatChangeEvent;
                    if (CHeatNumber != hce.HeatNumber) {
                        CHeatNumber = hce.HeatNumber;
                        Iterator.Reset();
                        Iterator.CurrentState.HeatNumber = hce.HeatNumber;
                        Iterator.ArchFileGen();
                        l.msg("Heat Changed. New Heat ID: {0}\n", Iterator.CurrentState.HeatNumber);
                    }
                    else
                        l.msg("Heat No Changed. Heat ID: {0}\n", hce.HeatNumber);
                }

                if (evt is SublanceStartEvent) {
                    var sse = evt as SublanceStartEvent;
                    if (sse.SublanceStartFlag == 1) {}
                    if (sse.SublanceStartFlag == 0) {
                        //
                    }
                }

                if (evt is visSpectrluksEvent) // углерод со спектролюкса
                {
                    var vse = evt as visSpectrluksEvent;
                    //Iterator.FindAndDequeue(vse.C, HeatNumberToShort(vse.HeatNumber));
                }

                if (evt is ScrapEvent) {
                    var se = evt as ScrapEvent;
                    if (se.ConverterNumber == Program.ConverterNumber) {
                        Iterator.CurrentState.MSc = se.TotalWeight;
                        l.msg("Scrap mass: {0}", Iterator.CurrentState.MSc);
                    }
                }
                if (evt is BoundNameMaterialsEvent) {
                    var bnme = evt as BoundNameMaterialsEvent;
                    BoundMaterials = new List<string>();
                    BoundMaterials.Add(bnme.Bunker5MaterialName);
                    BoundMaterials.Add(bnme.Bunker6MaterialName);
                    BoundMaterials.Add(bnme.Bunker7MaterialName);
                    BoundMaterials.Add(bnme.Bunker8MaterialName);
                    BoundMaterials.Add(bnme.Bunker9MaterialName);
                    BoundMaterials.Add(bnme.Bunker10MaterialName);
                    BoundMaterials.Add(bnme.Bunker11MaterialName);
                    BoundMaterials.Add(bnme.Bunker12MaterialName);
                }

                if (evt is visAdditionTotalEvent) {
                    var vate = evt as visAdditionTotalEvent;
                    WeightMaterials = new List<double>();
                    WeightMaterials.Add(vate.RB5TotalWeight);
                    WeightMaterials.Add(vate.RB6TotalWeight);
                    WeightMaterials.Add(vate.RB7TotalWeight);
                    WeightMaterials.Add(vate.RB8TotalWeight);
                    WeightMaterials.Add(vate.RB9TotalWeight);
                    WeightMaterials.Add(vate.RB10TotalWeight);
                    WeightMaterials.Add(vate.RB11TotalWeight);
                    WeightMaterials.Add(vate.RB12TotalWeight);

                    //BoundMaterials = new List<string>(); // на время отладки на эмуляторе
                    //BoundMaterials.Add("ДОЛОМС");
                    //BoundMaterials.Add("ALKонц");
                    //BoundMaterials.Add("KOKS  ");
                    //BoundMaterials.Add("ИЗВЕСТ");
                    //BoundMaterials.Add("ИЗВЕСТ");
                    //BoundMaterials.Add("ДОЛМИТ");
                    //BoundMaterials.Add("ДОЛОМС");
                    //BoundMaterials.Add("ФОМ   ");

                    var bunkerCnt = BoundMaterials.Count;
                    for (int i = 0; i < bunkerCnt; i++) {
                        var wgh = WeightMaterials[i];
                        var name = BoundMaterials[i];
                        for (int j = 0; j < bunkerCnt; j++) {
                            if ((i != j) && (name == BoundMaterials[j]))
                                wgh += WeightMaterials[j];
                        }

                        if (!Iterator.Receiver.HeatIsStarted) // все что отдали до продувки не считаем
                        {
                            Iterator.MaterialsZeroLevel.SetTotalWeight(Encoder(name), wgh, false);

                            //Iterator.MaterialsZeroLevel.SetTotalWeight(name, wgh, false); // временно для отладки
                        }
                        else
                        {
                            var wghZlevel = Iterator.MaterialsZeroLevel.GetTotalWeight(Encoder(name), false);
                            Iterator.CurrentState.Materials.SetTotalWeight(Encoder(name), wgh - wghZlevel, false);

                            //var wghZlevel = Iterator.MaterialsZeroLevel.GetTotalWeight(name, false); // временно для отладки
                            //Iterator.CurrentState.Materials.SetTotalWeight(name, wghZlevel - wgh, false); // временно для отладки
                        }

                        //Iterator.CurrentState.Materials.SetTotalWeight(Encoder(name), wgh, false);
                        //Iterator.CurrentState.Materials.SetTotalWeight(name, wgh, false); // временно для отладки
                    }
                }

                if (evt is FlexEvent) {
                    var fxe = evt as FlexEvent;
                    if (fxe.Operation.StartsWith("UDP.OffGasAnalysisEvent")) {
                        var fxh = new FlexHelper(fxe);

                        Iterator.Receiver.H2.Add(fxh.GetDbl("H2"));
                        Iterator.Receiver.O2.Add(fxh.GetDbl("O2"));
                        Iterator.Receiver.CO.Add(fxh.GetDbl("CO"));
                        Iterator.Receiver.CO2.Add(fxh.GetDbl("CO2"));
                        Iterator.Receiver.N2.Add(fxh.GetDbl("N2"));
                        Iterator.Receiver.Ar.Add(fxh.GetDbl("Ar"));

                        if (fxh.GetDbl("Branch") == 1)
                            Iterator.CurrentState.OffGasTransportDelay = (int) Math.Round(fxh.GetDbl("TransportDelay1"));
                        else if (fxh.GetDbl("Branch") == 2)
                            Iterator.CurrentState.OffGasTransportDelay = (int) Math.Round(fxh.GetDbl("TransportDelay2"));
                    }

                    if (fxe.Operation.StartsWith("PipeCatcher.Call.PCK_DATA.PGET_WGHIRON1")) {
                        if ((string) fxe.Arguments["SHEATNO"] ==
                            Convert.ToString(HeatNumberToLong(Iterator.CurrentState.HeatNumber))) {
                            l.msg("Iron Correction from Pipe: {0}\n", fxe.Arguments["NWGH_NETTO"]);
                            var hotIronMass = Convert.ToDouble(fxe.Arguments["NWGH_NETTO"])*1000;
                            Iterator.CurrentState.MHi = hotIronMass;
                        }
                        else {
                            l.msg(
                                "Iron Correction from Pipe: wrong heat number - expected {0} found {1}",
                                Iterator.CurrentState.HeatNumber, fxe.Arguments["SHEATNO"]
                                );
                        }
                    }

                    if (fxe.Operation.StartsWith("PipeCatcher.Call.PCK_DATA.PGET_XIMIRON")) {
                        if ((string) fxe.Arguments["HEAT_NO"] ==
                            Convert.ToString(HeatNumberToLong(Iterator.CurrentState.HeatNumber))) {
                            l.msg(fxe.ToString());
                            var hotIronMass = Convert.ToDouble(fxe.Arguments["HM_WEIGHT"]);
                            var hotIronCarbon = Convert.ToDouble(fxe.Arguments["ANA_C"]);
                            Iterator.CurrentState.MHi = hotIronMass;
                            Iterator.CurrentState.PCHi = hotIronCarbon;
                        }
                        else {
                            l.msg(
                                "Iron Correction from Pipe: wrong heat number - expected {0} found {1}",
                                HeatNumberToLong(Iterator.CurrentState.HeatNumber), fxe.Arguments["HEAT_NO"]
                                );
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
 public static void GiveDlmsCooling(double currentT, double targetT)
 {
     var diff = targetT - currentT;
     if (diff < -10) {
         var fex = new ConnectionProvider.FlexHelper("CorrectionCT.GiveDlmsCooling");
         fex.Fire(Program.MainGate);
         InstantLogger.msg(fex.evt.ToString());
     }
 }
 public static void SetControlMode(bool isAutomatic)
 {
     var fex = new ConnectionProvider.FlexHelper("OPC.ComControlMode");
     if (isAutomatic) {
         fex.AddArg("LanceMode", 3);
         fex.AddArg("VpathMode", 3);
     }
     else {
         fex.AddArg("LanceMode", 0);
         fex.AddArg("VpathMode", 0);
     }
     fex.Fire(m_pushGate);
 }
 public String ProcessNews()
 {
     using (Logger l = new Logger("PipeCatcher"))
     {
         OraCmd.CommandText = ProcName;
         OraCmd.CommandType = System.Data.CommandType.StoredProcedure;
         OraCmd.Parameters.Clear();
         OraCmd.Parameters.Add(new OracleParameter("NRECID", OracleDbType.Decimal, System.Data.ParameterDirection.Input)).Value = RecId;
         OraCmd.Parameters.Add(new OracleParameter("REFCURSOR", OracleDbType.RefCursor, System.Data.ParameterDirection.Output));
        // OraCmd.Parameters["NRECID"].Value = RecId;
         if (OraCmd.Connection.State != System.Data.ConnectionState.Closed)
         {
             OraCmd.Connection.Close();
         }
         OraCmd.Connection.Open();
         OraReader = OraCmd.ExecuteReader();
         var str = String.Format("\nCALL {0}({1})", ProcName, RecId);
         if (OraReader.HasRows)
         {
             var f = new FlexHelper("PipeCatcher.Call." + ProcName);
             str += "+++";
             OraReader.Read();
             f.AddArg("@ProcName", ProcName);
             for (int i = 0; i < OraReader.FieldCount; i++)
             {
                 f.AddArg(OraReader.GetName(i), OraReader[i]);
                 str += "\n" + OraReader.GetName(i) + "\t: " + OraReader[i];
             }
             f.Fire(Program.CoreGate);
         }
         else
         {
             str += "---";
         }
         OraReader.Close();
         return str;
     }
 }
        public static void Iterate()
        {
            if (ModelIsStarted) {
                if (m_dataIsFixed) {
                    if (!m_dataIsEnqueue) {
                        CurrentState.SteelCarbonPercentCalculated = Decarbonater.MFactorUniversalCarbonPlus(m_matrix,
                                                                                                   CurrentState);
                        CurrentState.SteelCarbonPercentCalculated =
                            CarbonClipper(CurrentState.SteelCarbonPercentCalculated);
                        if (VerifyForEnqueueWaitC()) EnqueueWaitC(); // ставим в очередь если плавка нормальная
                        m_dataIsEnqueue = true;
                        FireCurrentCarbon(CurrentState.SteelCarbonPercentCalculated);
                        FireFixEvent(CurrentState.SteelCarbonPercentCalculated);
                    }
                }
                else {
                    var co2 = HDSmoother.CO2.Average(PeriodSec);
                    var co = HDSmoother.CO.Average(PeriodSec);
                    CurrentState.CarbonVP = co*0.43 + co2 * 0.27;
                    CurrentState.CarbonIVP += CurrentState.CarbonVP;
                    CurrentState.TimeFromX += IntervalSec;
                    CurrentState.SteelCarbonPercentCalculated = Decarbonater.MFactorUniversalCarbonPlus(m_matrix, CurrentState);

                    //if (!m_dataIsEnqueue) m_lastCarbon = CurrentState.SteelCarbonPercentCalculated;
                    CurrentState.SteelCarbonPercentCalculated = CarbonClipper(CurrentState.SteelCarbonPercentCalculated);
                    FireCurrentCarbon(CurrentState.SteelCarbonPercentCalculated); // fire flex

                    //Console.WriteLine("Carbone = " + CurrentState.SteelCarbonPercentCalculated + "%");
                    m_dataIsFixed = ModelVerifiForFix();
                }
            }
            else {
                ModelIsStarted = ModelVerifiForStart();

                if (ModelIsStarted) {
                    FireCurrentCarbon(0.095);
                    var fex = new FlexHelper("UniversalCPlus.ModelIsStarted");
                    fex.Fire(Program.MainGate);
                    InstantLogger.msg(fex.evt + "\n");
                }
            }

            if (HDSmoother.HeatIsStarted)
                CurrentState.HightQualityHeat = HightQualityHeatVerify();
        }
 public static void FireFixEvent(double carbon)
 {
     var fex = new FlexHelper("UniversalCPlus.DataFix");
     fex.AddArg("C", carbon);
     fex.Fire(Program.MainGate);
     InstantLogger.msg(fex.evt + "\n");
 }
        public static void FireCurrentCarbon(double carbon)
        {
            const double tresholdCarbon = 0.03;
            carbon = carbon < tresholdCarbon ? tresholdCarbon : carbon; // ограничение на углерод

            var fex = new FlexHelper("UniversalCPlus.Result");
            fex.AddArg("C", carbon);
            fex.Fire(Program.MainGate);
            InstantLogger.msg("carbon = {0}", carbon);
        }
        public void OnEvent(BaseEvent newEvent)
        {
            // System.Threading.Thread.Sleep(3000);
            // InstantLogger.log(newEvent.GetType().GetCustomAttributesData()[5].ToString());
            //if (!(newEvent is SteelMakingPatternEvent))
            if ((newEvent is visAdditionTotalEvent))
                InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.error);
            if (newEvent is visSpectrluksEvent)
                InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.error);

            if (newEvent is FlexEvent) {
                var flx = newEvent as FlexEvent;
                if (flx.Operation.StartsWith("TestComplex")) {
                    var fxe = new FlexHelper(flx);
                    var dimm = (int[]) fxe.GetComplexArg("dimm", typeof (int[]));
                    Console.WriteLine("Receive:");
                    foreach (var i in dimm)
                        Console.Write((i + ", "));
                }
            }
            //var v = (PLCGroup)newEvent.GetType().GetCustomAttributes(false).Where(x => x.GetType().Name == "PLCGroup").FirstOrDefault();
            //object first = null;
            /*         InstantLogger.log(newEvent.GetType().FullName);
            var plcg = new PLCGroup();
            foreach (object x in newEvent.GetType().GetCustomAttributes(false))
            {
                if (x.GetType().Name == "PLCGroup")
                {
                    plcg = (PLCGroup)x;
                    InstantLogger.log("    " + plcg.Location + " -- " + plcg.Destination);
                }
            }
            var plcp = new PLCPoint();
            foreach (var prop in newEvent.GetType().GetProperties())
            {
                foreach (object x in prop.GetCustomAttributes(false))
                {
                    if (x.GetType().Name == "PLCPoint")
                    {

                        if (((PLCPoint)x).IsWritable)
                        {

                            plcp = (PLCPoint)x;
                            //prop.GetValue(newEvent, null);
                            //prop.GetValue(newEvent);
                            InstantLogger.log("        " + prop.Name + " = " + prop.GetValue(newEvent, null).ToString());
                            InstantLogger.log("            IsWritable = " + plcp.IsWritable.ToString());
                            InstantLogger.log("            " + plcp.Location);
                           // break;
                        }

                    }
                }
            }
             */

            //if (
            //    (newEvent is cntBlowingSchemaEvent) ||
            //    (newEvent is comBlowingSchemaEvent) ||
            //    (newEvent is cntWatchDogPLC01Event) ||
            //    (newEvent is cntWatchDogPLC1Event) ||
            //    (newEvent is cntWatchDogPLC2Event) ||
            //    (newEvent is cntWatchDogPLC3Event) ||
            //    (newEvent is comO2FlowRateEvent) ||
            //   (newEvent is cntO2FlowRateEvent)
            //    )
            //{

            //   // SteelMakingPatternEvent steelMakingPatternEvent = newEvent as SteelMakingPatternEvent;
            //    InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.death);
            //}
            //if(
            //    (newEvent is comAdditionsEvent) ||
            //    (newEvent is comAdditionsSchemaEvent)
            //   )
            //{
            //    InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.terror);
            //}

            //if (newEvent is HeatSchemaStepEvent)
            //{
            //    InstantLogger.log("step = " + newEvent.ToString(), "Received", InstantLogger.TypeMessage.caution);
            //}
            //if ((newEvent is cntWeigher3JobReadyEvent) ||
            //    (newEvent is cntWeigher4JobReadyEvent)||
            //    (newEvent is cntWeigher5JobReadyEvent)||
            //    (newEvent is cntWeigher6JobReadyEvent)||
            //    (newEvent is cntWeigher7JobReadyEvent))
            //{
            //    InstantLogger.log("step = " + newEvent.ToString(), "Received", InstantLogger.TypeMessage.normal);
            //}
            /*if (newEvent is SteelMakingPatternEvent)
            {

                SteelMakingPatternEvent steelMakingPatternEvent = newEvent as SteelMakingPatternEvent;
                InstantLogger.log(steelMakingPatternEvent.steps[0].Period.ToString(), "Received", InstantLogger.TypeMessage.important);
            }*/
            // lock (Program.consoleLock)
            //{
            /* Console.BackgroundColor = ConsoleColor.Blue;
               Console.ForegroundColor = ConsoleColor.White;
               Console.WriteLine(" " + newEvent.ToString() + "\n");
               Console.BackgroundColor = ConsoleColor.DarkBlue;
               Console.ForegroundColor = ConsoleColor.Gray;

               logFile.Write(newEvent.ToString() + "\n");*/
            // InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.unimportant);

            //logFile.Close();
            //}

            //MessageBox.Show("ll", "ll");
        }
Ejemplo n.º 26
0
 public static FlexHelper CreateRespFex(FlexEvent flx)
 {
     var operation = flx.Arguments.ContainsKey(ArgEventName) ? (string)flx.Arguments[ArgEventName] : "DBF.default.responce";
     var fex = new FlexHelper(operation);
     return fex;
 }
Ejemplo n.º 27
0
        private static void WatchDogSendTimeoutHandler(object state)
        {
            var fex = new FlexHelper("OPC.WatchdogsForL1");

            fex.AddArg("WDPLC1", m_watchdogSendValue);
            fex.AddArg("WDPLC2", m_watchdogSendValue);
            fex.AddArg("WDPLC3", m_watchdogSendValue);
            //fex.AddArg("WDPLC01", m_watchdogValue);
            fex.Fire(m_mainGate);

            if (m_watchdogSendValue < 999) m_watchdogSendValue++;
            else m_watchdogSendValue = 0;
        }
        public void OnEvent(BaseEvent evt)
        {
            using (var l = new Logger("Listener")) {
                if (evt is FlexEvent) {
                    var fxe = evt as FlexEvent;
                    if (fxe.Operation.StartsWith("SQL.Corrections")) {
                        var fex = new FlexHelper(fxe);
                        if (fex.GetStr(MainWindow.ArgCommandName) == "GetScheme") {
                            if (fex.GetStr(MainWindow.ArgErrorCodeName) == "S_OK") {
                                var itemLst = (List<int>) fex.GetComplexArg("ITEM", typeof (List<int>));
                                var cminLst = (List<double>) fex.GetComplexArg("CMIN", typeof (List<double>));
                                var cmaxLst = (List<double>) fex.GetComplexArg("CMAX", typeof (List<double>));
                                var oxygenLst = (List<double>) fex.GetComplexArg("OXYGEN", typeof (List<double>));
                                var heatinLst = (List<double>) fex.GetComplexArg("HEATING", typeof (List<double>));
                                Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() {
                                                                                     Pointer.PMainWindow.TableData = new List<TableRow>();
                                                                                     Pointer.PMainWindow.StandartTableData = new List<TableRow>();
                                                                                     for (int i = 0; i < fex.GetInt(MainWindow.ArgCountName); i++) {
                                                                                         var tr = new TableRow();
                                                                                         tr.Item = itemLst[i];
                                                                                         tr.CMin = cminLst[i];
                                                                                         tr.CMax = cmaxLst[i];
                                                                                         tr.Oxygen = oxygenLst[i];
                                                                                         tr.Heating = heatinLst[i];

                                                                                         Pointer.PMainWindow.StandartTableData.Add(new TableRow(tr));

                                                                                         tr.Item = i;
                                                                                         Pointer.PMainWindow.TableData.Add(new TableRow(tr));

                                                                                     }
                                                                                     Pointer.PMainWindow.dgScheme.ItemsSource =Pointer.PMainWindow.TableData;
                                                                                     Pointer.PMainWindow.dgScheme.Items.Refresh();
                                                                                     Pointer.PMainWindow.btnSave.IsEnabled = true;
                                                                                     Pointer.PMainWindow.LogWrite("Scheme loaded");
                                                                                 }));
                            }
                            else {
                                Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() {
                                                                                     Pointer.PMainWindow.LogWrite(fex.GetStr(MainWindow.ArgErrorStringName));
                                                                                 }));
                            }
                        }

                        if (fex.GetStr(MainWindow.ArgCommandName) == "InsertSchemeRow") {
                            if (fex.GetStr(MainWindow.ArgErrorCodeName) == "S_OK") {
                                Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() {
                                                                                     Pointer.PMainWindow.TableChangeCounter--;
                                                                                     if (Pointer.PMainWindow.TableChangeCounter == 0) {
                                                                                         Pointer.PMainWindow.ReqScheme(Pointer.PMainWindow.CurrentSchema);
                                                                                         Pointer.PMainWindow.LogWrite("Save complete");
                                                                                     }
                                                                                 }));
                            }
                            else {
                                Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() {
                                                                                     Pointer.PMainWindow.LogWrite("Scheme save error");
                                                                                 }));
                            }
                        }
                        if (fex.GetStr(MainWindow.ArgCommandName) == "UpdateSchemeRow")
                        {
                            if (fex.GetStr(MainWindow.ArgErrorCodeName) == "S_OK")
                            {
                                Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate()
                                {
                                    Pointer.PMainWindow.TableChangeCounter--;
                                    if (Pointer.PMainWindow.TableChangeCounter == 0)
                                    {
                                        Pointer.PMainWindow.ReqScheme(Pointer.PMainWindow.CurrentSchema);
                                        Pointer.PMainWindow.LogWrite("Save complete");
                                    }
                                }));
                            }
                            else
                            {
                                Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate()
                                {
                                    Pointer.PMainWindow.LogWrite("Scheme Update error");
                                }));
                            }
                        }

                        if (fex.GetStr(MainWindow.ArgCommandName) == "DeleteSchemeRow")
                        {
                            if (fex.GetStr(MainWindow.ArgErrorCodeName) == "S_OK")
                            {
                                Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate()
                                {
                                    Pointer.PMainWindow.TableChangeCounter--;
                                    if (Pointer.PMainWindow.TableChangeCounter == 0)
                                    {
                                        Pointer.PMainWindow.ReqScheme(Pointer.PMainWindow.CurrentSchema);
                                        Pointer.PMainWindow.LogWrite("Save complete");
                                    }
                                }));
                            }
                            else
                            {
                                Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate()
                                {
                                    Pointer.PMainWindow.LogWrite("Scheme Delete error");
                                }));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 29
0
        public static void MainHandler()
        {
            var allRight = true;
            var offgasOkay = !m_offgasEventAbsent;
            var watchdogOkay = !(m_wd1Timeout || m_wd2Timeout || m_wd3Timeout || m_wd01Timeout);
            var description = new List<string>();

            if (m_offgasEventAbsent) {
                allRight = false;
                description.Add(String.Format("OffgasEvent absent more than {0} second", MaxSecondDelayOffGasEvent));
            }

            if (!watchdogOkay)
            {
                allRight = false;
                description.Add(String.Format("Something from watchdog did not change more than {0} second", MaxSecondDelayWatchdogChange));
            }

            var fex = new FlexHelper("L1.Keeper");

            fex.AddArg("AllRight", allRight);
            fex.AddArg("OffgasOkay", offgasOkay);
            fex.AddArg("WatchdogOkay", watchdogOkay);

            fex.AddArg("Wd1Timeout", m_wd1Timeout);
            fex.AddArg("Wd2Timeout", m_wd2Timeout);
            fex.AddArg("Wd3Timeout", m_wd3Timeout);
            fex.AddArg("Wd01Timeout", m_wd01Timeout);

            fex.AddComplexArg("Description", description);

            if (!allRight) InstantLogger.err(fex.evt.ToString());
            fex.Fire(m_mainGate);
        }
Ejemplo n.º 30
0
        public static CSVTableParser LoadMatrixTFromFlex(List<ColumnPath> description, FlexHelper fex)
        {
            var matrixT = new CSVTableParser();
            matrixT.Description = description;

            var cminLst = (List<double>)fex.GetComplexArg("CMIN", typeof(List<double>));
            var cmaxLst = (List<double>)fex.GetComplexArg("CMAX", typeof(List<double>));
            var oxygenLst = (List<double>)fex.GetComplexArg("OXYGEN", typeof(List<double>));
            var heatinLst = (List<double>)fex.GetComplexArg("HEATING", typeof(List<double>));

            for (int i = 0; i < fex.GetInt(Implements.DBFlex.ArgCountName); i++) {
                var row = matrixT.ColumnCreator();
                row.Cell["CMin"] = cminLst[i];
                row.Cell["CMax"] = cmaxLst[i];
                row.Cell["OxygenOnHeating"] = oxygenLst[i];
                row.Cell["Heating"] = heatinLst[i];
                matrixT.Rows.Add(row);
            }

            return matrixT;
        }