Beispiel #1
0
        private void WriteDataToPLC(LTEC_Input obj)
        {
            try
            {
                DBObjects.Scarf_Input Scarf_Input = new DBObjects.Scarf_Input();
                Scarf_Input.ParseDBInformation(obj);

                _client._plcConnection.Write(Scarf_Input);
                _client._plcConnection.WriteBoolean("DB562.DBX 2.0", true);
            }
            catch (Exception ex)
            {
                ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
Beispiel #2
0
            //[PlcMember("DB562.DBD 74.0")]
            //public float Depth_Top = 0;

            //[PlcMember("DB562.DBD 78.0")]
            //public float Depth_Bottom = 0;

            //[PlcMember("DB562.DBD 82.0")]
            //public float Depth_Top_Fixed = 0;

            //[PlcMember("DB562.DBD 86.0")]
            //public float Depth_Top_Float = 0;

            //[PlcMember("DB562.DBD 90.0")]
            //public float Depth_Bottom_Fixed = 0;

            //[PlcMember("DB562.DBD 94.0")]
            //public float Depth_Bottom_Float = 0;

            //[PlcMember("DB562.DBD 98.0")]
            //public float Depth_Top_Edge = 0;

            //[PlcMember("DB562.DBD 102.0")]
            //public float Depth_Bottom_Edge = 0;

            //[PlcMember("DB562.DBW 110.0")]
            //public short Preheat_Time = 0;

            //[PlcMember("DB562.DBD 112.0")]
            //public float Scarf_Speed = 0;

            //[PlcMember("DB562.DBD 116.0")]
            //public float OST = 0;

            //[PlcMember("DB562.DBD 120.0")]
            //public float OSB = 0;

            //[PlcMember("DB562.DBD 124.0")]
            //public float OSTFX = 0;

            //[PlcMember("DB562.DBD 128.0")]
            //public float OSTFL = 0;

            //[PlcMember("DB562.DBD 132.0")]
            //public float OSBFX = 0;

            //[PlcMember("DB562.DBD 136.0")]
            //public float OSBFL = 0;

            //[PlcMember("DB562.DBD 140.0")]
            //public float OSTE = 0;

            //[PlcMember("DB562.DBD 144.0")]
            //public float OSBE = 0;

            public void ParseDBInformation(LTEC_Input obj)
            {
                try
                {
                    this.Mat_ID              = obj.Mat_ID.ToCharArray();
                    this.Mat_Grade           = obj.Mat_Grade.ToCharArray();
                    this.Steel_Group_ID      = obj.Steel_Group_ID.ToCharArray();
                    this.Mat_Length          = obj.Mat_Length;
                    this.Mat_Thickness       = obj.Mat_Thickness;
                    this.Mat_Width_Head      = obj.Mat_Width_Head;
                    this.Mat_Width_Tail      = obj.Mat_Width_Tail;
                    this.Preheat_Pos         = obj.Preheat_Pos;
                    this.Oper_Mode_Code      = obj.Oper_Mode_Code;
                    this.Pattern_Code        = obj.Pattern_Code;
                    this.Pattern_Depth_Base  = obj.Pattern_Depth_Base;
                    this.Pattern_Depth_Heavy = obj.Pattern_Depth_Heavy;
                    //this.Depth_Top = obj.Depth_Top;
                    //this.Depth_Bottom = obj.Depth_Bottom;
                    //this.Depth_Top_Fixed = obj.Depth_Top_Fixed;
                    //this.Depth_Top_Float = obj.Depth_Top_Float;
                    //this.Depth_Bottom_Fixed = obj.Depth_Bottom_Fixed;
                    //this.Depth_Bottom_Float = obj.Depth_Bottom_Float;
                    //this.Depth_Top_Edge = obj.Depth_Top_Edge;
                    //this.Depth_Bottom_Edge = obj.Depth_Bottom_Edge;
                    //this.Preheat_Time = obj.Preheat_Time;
                    //this.Scarf_Speed = obj.Scarf_Speed;
                    //this.OST = obj.OST;
                    //this.OSB = obj.OSB;
                    //this.OSTFX = obj.OSTFX;
                    //this.OSTFL = obj.OSTFL;
                    //this.OSBFX = obj.OSBFX;
                    //this.OSBFL = obj.OSBFL;
                    //this.OSTE = obj.OSTE;
                    //this.OSBE = obj.OSBE;
                }
                catch (Exception ex)
                {
                    ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
                }
            }
Beispiel #3
0
        private void ProcessDB()
        {
            try
            {
                //check reference of DB object _cmdSel
                if (bDBConnected == true && _cmdSel == null)
                {
                    bDBConnected = false;
                }

                //if not connected return
                if (bDBConnected == false)
                {
                    return;
                }

                if (!mre_dependency.IsSet)
                {
                    mre_dependency.Wait();
                }

                mre_dependency.Reset();
                mre_dependency_backup.Set();

                //read TQS dataset with status between X and 0
                using (OracleDataReader dr = _cmdSel.ExecuteReader(CommandBehavior.Default))
                {
                    do
                    {
                        while (dr.Read())
                        {
                            int iPKID         = dr.GetOracleDecimal(0).ToInt32(),
                                iStatus       = dr.GetOracleDecimal(8).ToInt32();
                            string sMessageID = dr.GetOracleString(4).ToString();

                            UpdateTQS(iPKID, 2, _sSelectedTable);

                            string     sMessage = string.Empty;
                            OracleBlob blob     = null;

                            //get the actual message to send
                            blob     = dr.GetOracleBlob(9);
                            sMessage = Encoding.UTF8.GetString(blob.Value);

                            //parse the included informations
                            switch (sMessageID)
                            {
                            case "OPC_01":
                                OPC_New_Lock_Request New_Lock_Request = new OPC_New_Lock_Request();
                                New_Lock_Request.ParseTelegraminformation(sMessage);
                                if (!CheckFlagDB(TelegramType.Lock_Request))
                                {
                                    WriteDataToPLC(New_Lock_Request);
                                    Thread.Sleep(_iTimer);
                                    if (CheckFlagDB(TelegramType.Lock_Request))
                                    {
                                        UpdateTQS(iPKID, -9, _sSelectedTable);
                                        ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": DB not processed after being written.");
                                    }
                                    else
                                    {
                                        UpdateTQS(iPKID, 1, _sSelectedTable);
                                        ServiceBaseX._logger.Log(Category.Info, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": OPC_01 Information successfully updated to DB.");
                                    }
                                }
                                else
                                {
                                    UpdateTQS(iPKID, -9, _sSelectedTable);
                                    ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": DB not ready to be written at all. (OPC_01)");
                                }
                                break;

                            case "OPC_02":
                                OPC_CTS_Lift_Drop CTS_Lift_Drop = new OPC_CTS_Lift_Drop();
                                CTS_Lift_Drop.ParseTelegraminformation(sMessage);
                                if (!CheckFlagDB(TelegramType.CTS_Lift_Drop))
                                {
                                    WriteDataToPLC(CTS_Lift_Drop);
                                    Thread.Sleep(_iTimer);
                                    if (CheckFlagDB(TelegramType.CTS_Lift_Drop))
                                    {
                                        UpdateTQS(iPKID, -9, _sSelectedTable);
                                        ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": DB not processed after being written.");
                                    }
                                    else
                                    {
                                        UpdateTQS(iPKID, 1, _sSelectedTable);
                                        ServiceBaseX._logger.Log(Category.Info, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": OPC_02 Information successfully updated to DB.");
                                    }
                                }
                                else
                                {
                                    UpdateTQS(iPKID, -9, _sSelectedTable);
                                    ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": DB not ready to be written at all. (OPC_02)");
                                }
                                break;

                            case "OPC_03":
                                OPC_New_Target New_Target = new OPC_New_Target();
                                New_Target.ParseTelegraminformation(sMessage);
                                if (!CheckFlagDB(TelegramType.New_Target))
                                {
                                    WriteDataToPLC(New_Target);
                                    Thread.Sleep(_iTimer);
                                    if (CheckFlagDB(TelegramType.New_Target))
                                    {
                                        UpdateTQS(iPKID, -9, _sSelectedTable);
                                        ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": DB not processed after being written.");
                                    }
                                    else
                                    {
                                        UpdateTQS(iPKID, 1, _sSelectedTable);
                                        ServiceBaseX._logger.Log(Category.Info, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": OPC_03 Information successfully updated to DB.");
                                    }
                                }
                                else
                                {
                                    UpdateTQS(iPKID, -9, _sSelectedTable);
                                    ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": DB not ready to be written at all. (OPC_03)");
                                }
                                break;

                            case "LTEC01":
                                LTEC_Input LTEC_Input = new LTEC_Input();
                                LTEC_Input.ParseTelegramBody(sMessage);
                                if (!CheckFlagDB(TelegramType.New_Slab_Scarfing))
                                {
                                    WriteDataToPLC(LTEC_Input);
                                    Thread.Sleep(_iTimer);
                                    if (CheckFlagDB(TelegramType.New_Slab_Scarfing))
                                    {
                                        UpdateTQS(iPKID, -9, _sSelectedTable);
                                        ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": DB not processed after being written.");
                                    }
                                    else
                                    {
                                        UpdateTQS(iPKID, 1, _sSelectedTable);
                                        ServiceBaseX._logger.Log(Category.Info, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": LTEC Information successfully updated to DB.");
                                    }
                                }
                                else
                                {
                                    UpdateTQS(iPKID, -9, _sSelectedTable);
                                    ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": DB not ready to be written at all. (LTEC)");
                                }
                                break;

                            default:
                                ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": unknown MessageID.");
                                break;
                            }
                        }
                    } while (dr.NextResult());
                }
                mre_dependency.Set();
            }
            catch (Exception ex)
            {
                ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }