private bool InsertOrUpdateTrends(LanceEvent evt)
 {
     var sql = CheckInsert("TREND_LANCE", evt.iCnvNr, evt.Time)
                   ? "UPDATE TREND_LANCE " +
                     "SET  O2TOTALVOL = :O2TOTALVOL, O2FLOW = :O2FLOW, O2PRESSURE = :O2PRESSURE, LANCEHEIGHT = :LANCEHEIGHT, LANCEMODE = :LANCEMODE, " +
                     "O2FLOWMODE = :O2FLOWMODE, LEFTWATERINP = :LEFTWATERINP, LEFTWATEROUT = :LEFTWATEROUT, LEFTWATERTEMPINP = :LEFTWATERTEMPINP, " +
                     "LEFTWATERTEMPOUTP = :LEFTWATERTEMPOUTP, LEFTLECK = :LEFTLECK, RIGHTLECK = :RIGHTLECK, LEFTWATERPRESS = :LEFTWATERPRESS, " +
                     "RIGHTWATERPRESS = :RIGHTWATERPRESS, RIGHTWATERINP = :RIGHTWATERINP, RIGHTWATEROUT = :RIGHTWATEROUT, " +
                     "RIGHTWATERTEMPINP = :RIGHTWATERTEMPINP, RIGHTWATERTEMPOUTP = :RIGHTWATERTEMPOUTP, LEFTWEIGHT = :LEFTWEIGHT, LEFTGOAT = :LEFTGOAT, " +
                     "RIGHTWEIGHT = :RIGHTWEIGHT, RIGHTGOAT = :RIGHTGOAT, BATHLEVEL = :BATHLEVEL " +
                     "WHERE CNV_NO = :CNV_NO AND INSERTTIME = :INSERTTIME "
                   : "INSERT INTO TREND_LANCE(O2TOTALVOL, O2FLOW, O2PRESSURE, LANCEHEIGHT, LANCEMODE, O2FLOWMODE, LEFTWATERINP, LEFTWATEROUT, " +
                     "LEFTWATERTEMPINP, LEFTWATERTEMPOUTP, LEFTLECK, RIGHTLECK, LEFTWATERPRESS, RIGHTWATERPRESS, RIGHTWATERINP, RIGHTWATEROUT, " +
                     "RIGHTWATERTEMPINP, RIGHTWATERTEMPOUTP, LEFTWEIGHT, LEFTGOAT, RIGHTWEIGHT, RIGHTGOAT, BATHLEVEL, CNV_NO, INSERTTIME) " +
                     "VALUES (:O2TOTALVOL, :O2FLOW, :O2PRESSURE, :LANCEHEIGHT, :LANCEMODE, :O2FLOWMODE, :LEFTWATERINP, :LEFTWATEROUT, " +
                     ":LEFTWATERTEMPINP, :LEFTWATERTEMPOUTP, :LEFTLECK, :RIGHTLECK, :LEFTWATERPRESS, :RIGHTWATERPRESS, :RIGHTWATERINP, :RIGHTWATEROUT, " +
                     ":RIGHTWATERTEMPINP, :RIGHTWATERTEMPOUTP, :LEFTWEIGHT, :LEFTGOAT, :RIGHTWEIGHT, :RIGHTGOAT, :BATHLEVEL, :CNV_NO, :INSERTTIME) ";
     var parametres = new List<OracleParameter>
                          {
                              SetParams("O2TOTALVOL", evt.O2TotalVol),
                              SetParams("O2FLOW", evt.O2Flow),
                              SetParams("O2PRESSURE", evt.O2Pressure),
                              SetParams("LANCEHEIGHT", evt.LanceHeight),
                              SetParams("LANCEMODE", evt.LanceMode),
                              SetParams("O2FLOWMODE", evt.O2FlowMode),
                              SetParams("LEFTWATERINP", evt.O2LeftLanceWaterInput),
                              SetParams("LEFTWATEROUT", evt.O2LeftLanceWaterOutput),
                              SetParams("LEFTWATERTEMPINP", evt.O2LeftLanceWaterTempInput),
                              SetParams("LEFTWATERTEMPOUTP", evt.O2LeftLanceWaterTempOutput),
                              SetParams("LEFTLECK", evt.O2LeftLanceLeck),
                              SetParams("RIGHTLECK", evt.O2RightLanceLeck),
                              SetParams("LEFTWATERPRESS", evt.O2LeftLanceWaterPressure),
                              SetParams("RIGHTWATERPRESS", evt.O2RightLanceWaterPressure),
                              SetParams("RIGHTWATERINP", evt.O2RightLanceWaterInput),
                              SetParams("RIGHTWATEROUT", evt.O2RightLanceWaterOutput),
                              SetParams("RIGHTWATERTEMPINP", evt.O2RightLanceWaterTempInput),
                              SetParams("RIGHTWATERTEMPOUTP", evt.O2LeftLanceWaterTempOutput),
                              SetParams("LEFTWEIGHT", evt.O2LeftLanceGewWeight),
                              SetParams("LEFTGOAT", evt.O2LeftLanceGewBaer),
                              SetParams("RIGHTWEIGHT", evt.O2RightLanceGewWeight),
                              SetParams("RIGHTGOAT", evt.O2RightLanceGewBaer),
                              SetParams("BATHLEVEL", evt.BathLevel)
                          };
     parametres.AddRange(MandatoryParams(evt.iCnvNr, evt.Time));
     return ExecuteNonQuery(sql, parametres);
 }
        public void Process(LanceEvent _event)
        {
            if (this._Module._Heat.Number == -1) return;

            if (this._Module._Heat.BlowingScheme != null)
            {
                float curpersent = (float)_event.O2TotalVol / 22000f * 100f;
                if (this._Module._Heat.CurrentBlowingScheme == -1 && curpersent > this._Module._Heat.BlowingScheme[0].O2VolStep1)
                {
                    this._Module.PushEvent(this._Module._Heat.BlowingScheme[0]);
                    this._Module._Heat.CurrentBlowingScheme = 0;
                    this._Module.PushEvent(new cntBlowingSchemaEvent());
                }
                if (this._Module._Heat.CurrentBlowingScheme == 0 && curpersent > this._Module._Heat.BlowingScheme[1].O2VolStep1)
                {
                    this._Module._Heat.CurrentBlowingScheme = 1;
                    this._Module.PushEvent(this._Module._Heat.BlowingScheme[1]);
                    this._Module.PushEvent(new cntBlowingSchemaEvent());
                }
                if (this._Module._Heat.CurrentBlowingScheme == 1 && curpersent > this._Module._Heat.BlowingScheme[2].O2VolStep1)
                {
                    this._Module._Heat.CurrentBlowingScheme = 2;
                    this._Module.PushEvent(this._Module._Heat.BlowingScheme[2]);
                    this._Module.PushEvent(new cntBlowingSchemaEvent());
                }
                if (this._Module._Heat.CurrentBlowingScheme == 2 && curpersent > this._Module._Heat.BlowingScheme[3].O2VolStep1)
                {
                    this._Module._Heat.CurrentBlowingScheme = 3;
                    this._Module.PushEvent(this._Module._Heat.BlowingScheme[3]);
                    this._Module.PushEvent(new cntBlowingSchemaEvent());
                }
            }
            //if (_event.O2TotalVol)
            try
            {

                this._Module._Heat.LanceHistory.Add( _event);
            }
            catch { }
        }
        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;
            }
        }
 public void AddLancePoints(LanceEvent lEvent)
 {
     LanceTrend.Update((DateTime.Now - StartBlowingTime.Value).TotalSeconds, lEvent.LanceHeight);
     OFlowTrend.Update((DateTime.Now - StartBlowingTime.Value).TotalSeconds, (float)lEvent.O2Flow);
     lanceHeight = lEvent.LanceHeight;
     lbLanceHeight.Content = lEvent.LanceHeight;
     lbO2Flow.Content = lEvent.O2Flow;
 }
        private bool DoLanceEvent(int iIdxInPointLi)
        {
            bool bErg = false;

             if (bIsBlasen(pointLi[iIdxInPointLi].iCnvNr)) {
            try {
               LanceEvent evLanceEvent = new LanceEvent();
               evLanceEvent.iCnvNr = pointLi[iIdxInPointLi].iCnvNr;
               j = findPoint("O2VOL_TOTAL",pointLi[iIdxInPointLi].iCnvNr);
               if (j >= 0) {
                  evLanceEvent.O2TotalVol = pointLi[j].iDataValue;
                  j = findPoint("LANCEPOS",pointLi[iIdxInPointLi].iCnvNr);
                  if (j >= 0) {
                     evLanceEvent.LanceHeight = pointLi[j].iDataValue;
                     j = findPoint("O2FLOW",pointLi[iIdxInPointLi].iCnvNr);
                     if (j >= 0) {
                        evLanceEvent.O2Flow = pointLi[j].iDataValue;
                        j = findPoint("O2PRESSURE",pointLi[iIdxInPointLi].iCnvNr);
                        if (j >= 0) {
                           evLanceEvent.O2Pressure = pointLi[j].iDataValue;
                           j = findPoint("OPLANCE",pointLi[iIdxInPointLi].iCnvNr);
                           if (j >= 0) {
                              evLanceEvent.LanceMode = pointLi[j].iDataValue;
                              j = findPoint("OPO2FLOW",pointLi[iIdxInPointLi].iCnvNr);
                              if (j >= 0) {
                                 evLanceEvent.O2FlowMode = pointLi[j].iDataValue;
                                 j = findPoint("QWASSZU_L",pointLi[iIdxInPointLi].iCnvNr);
                                 if (j >= 0) {
                                    evLanceEvent.O2LeftLanceWaterInput = pointLi[j].iDataValue;
                                    j = findPoint("QWASSAB_L",pointLi[iIdxInPointLi].iCnvNr);
                                    if (j >= 0) {
                                       evLanceEvent.O2LeftLanceWaterOutput = pointLi[j].iDataValue;
                                       j = findPoint("TWASSZU_L",pointLi[iIdxInPointLi].iCnvNr);
                                       if (j >= 0) {
                                          evLanceEvent.O2LeftLanceWaterTempInput = pointLi[j].iDataValue;
                                          j = findPoint("TWASSAB_L",pointLi[iIdxInPointLi].iCnvNr);
                                          if (j >= 0) {
                                             evLanceEvent.O2LeftLanceWaterTempOutput = pointLi[j].iDataValue;
                                             j = findPoint("LECK_L",pointLi[iIdxInPointLi].iCnvNr);
                                             if (j >= 0) {
                                                evLanceEvent.O2LeftLanceLeck = pointLi[j].iDataValue;
                                                j = findPoint("LECK_R",pointLi[iIdxInPointLi].iCnvNr);
                                                if (j >= 0) {
                                                   evLanceEvent.O2RightLanceLeck = pointLi[j].iDataValue;
                                                   j = findPoint("PWASS_L",pointLi[iIdxInPointLi].iCnvNr);
                                                   if (j >= 0) {
                                                      evLanceEvent.O2LeftLanceWaterPressure = pointLi[j].iDataValue;
                                                      j = findPoint("PWASS_R",pointLi[iIdxInPointLi].iCnvNr);
                                                      if (j >= 0) {
                                                         evLanceEvent.O2RightLanceWaterPressure = pointLi[j].iDataValue;
                                                         j = findPoint("QWASSZU_R",pointLi[iIdxInPointLi].iCnvNr);
                                                         if (j >= 0) {
                                                            evLanceEvent.O2RightLanceWaterInput = pointLi[j].iDataValue;
                                                            j = findPoint("QWASSAB_R",pointLi[iIdxInPointLi].iCnvNr);
                                                            if (j >= 0) {
                                                               evLanceEvent.O2RightLanceWaterOutput =
                                                                  pointLi[j].iDataValue;
                                                               j = findPoint("TWASSZU_R",pointLi[iIdxInPointLi].iCnvNr);
                                                               if (j >= 0) {
                                                                  evLanceEvent.O2RightLanceWaterTempInput =
                                                                     pointLi[j].iDataValue;
                                                                  j = findPoint("TWASSAB_R",
                                                                                pointLi[iIdxInPointLi].iCnvNr);
                                                                  if (j >= 0) {
                                                                     evLanceEvent.O2RightLanceWaterTempOutput =
                                                                        pointLi[j].iDataValue;
                                                                     j = findPoint("GEWLANCE_L",
                                                                                   pointLi[iIdxInPointLi].iCnvNr);
                                                                     if (j >= 0) {
                                                                        evLanceEvent.O2LeftLanceGewWeight =
                                                                           pointLi[j].iDataValue;
                                                                        j = findPoint("GEWBAER_L",
                                                                                      pointLi[iIdxInPointLi].iCnvNr);
                                                                        if (j >= 0) {
                                                                           evLanceEvent.O2LeftLanceGewBaer =
                                                                              pointLi[j].iDataValue;
                                                                           j = findPoint("GEWLANCE_R",
                                                                                         pointLi[iIdxInPointLi].iCnvNr);
                                                                           if (j >= 0) {
                                                                              evLanceEvent.O2RightLanceGewWeight =
                                                                                 pointLi[j].iDataValue;
                                                                              j = findPoint("GEWBAER_R",
                                                                                            pointLi[iIdxInPointLi].
                                                                                               iCnvNr);
                                                                              if (j >= 0) {
                                                                                 evLanceEvent.O2RightLanceGewBaer =
                                                                                    pointLi[j].iDataValue;
                                                                                 j = findPoint("BATHLEVELMAN",
                                                                                               pointLi[iIdxInPointLi].
                                                                                                  iCnvNr);
                                                                                 if (j >= 0) {
                                                                                    evLanceEvent.BathLevel =
                                                                                       pointLi[j].iDataValue;
                                                                                    sLfdEvtMsg = evLanceEvent.ToString();
                                                                                    mainGate.PushEvent(evLanceEvent);
                                                                                    //AddLogg(evLanceEvent.ToString());
                                                                                 }
                                                                                 else {
                                                                                    AddLogg(
                                                                                       "При LanceEvent не найдена точка K" +
                                                                                       pointLi[iIdxInPointLi].iCnvNr +
                                                                                       " BATHLEVELMAN");
                                                                                    }
                                                                                 }
                                                                              else {
                                                                                 AddLogg(
                                                                                    "При LanceEvent не найдена точка K" +
                                                                                    pointLi[iIdxInPointLi].iCnvNr +
                                                                                    " GEWBAER_R");
                                                                                 }
                                                                              }
                                                                           else {
                                                                              AddLogg(
                                                                                 "При LanceEvent не найдена точка K" +
                                                                                 pointLi[iIdxInPointLi].iCnvNr +
                                                                                 " GEWLANCE_R");
                                                                              }
                                                                           }
                                                                        else {
                                                                           AddLogg("При LanceEvent не найдена точка K" +
                                                                                   pointLi[iIdxInPointLi].iCnvNr +
                                                                                   " GEWBAER_L");
                                                                           }
                                                                        bErg = true;
                                                                        }
                                                                     else {
                                                                        AddLogg("При LanceEvent не найдена точка K" +
                                                                                pointLi[iIdxInPointLi].iCnvNr +
                                                                                " GEWLANCE_L");
                                                                        }
                                                                     }
                                                                  else {
                                                                     AddLogg("При LanceEvent не найдена точка K" +
                                                                             pointLi[iIdxInPointLi].iCnvNr +
                                                                             " TWASSAB_R");
                                                                     }
                                                                  }
                                                               else {
                                                                  AddLogg("При LanceEvent не найдена точка K" +
                                                                          pointLi[iIdxInPointLi].iCnvNr + " TWASSZU_R");
                                                                  }
                                                               }
                                                            else {
                                                               AddLogg("При LanceEvent не найдена точка K" +
                                                                       pointLi[iIdxInPointLi].iCnvNr + " QWASSAB_R");
                                                               }
                                                            }
                                                         else {
                                                            AddLogg("При LanceEvent не найдена точка K" +
                                                                    pointLi[iIdxInPointLi].iCnvNr + " QWASSZU_R");
                                                            }
                                                         }
                                                      else {
                                                         AddLogg("При LanceEvent не найдена точка K" +
                                                                 pointLi[iIdxInPointLi].iCnvNr + " PWASS_R");
                                                         }
                                                      }
                                                   else {
                                                      AddLogg("При LanceEvent не найдена точка K" +
                                                              pointLi[iIdxInPointLi].iCnvNr + " PWASS_L");
                                                      }
                                                   }
                                                else {
                                                   AddLogg("При LanceEvent не найдена точка K" +
                                                           pointLi[iIdxInPointLi].iCnvNr + " LECK_R");
                                                   }
                                                }
                                             else {
                                                AddLogg("При LanceEvent не найдена точка K" +
                                                        pointLi[iIdxInPointLi].iCnvNr + " LECK_L");
                                                }
                                             }
                                          else {
                                             AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr +
                                                     " TWASSAB_L");
                                             }
                                          }
                                       else {
                                          AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr +
                                                  " TWASSZU_L");
                                          }
                                       }
                                    else {
                                       AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr +
                                               " QWASSAB_L");
                                       }
                                    }
                                 else {
                                    AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr +
                                            " QWASSZU_L");
                                    }
                                 }
                              else {
                                 AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr +
                                         " OPO2FLOW");
                                 }
                              }
                           else {
                              AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr + " OPLANCE");
                              }
                           }
                        else {
                           AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr + " O2PRESSURE");
                           }
                        }
                     else {
                        AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr + " O2FLOW");
                        }
                     }
                  else {
                     AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr + " O2VOL_TOTAL");
                     }
                  }
               else {
                  AddLogg("При LanceEvent не найдена точка K" + pointLi[iIdxInPointLi].iCnvNr + " LANCEPOS");
                  }
               }
            catch (Exception eXc) {
               sLfdEvtErr = eXc.Message;
               AddLogg("При LanceEvent K" + pointLi[iIdxInPointLi].iCnvNr + " Exception: " + eXc.Message);
               }
            }
             return bErg;
        }
        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;
                }
            }
        }