Пример #1
0
        public static bool PeriodBakingZeroTimer(int devicenumber)
        {
            try
            {
                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Update_Zero_Autoclav", cn);

                cmd.Parameters.AddWithValue("intTimeStart", Convert.ToInt32(Varibale.Status_Baking[devicenumber]));

                cmd.Parameters.AddWithValue("intTimezero", PublicMehotd.time_php());

                cmd.Parameters.AddWithValue("timezero", PublicMehotd.RetStringLocalTime());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.baking.ToString());

                cmd.Parameters.AddWithValue("dev_no", devicenumber);

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();



                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-baking-zero timer");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.updatePeriodAutoclavZeroError);
                return(false);
            }
        }
Пример #2
0
        private void NewLogInsertToDatabase()
        {
            try
            {
                SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_Log_New", cn);

                cmd.Parameters.AddWithValue("dev_no", DeviceNumber);
                cmd.Parameters.AddWithValue("kind", Kind.ToString());
                cmd.Parameters.AddWithValue("comment", classEnumLog.ShowError(Type));
                cmd.Parameters.AddWithValue("level", Level.ToString());
                cmd.Parameters.AddWithValue("intTime", (Convert.ToInt32(PublicMehotd.time_php()) + Sec));
                cmd.Parameters.AddWithValue("datep", PublicMehotd.RetStringPersianCalender());
                cmd.Parameters.AddWithValue("timep", PublicMehotd.RetStringLocalTime(Sec));
                cmd.Parameters.AddWithValue("datetimep", PublicMehotd.retStringShowDatetime());
                cmd.Parameters.AddWithValue("value", Val);
                cmd.Parameters.AddWithValue("yearp", PublicMehotd.retStringYearPersian());
                cmd.Parameters.AddWithValue("monthp", PublicMehotd.retStringMonthPersian());
                cmd.Parameters.AddWithValue("dayp", PublicMehotd.retStringDayPersian());

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();
            }
            catch (Exception ex)
            {
                //Enum.ClassEnumError.ShowErrorInMessageBox(EnumError.insertNewLogProbel);
                log_system.saveLogSystem(ex, "log_manager insert");
            }
        }
 private void setToDatabase(int i, double new_val, double old_val, string updateVar)
 {
     if (new_val != old_val)
     {
         PublicMehotd.SetDataToDatabase(updateVar, new_val.ToString());
     }
 }
Пример #4
0
        public static void ReadFromOil()
        {
            int number = Varibale.oil_number - 1;

            try
            {
                if (Varibale.Status_Active_Oil)
                {
                    //MessageBox.Show(number.ToString());
                    CreateSerialPort.serialPort_1.Write(DeviceString.WriteDevice[number], 0, DeviceString.WriteDevice[number].Length);
                    string readSTR  = CreateSerialPort.serialPort_1.ReadLine();
                    char[] arraySTR = readSTR.ToCharArray();

                    string address = arraySTR[1].ToString() + arraySTR[2].ToString();
                    string reder   = arraySTR[7].ToString() + arraySTR[8].ToString() + arraySTR[9].ToString() + arraySTR[10].ToString();
                    string greener = arraySTR[11].ToString() + arraySTR[12].ToString() + arraySTR[13].ToString() + arraySTR[14].ToString();

                    float fReadDevice = PublicMehotd.hextoFloat(reder);

                    Check_temp_oil(fReadDevice);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "roghan-error-read");
                Oil_deactive();
                if (CreateSerialPort.serialPort_1.IsOpen)
                {
                    CreateSerialPort.serialPort_1.Close();
                    CreateSerialPort.serialPort_1.Dispose();
                }
            }
        }
Пример #5
0
        public bool PeriodAutoclavStart()
        {
            try
            {
                string timeStartAutoclav = PublicMehotd.time_php();

                //MessageBox.Show((Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString() + " X " + timeStartAutoclav);

                Varibale.Status_Autoclav[Dev_no] = (Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString();

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_start_New_Period", cn);

                cmd.Parameters.AddWithValue("dev_no", Dev_no);

                cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.start.ToString());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.autoclav.ToString());

                cmd.Parameters.AddWithValue("intTimestart", (Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString());

                cmd.Parameters.AddWithValue("intTimeend", 0);

                cmd.Parameters.AddWithValue("timestart", PublicMehotd.RetStringLocalTime(-1 * Varibale.Timer_Autoclav[Dev_no]));

                cmd.Parameters.AddWithValue("timeend", "00:00:00");

                cmd.Parameters.AddWithValue("date", PublicMehotd.RetStringPersianCalender());

                cmd.Parameters.AddWithValue("year", PublicMehotd.retStringYearPersian());

                cmd.Parameters.AddWithValue("month", PublicMehotd.retStringMonthPersian());

                cmd.Parameters.AddWithValue("day", PublicMehotd.retStringDayPersian());

                cmd.Parameters.AddWithValue("intTimezero", "0");

                cmd.Parameters.AddWithValue("timezero", "00:00:00");

                cmd.Parameters.AddWithValue("time_st", Varibale.Data_Timer_Max[Dev_no].ToString());

                cmd.Parameters.AddWithValue("temp_low_st", Varibale.Data_Temp_Min[Dev_no]);

                cmd.Parameters.AddWithValue("temp_high_st", Varibale.Data_Temp_Max[Dev_no]);

                cmd.Parameters.AddWithValue("pres_st", Varibale.Data_Pres_Min[Dev_no]);

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();

                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-start-autoclav");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewstartautoclavinsertdatabaseerror);
                return(false);
            }
        }
Пример #6
0
        public static string ConvertEnumStringTOpersianName(string name)
        {
            Enum.EnumKindDevice kind = PublicMehotd.RetStringConvertToEnumKind(name.Trim());

            switch (kind)
            {
            case Enum.EnumKindDevice.autoclav:
                return("اتوکلاو");

            case Enum.EnumKindDevice.baking:
                return("پخت");

            case Enum.EnumKindDevice.frig_1:
                return("دماسنج 1");

            case Enum.EnumKindDevice.frig:
                return("دماسنج ");

            case Enum.EnumKindDevice.frig_2:
                return("دماسنج 2");

            case Enum.EnumKindDevice.oil:
                return("روغن ریز");

            default:
                return("سیستم");
            }
        }
Пример #7
0
        private long createStringFromChar(int start, int end, char[] strarray)
        {
            string str = "";

            for (int i = start; i <= end; i++)
            {
                str = str + strarray[i].ToString();
            }

            return(PublicMehotd.convertHextoInt(str));
        }
Пример #8
0
        public static void processData(string element)
        {
            // :020310 000C000100020000002B0001000F0001A0
            //:010310C9FF3B9A01F4000000130000CD15075B03
            char[] strarray = element.ToCharArray();

            //c1
            string counter11 = strarray[7].ToString() + strarray[8].ToString() + strarray[9].ToString() + strarray[10].ToString();
            string counter12 = strarray[11].ToString() + strarray[12].ToString() + strarray[13].ToString() + strarray[14].ToString();
            Int64  c12       = PublicMehotd.convertHextoInt(counter12 + counter11);

            //c2
            string counter21 = strarray[15].ToString() + strarray[16].ToString() + strarray[17].ToString() + strarray[18].ToString();
            string counter22 = strarray[19].ToString() + strarray[20].ToString() + strarray[21].ToString() + strarray[22].ToString();
            Int64  c22       = PublicMehotd.convertHextoInt(counter22 + counter21);

            //c3
            string counter31 = strarray[23].ToString() + strarray[24].ToString() + strarray[25].ToString() + strarray[26].ToString();
            string counter32 = strarray[27].ToString() + strarray[28].ToString() + strarray[29].ToString() + strarray[30].ToString();
            Int64  c32       = PublicMehotd.convertHextoInt(counter32 + counter31);

            //c4
            string counter41 = strarray[31].ToString() + strarray[32].ToString() + strarray[33].ToString() + strarray[34].ToString();
            string counter42 = strarray[35].ToString() + strarray[36].ToString() + strarray[37].ToString() + strarray[38].ToString();
            Int64  c42       = PublicMehotd.convertHextoInt(counter42 + counter41);


            //MessageBox.Show(c12.ToString() + " " + c22.ToString() + " " + c32.ToString() + " " + c42.ToString());

            //frmIndex.counter[1].Text = c12.ToString();
            zarinReport.proccessCount(1, Convert.ToInt64(c12));

            //frmIndex.counter[2].Text = c22.ToString();
            zarinReport.proccessCount(2, Convert.ToInt64(c22));

            //frmIndex.counter[3].Text = c32.ToString();
            zarinReport.proccessCount(3, Convert.ToInt64(c32));

            //frmIndex.counter[4].Text = c42.ToString();
            zarinReport.proccessCount(4, Convert.ToInt64(c42));

            if (DeviceCounter.Save_data == DeviceCounter.save_max)
            {
                DeviceCounter.InsertToDatabase(1, Enum.EnumTypeData.count, Enum.EnumKindDevice.counter, c12);
                DeviceCounter.InsertToDatabase(2, Enum.EnumTypeData.count, Enum.EnumKindDevice.counter, c22);
                DeviceCounter.InsertToDatabase(3, Enum.EnumTypeData.count, Enum.EnumKindDevice.counter, c32);
                DeviceCounter.InsertToDatabase(4, Enum.EnumTypeData.count, Enum.EnumKindDevice.counter, c42);
                DeviceCounter.Save_data = 0;
            }
            else
            {
                DeviceCounter.Save_data = DeviceCounter.Save_data + 1;
            }
        }
Пример #9
0
        public static void ReadFromFrig(int devicenumber)
        {
            int number = Varibale.frig_number[devicenumber] - 1;

            try
            {
                if (Varibale.Status_Active_Frig[devicenumber])
                {
                    CreateSerialPort.serialPort_1.Write(DeviceString.WriteDevice[number], 0, DeviceString.WriteDevice[number].Length);

                    string readSTR = CreateSerialPort.serialPort_1.ReadLine();

                    char[] arraySTR = readSTR.ToCharArray();

                    string address = arraySTR[1].ToString() + arraySTR[2].ToString();
                    int    nn      = number + 1;
                    int    add     = Int16.Parse(address, System.Globalization.NumberStyles.HexNumber);


                    if (nn.ToString() == add.ToString())
                    {
                        string reder   = arraySTR[7].ToString() + arraySTR[8].ToString() + arraySTR[9].ToString() + arraySTR[10].ToString();
                        string greener = arraySTR[11].ToString() + arraySTR[12].ToString() + arraySTR[13].ToString() + arraySTR[14].ToString();

                        float fReadDevice = PublicMehotd.hextoFloat(reder);

                        if (fReadDevice != 0 && fReadDevice.ToString("00.0") != "00.0")
                        {
                            Varibale.Frig_Temp[devicenumber] = fReadDevice;


                            Check_temp_frig(fReadDevice, devicenumber);
                            Varibale.Error_frig[devicenumber] = 0;

                            if (Save_data_frig == 0)
                            {
                                InsertToDatabase(devicenumber, Enum.EnumTypeData.temp, Enum.EnumKindDevice.frig, Varibale.Frig_Temp[devicenumber]);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CreateSerialPort.CLOSESERIAL("frig_error_read", "frig");
                log_system.saveLogSystem(ex, "frig-error-read");
                Varibale.Error_frig[devicenumber]++;

                if (Varibale.Error_frig[devicenumber] % 10 == 0)
                {
                    LogManager log = new LogManager(devicenumber, Enum.EnumKindDevice.frig, Enum.EnumLevel.high, Enum.EnumLOg.Frig_Connection_error, "خطا شماره " + (Varibale.Error_frig[devicenumber] / 10));
                }
            }
        }
Пример #10
0
        public bool PeriodBakingStart()
        {
            try
            {
                string timeStartBaking = PublicMehotd.time_php();

                Varibale.Status_Baking[Dev_no] = timeStartBaking.ToString();

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_start_New_Period", cn);

                cmd.Parameters.AddWithValue("dev_no", Dev_no);

                cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.start.ToString());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.baking.ToString());

                cmd.Parameters.AddWithValue("intTimestart", timeStartBaking);

                cmd.Parameters.AddWithValue("intTimeend", 0);

                cmd.Parameters.AddWithValue("timestart", PublicMehotd.RetStringLocalTime());

                cmd.Parameters.AddWithValue("timeend", "00:00:00");

                cmd.Parameters.AddWithValue("date", PublicMehotd.RetStringPersianCalender());

                cmd.Parameters.AddWithValue("year", PublicMehotd.retStringYearPersian());

                cmd.Parameters.AddWithValue("month", PublicMehotd.retStringMonthPersian());

                cmd.Parameters.AddWithValue("day", PublicMehotd.retStringDayPersian());

                cmd.Parameters.AddWithValue("intTimezero", "0");

                cmd.Parameters.AddWithValue("timezero", "00:00:00");

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();



                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-baking-start");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewstartautoclavinsertdatabaseerror);
                return(false);
            }
        }
Пример #11
0
        public static bool InsertToDatabase(int devicenumber, Enum.EnumTypeData type, Enum.EnumKindDevice kind, double value)
        {
            try
            {
                Boolean check = true;

                if (check)
                {
                    SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                    SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_Data_new", cn);

                    cmd.Parameters.AddWithValue("dev_no", devicenumber);
                    cmd.Parameters.AddWithValue("type", type.ToString());
                    cmd.Parameters.AddWithValue("kind", kind.ToString());
                    cmd.Parameters.AddWithValue("value", value);
                    cmd.Parameters.AddWithValue("intTime", PublicMehotd.time_php());
                    cmd.Parameters.AddWithValue("datep", PublicMehotd.RetStringPersianCalender());
                    cmd.Parameters.AddWithValue("timep", PublicMehotd.RetStringLocalTime());
                    cmd.Parameters.AddWithValue("yearp", PublicMehotd.retStringYearPersian());
                    cmd.Parameters.AddWithValue("monthp", PublicMehotd.retStringMonthPersian());
                    cmd.Parameters.AddWithValue("dayp", PublicMehotd.retStringDayPersian());
                    cmd.Parameters.AddWithValue("datetimep", Convert.ToDouble(PublicMehotd.retStringShowDatetime()));

                    cn.Open();
                    object obj = cmd.ExecuteScalar();
                    cn.Close();

                    if (Autoclav.sendServer_count == Varibale.save_count_autoclav_server)
                    {
                        Autoclav.sendServer_count = 0;
                    }
                    else
                    {
                        Autoclav.sendServer_count++;
                    }


                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "autoclav-insert database");
                //Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewDatalogforautoclav);
                return(false);
            }
        }
Пример #12
0
        private static void closeAllRcord(int num)
        {
            string sql = "update zarin_report_counter set status = 'end' ,timeEnd='" + PublicMehotd.RetStringLocalTime()
                         + "' , intTimeEnd = '" + PublicMehotd.time_php() + "'  where counter_num = " + num + " and  status = 'counts' ";

            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();

            removeNumberZero(num);
        }
Пример #13
0
        public static void saveLogMsg(string msg)
        {
            string filepath = @"c:\log_monitoring\";
            string filename = PublicMehotd.RetStringPersianCalenderwithDash() + "-" + DateTime.Now.Hour.ToString("00") + ".txt";

            checkFileAndFolder(filename);

            using (System.IO.StreamWriter file =
                       File.AppendText(filepath + filename))
            {
                file.WriteLine("\n msg = " + msg);
                file.WriteLine("\n datep = " + PublicMehotd.RetStringPersianCalender());
                file.WriteLine("\n timep = " + PublicMehotd.RetStringLocalTime());
            }
        }
Пример #14
0
 public static bool DisconnectToDeviceSerialPort()
 {
     if (CreateSerialPort.CloseSerialPort_1())
     {
         //ManageTimer.tmrFromDevice.Stop();
         //ShowMessage.Text = "قطع اتصال با موفقیت انجام شد";
         //frmIndex.st_lbl_comment.Text = "عدم ارتباط";
         PublicMehotd.DeactiveAllDevice();
         return(true);
     }
     else
     {
         //ShowMessage.Text = "قادر به قطع اتصال نیست";
         return(false);
     }
 }
Пример #15
0
        private static string[] calculateLastData(int id, Int64 number, string[] RecordData)
        {
            string NOWEND = PublicMehotd.time_php();

            //string[] RecordData = getRecordReportProduct(id);
            string intTimeEnd  = RecordData[9];
            string Counter_num = RecordData[10];
            string timeEnd     = RecordData[12];

            string[] x   = new string[10];
            string   sql = "";

            try
            {
                sql = "select top 1  * from Data where type = 'count' and device_no = '" + Counter_num
                      + "' and intTime < '" + NOWEND + "' and value in ( select  top 1 value from Data where type = 'count' and device_no = '" + Counter_num
                      + "'and intTime < '" + NOWEND + "'  order by id desc ) order by id asc";

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();

                if (dr.Read())
                {
                    x[0] = dr["intTime"].ToString();
                    x[1] = dr["timep"].ToString();


                    cn.Close();
                    return(x);
                }
                else
                {
                    x[0] = PublicMehotd.time_php();
                    x[1] = PublicMehotd.RetStringLocalTime();
                    cn.Close();
                    return(x);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "zarin report end  record last data=" + sql);
                return(null);
            }
        }
Пример #16
0
 private void checkChange(string type, string var, string val)
 {
     try
     {
         if (Varibale.zarin[var + "_" + type] != val)
         {
             sendLogChangeData(type, var, Varibale.zarin[var + "_" + type], val);
             PublicMehotd.SetDataToDatabase(var + "_" + type, val);
             Varibale.zarin[var + "_" + type] = val;
             zeroSet = true;
         }
     }
     catch (Exception ex)
     {
         log_system.saveLogSystem(ex, "zarin check change");
     }
 }
Пример #17
0
        private static void newRecord(int num, Int64 number)
        {
            zarinReport.closeAllRcord(num);

            string type = "";

            if (num == 1 || num == 2)
            {
                type = "ghabl";
            }
            else
            {
                type = "bad";
            }

            string sql = "insert into zarin_report_counter" +
                         " (status , intTimeStart , intTimeEnd, timeStart, timeEnd , datep  , yearp , monthp , dayp , number , zarin_product , brand , vazn , baste_bandi , darb , counter_num )" +
                         " values " +
                         " ('counts' , '" +
                         PublicMehotd.time_php() + "' , '0' , '" +
                         PublicMehotd.RetStringLocalTime() + "' , '00:00:00' , '" +
                         PublicMehotd.RetStringPersianCalender() + "' , '" +
                         PublicMehotd.retStringYearPersian() + "' , '" +
                         PublicMehotd.retStringMonthPersian() + "' , '" +
                         PublicMehotd.retStringDayPersian() + "' , '" +
                         number.ToString() + "' , '" +
                         ClassEnumProduct.getProductZarinNumber(Convert.ToInt64(Varibale.zarin["zarin_product_" + type]))
                         + "' , '" +
                         Varibale.zarin["brand_" + type]
                         + "' , '" +
                         Varibale.zarin["vazn_" + type]
                         + "' ,  '" +
                         Varibale.zarin["baste_bandi_" + type]
                         + "' , '" +
                         Varibale.zarin["darb_" + type]
                         + "' , '" +
                         num.ToString()
                         + "')";

            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();
        }
Пример #18
0
        public static bool PeriodAutoclavNaghes(int deviceNumber)
        {
            try
            {
                if (Varibale.Status_Autoclav[deviceNumber] != "")
                {
                    SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                    SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Update_End_autoclav", cn);

                    cmd.Parameters.AddWithValue("intTimeStart", Varibale.Status_Autoclav[deviceNumber]);

                    cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.autoclav.ToString());

                    cmd.Parameters.AddWithValue("dev_no", deviceNumber);

                    cmd.Parameters.AddWithValue("intTimeend", PublicMehotd.time_php());

                    cmd.Parameters.AddWithValue("timeend", PublicMehotd.RetStringLocalTime());

                    cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.naghes.ToString());

                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();



                    Varibale.Status_Autoclav[deviceNumber] = "";

                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-autoclav naghes");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.updatePeriodAutoclavEndNaghes);
                return(false);
            }
        }
Пример #19
0
        private long createStringFromChar(int numberdata, char[] strarray)
        {
            //410 - 403 = 7
            //411 - 400 = 11
            //412 - 397 = 15

            int num = numberdata - 410;

            int start = 7 + (4 * num);
            int end   = start + 3;
            //MessageBox.Show(start+" X "+end+" X "+strarray.Length);
            string str = "";

            for (int i = start; i <= end; i++)
            {
                str = str + strarray[i].ToString();
            }

            return(PublicMehotd.convertHextoInt(str));
        }
Пример #20
0
        public static void getShostesho()
        {
            try {
                string x = PLC.Read("010108C80002", "shostesho");
                //sample return :010101C 9 34
                // shostesho mikonan 9

                char[] strarray   = x.ToCharArray();
                string typenumber = strarray[7].ToString() + strarray[8].ToString();
                int    value      = Convert.ToInt16(PublicMehotd.convertHextoInt(typenumber));
                string binary     = Convert.ToString(value, 2);

                char[] binaryArray = binary.ToCharArray();

                if (binary[6] == '0')
                {
                    PublicMehotd.SetDataToDatabase("shostesho_bad", "0");
                }
                else
                {
                    PublicMehotd.SetDataToDatabase("shostesho_bad", "1");
                }

                if (binary[7] == '0')
                {
                    PublicMehotd.SetDataToDatabase("shostesho_ghabl", "0");
                }
                else
                {
                    PublicMehotd.SetDataToDatabase("shostesho_ghabl", "1");
                }


                //if(typenumber == '')
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                log_system.saveLogSystem(ex, "shostesho");
            }
        }
Пример #21
0
        private static void updateRecord(int id, Int64 number, string status)
        {
            string[] RecordData   = getRecordReportProduct(id);
            string   statusUpdate = RecordData[17];

            try {
                if (status == "end")
                {
                    endRecord(id, number, RecordData);
                }
                else
                {
                    string intTimeEnd      = "0";
                    string timeEnd         = "00:00:00";
                    string timeUpdateQuery = ", timeUpdate = '" + PublicMehotd.RetStringLocalTime() + "' ";
                    string sql             = "update zarin_report_counter set status = '" + status
                                             + "' , number = '" + number
                                             + "' , intTimeEnd = '" + intTimeEnd
                                             + "' , timeEnd = '" + timeEnd
                                             + "' " + timeUpdateQuery
                                             + " where id = " + id + " ";

                    SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                    SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();

                    if (number > 1000 && statusUpdate == "0")
                    {
                        updateFirstData(id, RecordData);
                    }
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "zarin report update record ");
            }
        }
Пример #22
0
        public static bool CloseSerialPort_1()
        {
            try
            {
                serialPort_1.Close();
                serialPort_1.Dispose();

                if (!(serialPort_1.IsOpen))
                {
                    PublicMehotd.DeactiveAllDevice();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ClassEnumError.ShowErrorInMessageBox(EnumError.closeportproblem);
                log_system.saveLogSystem(ex, "serialport-close");
                return(false);
            }
        }
Пример #23
0
        public static void SetFromDatabaseToVarible()
        {
            try
            {
                SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Select_All_Varible", cn);

                cn.Open();

                SqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    try
                    {
                        switch (dr["name"].ToString())
                        {
                        case "Autoclav_temp_max":
                            Varibale.Autoclav_Temp_High = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Autoclav_temp_min":
                            Varibale.Autoclav_Temp_Low = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Autoclav_pres_max":
                            Varibale.Autoclav_Pres_high = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Autoclav_pres_min":
                            Varibale.Autoclav_Pres_Low = Convert.ToDouble(dr["value"].ToString());// 0.2 => error
                            break;

                        case "Autoclav_timer_max":
                            Varibale.Autoclav_Timer_max = Convert.ToInt32(dr["value"].ToString());
                            break;


                        case "Baking_temp_max":
                            Varibale.Baking_Temp_High = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Baking_temp_min":
                            Varibale.Baking_Temp_Low = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Baking_pres_max":
                            Varibale.Baking_Pres_high = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Baking_pres_min":
                            Varibale.Baking_Pres_Low = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Baking_timer_max":
                            Varibale.Baking_Timer_max = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "totalAutoclav":
                            Varibale.totalAutoclav = Convert.ToInt32(dr["value"].ToString()) + 1;
                            break;

                        case "totalBaking":
                            Varibale.totalBaking = Convert.ToInt32(dr["value"].ToString()) + 1;
                            break;

                        case "Frig_1_Temp_High":
                            Varibale.Frig_Temp_High[1] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_1_Temp_Low":
                            Varibale.Frig_Temp_Low[1] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_2_Temp_High":
                            Varibale.Frig_Temp_High[2] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_2_Temp_Low":
                            Varibale.Frig_Temp_Low[2] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_3_Temp_High":
                            Varibale.Frig_Temp_High[3] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_3_Temp_Low":
                            Varibale.Frig_Temp_Low[3] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_4_Temp_High":
                            Varibale.Frig_Temp_High[4] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_4_Temp_Low":
                            Varibale.Frig_Temp_Low[4] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_5_Temp_High":
                            Varibale.Frig_Temp_High[5] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_5_Temp_Low":
                            Varibale.Frig_Temp_Low[5] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Oil_Temp_High":
                            Varibale.Oil_Temp_High = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Oil_Temp_Low":
                            Varibale.Oil_Temp_Low = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "portname1":
                            Varibale.portname1 = dr["value"].ToString();
                            break;

                        case "buadrate1":
                            Varibale.buadrate1 = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "parity1":
                            Varibale.parity1 = PublicMehotd.ConvertStringToParity(dr["value"].ToString());
                            break;

                        case "Frig_1_number":
                            Varibale.frig_number[1] = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "Frig_2_number":
                            Varibale.frig_number[2] = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "Frig_3_number":
                            Varibale.frig_number[3] = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "Frig_4_number":
                            Varibale.frig_number[4] = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "Frig_5_number":
                            Varibale.frig_number[5] = Convert.ToInt32(dr["value"].ToString());
                            break;


                        case "Oil_number":
                            Varibale.oil_number = Convert.ToInt32(dr["value"].ToString());
                            break;



                        case "save_count":
                            Varibale.Save_count = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "save_count_frig":
                            Varibale.Save_count_frig = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "save_count_baking_server":
                            Varibale.save_count_baking_server = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "save_count_autoclav_server":
                            Varibale.save_count_autoclav_server = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "port_counter":
                            Varibale.port_counter = dr["value"].ToString();
                            break;

                        case "zarin_product_ghabl":
                            Varibale.zarin.Add("zarin_product_ghabl", dr["value"].ToString());
                            break;

                        case "zarin_product_bad":
                            Varibale.zarin.Add("zarin_product_bad", dr["value"].ToString());
                            break;

                        case "brand_ghabl":
                            Varibale.zarin.Add("brand_ghabl", dr["value"].ToString());
                            break;

                        case "brand_bad":
                            Varibale.zarin.Add("brand_bad", dr["value"].ToString());
                            break;

                        case "vazn_ghabl":
                            Varibale.zarin.Add("vazn_ghabl", dr["value"].ToString());
                            break;

                        case "vazn_bad":
                            Varibale.zarin.Add("vazn_bad", dr["value"].ToString());
                            break;

                        case "baste_bandi_ghabl":
                            Varibale.zarin.Add("baste_bandi_ghabl", dr["value"].ToString());
                            break;

                        case "baste_bandi_bad":
                            Varibale.zarin.Add("baste_bandi_bad", dr["value"].ToString());
                            break;

                        case "darb_ghabl":
                            Varibale.zarin.Add("darb_ghabl", dr["value"].ToString());
                            break;

                        case "darb_bad":
                            Varibale.zarin.Add("darb_bad", dr["value"].ToString());
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        log_system.saveLogSystem(ex, "error read value =" + dr["value"].ToString());
                    }
                }

                cn.Close();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.StackTrace);
                log_system.saveLogSystem(ex, "Variable Error ");
            }
        }
Пример #24
0
        public static void ReadFromAutoclav_old()
        {
            if (Save_data == Varibale.Save_count)
            {
                Save_data = 0;
            }
            else
            {
                Save_data++;
            }


            try
            {
                while (Varibale.i_for_autoclav < ((Varibale.totalAutoclav - 1) * 2) && Varibale.devicenumber_autoclav < Varibale.totalAutoclav)
                {
                    if (Varibale.Active_autoclav[Varibale.devicenumber_autoclav])
                    {
                        Varibale.AutoclavdeviceProblem = Varibale.devicenumber_autoclav;

                        String readerdatafromserialport = ReadData(Varibale.i_for_autoclav);

                        if (readerdatafromserialport != "amir")
                        {
                            float fRedValue = PublicMehotd.hextoFloat(readerdatafromserialport);

                            //adad red gerefte shode
                            if (Varibale.i_for_autoclav % 2 == 0)
                            {
                                Varibale.Data_Temp_autoclav[Varibale.devicenumber_autoclav] = fRedValue;
                                Autoclav_Check_Temp(Varibale.devicenumber_autoclav, Varibale.Data_Temp_autoclav[Varibale.devicenumber_autoclav]);
                            }
                            else
                            {
                                Varibale.Data_Pres_autoclav[Varibale.devicenumber_autoclav] = fRedValue;
                                Autoclav_Check_Pres(Varibale.devicenumber_autoclav, Varibale.Data_Pres_autoclav[Varibale.devicenumber_autoclav]);
                            }


                            if (Varibale.i_for_autoclav % 2 == 1)
                            {
                                if (Varibale.Data_Pres_autoclav[Varibale.devicenumber_autoclav] > Varibale.Autoclav_Pres_Low)
                                {
                                    if (Save_data == 0)
                                    {
                                        InsertToDatabase(Varibale.devicenumber_autoclav, Enum.EnumTypeData.pres, Enum.EnumKindDevice.autoclav, Varibale.Data_Pres_autoclav[Varibale.devicenumber_autoclav]);
                                        InsertToDatabase(Varibale.devicenumber_autoclav, Enum.EnumTypeData.temp, Enum.EnumKindDevice.autoclav, Varibale.Data_Temp_autoclav[Varibale.devicenumber_autoclav]);
                                    }
                                }

                                Autoclav_check_pbx_timer(Varibale.devicenumber_autoclav);
                                Autoclav_Check_For_Timer(Varibale.devicenumber_autoclav);

                                //Varibale.lst_autoclav_temp[Varibale.devicenumber_autoclav - 1].Text = Varibale.Data_Temp_autoclav[Varibale.devicenumber_autoclav].ToString("00.0");
                                //Varibale.lst_autoclav_pres[Varibale.devicenumber_autoclav - 1].Text = Varibale.Data_Pres_autoclav[Varibale.devicenumber_autoclav].ToString("00.0");
                                //Varibale.lst_autoclav_timer[Varibale.devicenumber_autoclav - 1].Text = PublicMehotd.show_time(Varibale.Timer_Autoclav[Varibale.devicenumber_autoclav]);

                                Varibale.Error_autoclav[Varibale.devicenumber_autoclav - 1] = 0;
                                Varibale.devicenumber_autoclav++;
                            }
                        }
                        else
                        {
                            Varibale.devicenumber_autoclav++;
                            Varibale.i_for_autoclav++;
                        }
                    }
                    else
                    {
                        Varibale.devicenumber_autoclav++;
                        Varibale.i_for_autoclav++;
                    }


                    Varibale.i_for_autoclav++;
                }//End while

                Varibale.i_for_autoclav        = 0;
                Varibale.devicenumber_autoclav = 1;
            }
            catch (Exception ex)
            {
                Varibale.Error_autoclav[Varibale.devicenumber_autoclav - 1]++;

                if (Varibale.Error_autoclav[Varibale.devicenumber_autoclav - 1] > 4)
                {
                    LogManager log = new LogManager(Varibale.devicenumber_autoclav, Enum.EnumKindDevice.autoclav, Enum.EnumLevel.urgent, Enum.EnumLOg.Autoclav_Connection_error, "*");
                    DeactiveAutoclav(Varibale.devicenumber_autoclav);
                }
                else if (Varibale.Error_autoclav[Varibale.devicenumber_autoclav - 1] > 3)
                {
                    //Varibale.lst_autoclav_temp[Varibale.devicenumber_autoclav - 1].Text = Varibale.Error_autoclav[Varibale.devicenumber_autoclav - 1].ToString() + ".خطا.";
                    LogManager log = new LogManager(Varibale.devicenumber_autoclav, Enum.EnumKindDevice.autoclav, Enum.EnumLevel.high, Enum.EnumLOg.Autoclav_Connection_error, "خطا شماره " + Varibale.Error_autoclav[Varibale.devicenumber_autoclav - 1]);
                }
                else
                {
                    //Varibale.lst_autoclav_temp[Varibale.devicenumber_autoclav - 1].Text = "--.-";
                }


                if (Varibale.i_for_autoclav % 2 == 1)
                {
                    Varibale.devicenumber_autoclav++;
                    Varibale.i_for_autoclav++;
                }
                else
                {
                    Varibale.devicenumber_autoclav++;
                    Varibale.i_for_autoclav++;
                    Varibale.i_for_autoclav++;
                }

                //MessageBox.Show(ex.Message);
                //Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.readFromAutoclacProblem);
                log_system.saveLogSystem(ex, "autoclav-error-read");
            }
        }