예제 #1
0
        private void btnSendMail_Click(object sender, EventArgs e)
        {
            Util myFunct = new Util();

            //ArrayList myToAL = new ArrayList();
            //String mailTo;

            try
            {
                //mailTo = tbTo.Text;
                //string[] clan1 = mailTo.Split(new char[] { ';' });

                //foreach (string clan in clan1)
                //{
                //    if (clan != string.Empty)
                //    {
                //        myToAL.Add(clan);
                //    }
                //}

                //myFunct.SendMail(tbFrom.Text, tbFromName.Text, myToAL, tbSubject.Text, tbBody.Text);
                myFunct.SendMail(tbFrom.Text, tbFromName.Text, tbTo.Text, tbSubject.Text, tbBody.Text);
                tbSendMail.Text = "Poslat mail.";
            }
            catch (Exception err)
            {
                LogErr.log(err.StackTrace + "++++++++" + err.Message, "btnSendMail_Click");
            }
        }
예제 #2
0
        /// <summary>
        /// Jog
        /// </summary>
        /// <param name="Axis"></param>
        /// <param name="dir"></param>
        /// <param name="JogVel"></param>
        /// <param name="JogAcc"></param>
        /// <param name="JogDcc"></param>
        public void Jog(short Axis, short dir, decimal JogVel, decimal JogAcc, decimal JogDcc)
        {
            //定义Jog运动参数变量
            MC.TJogPrm prfJog = new MC.TJogPrm();
            //将轴设置为Jog模式
            Gts_Return = MC.GT_PrfJog(Axis);
            LogErr?.Invoke("Motion--将轴设置为Jog模式", Gts_Return);
            //读取轴jog运动参数
            Gts_Return = MC.GT_GetJogPrm(Axis, out prfJog);
            LogErr?.Invoke("Motion--读取轴jog运动参数", Gts_Return);

            //设置要修改的参数
            prfJog.acc = Convert.ToDouble(JogAcc / Program.SystemContainer.SysPara.Gts_Acc_reference); //加速度
            prfJog.dec = Convert.ToDouble(JogDcc / Program.SystemContainer.SysPara.Gts_Acc_reference); //减速度

            //设置jog运动参数
            Gts_Return = MC.GT_SetJogPrm(Axis, ref prfJog);
            LogErr?.Invoke("Motion--设置jog运动参数", Gts_Return);

            //设置轴Jog运行速度
            if (dir == 0) //Jog+
            {
                Gts_Return = MC.GT_SetVel(Axis, Convert.ToDouble(JogVel / Program.SystemContainer.SysPara.Gts_Vel_reference));
                LogErr?.Invoke("Motion--设置轴Jog运行速度", Gts_Return);
            }
            else    // Jog-
            {
                Gts_Return = MC.GT_SetVel(Axis, Convert.ToDouble(-JogVel / Program.SystemContainer.SysPara.Gts_Vel_reference));
                LogErr?.Invoke("Motion--设置轴Jog运行速度", Gts_Return);
            }

            //启动轴运动
            Gts_Return = MC.GT_Update(1 << (Axis - 1));
            LogErr?.Invoke("Motion--启动轴运动", Gts_Return);
        }
예제 #3
0
 //Dodaje nowy dodatek do bazy danych
 private void btnSave_Click(object sender, EventArgs e)
 {
     if ((tbAdditionName.Text.Trim() == "") || (tbAdditionName.Text == "wpisz tutaj..."))
     {
         MessageBox.Show("Proszę wpisać poprawną wartość...", "Błędne dane.", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             if (tbAdditionName.TextLength > 30)
             {
                 throw new WrongSizeStringException("Nazwa dodatku nie może być większa niż 30 znaków");
             }
             //dodanie rodzaju dodatku do bazy danych
             Additions.Addition.AddAdditionType(tbAdditionName.Text, ConnectionToDB.disconnect);
             EmployeesFinances.EmployeeFinanse.isCorrect = true;
         }
         catch (WrongSizeStringException ex2)
         {
             MessageBox.Show(ex2.Message, "Błąd podczas wprowadzania danych do tabeli Rodzaj Dodatku.", MessageBoxButtons.OK, MessageBoxIcon.Error);
             //log
             LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.rodzaj_dodatku, ex2.Message));
         }
         finally
         {
             this.Close();
         }
     }
 }
예제 #4
0
        /// <summary>
        /// 接收事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="bytes"></param>
        /// <returns></returns>
        HandleResult OnReceive(TcpClient sender, byte[] bytes)
        {
            // 数据到达了
            byte[] contentBytes = new byte[bytes.Length];
            Array.ConstrainedCopy(bytes, 0, contentBytes, 0, contentBytes.Length);
            string data = Encoding.Default.GetString(contentBytes);

            string[] tmp = data.Split(',');

            if (isSend)
            {
                isSend = false;
                if (tmp.Length <= 1)
                {
                    Receive_Cordinate = new Vector(0, 0);
                    Rec_Ok            = true;
                    LogErr?.Invoke("图像处理反馈 -- 识别失败,数据:" + data);
                }
                else
                {
                    if ((decimal.TryParse(tmp[0], out decimal d_tmp_x)) && (decimal.TryParse(tmp[1], out decimal d_tmp_y)))
                    {
                        Receive_Cordinate = new Vector(d_tmp_x, d_tmp_y);
                        Rec_Ok            = true;
                    }
                    else
                    {
                        Receive_Cordinate = new Vector(0, 0);
                        Rec_Ok            = true;
                        LogErr?.Invoke("图像处理数据转换 -- 相机坐标提取失败!!!!");
                    }
                }
 /// <summary>
 /// Przycisk wprowadzania danych do bazy
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (dtpDate.Enabled == true)
         {
             loanInstallment.Date = dtpDate.Value.Date;
         }
         if (tbAmount.Enabled == true)
         {
             loanInstallment.InstallmentAmount = Convert.ToSingle(tbAmount.Text.Replace('.', ','));
         }
         //edycja w bazie danych
         Loan.EditInstallmentLone(loanInstallment, ConnectionToDB.disconnect);
         LoanInstallment.correctLoanInstallment = true;
         //zamknięcie formularza
         this.Close();
     }
     catch (FormatException ex)
     {
         MessageBox.Show(ex.Message, "Błąd aktualizacji.", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex2)
     {
         MessageBox.Show(ex2.Message, "Błąd aktualizacji.", MessageBoxButtons.OK, MessageBoxIcon.Error);
         //log
         LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.rata_pozyczki, "ZmianaKwotyDatyForm.btnZatwierdz_Click()/n/n" + ex2.Message));
     }
 }
예제 #6
0
        internal static bool AssignWorkData(Work w, MainForm form)
        {
            try
            {
                w.Date       = Convert.ToDateTime(form.tbWorkDate.Text);
                w.IdEmployee = Convert.ToInt32(form.cbSelectEmployeeWork.SelectedValue);
                w.StartTime  = Convert.ToDateTime(form.tbWorkTimeFrom.Text.ToString());
                w.StopTime   = Convert.ToDateTime(form.tbWorkTimeTo.Text.ToString());
                //to sprawdza czy godzina przyjścia jest mniejsza od godziny wyjścia
                if (w.StartTime.TimeOfDay > w.StopTime.TimeOfDay)
                {
                    throw new WrongDateTimeException("Godzina wyjścia jest mniejsza od godziny przyjścia.");
                }

                return(true);
            }
            catch (WrongDateTimeException ex)
            {
                MessageBox.Show(ex.Message, "Błąd przy wpisywaniu godzin.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (FormatException)
            {
                MessageBox.Show("Wpisałeś niepoprawną datę lub godziny rozpoczęcia i zakończenia pracy.\nPopraw dane i spróbuj ponownie.", "Błąd przy wpisywaniu godzin.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (Exception ex)
            {
                //log
                LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.praca, "MainForm.btnGodzinyDodaj_Click()/n/n" + ex.Message));
                MessageBox.Show(ex.Message, "Błąd przy wpisywaniu godzin.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
예제 #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                CheckDataCorrectness();

                DataAssignment();

                if (loan.PayInstallment(installment, loan))
                {
                    this.Close();
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("Wpisałeś niepoprawną kwotę pożyczki.", "Błędne dane..", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (EmptyStringException ex1)
            {
                MessageBox.Show(ex1.Message, "Błędne dane..", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (ErrorException ex2)
            {
                MessageBox.Show(ex2.Message, "Błędne dane..", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex2)
            {
                MessageBox.Show(ex2.Message, "Błędne dane, popraw i spróbuj ponownie", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //log
                LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.rata_pozyczki, "PozyczkaWplataWlasnaForm.btnZapisz_Click()/n/n" + ex2.Message));
            }
        }
예제 #8
0
        private void DisplayEmployee()
        {
            try
            {
                this.tbName.Text              = employee.FirstName;
                this.tbLastName.Text          = employee.LastName;
                this.tbStreet.Text            = employee.Street;
                this.tbCity.Text              = employee.City;
                this.tbZipCode.Text           = employee.ZipCode;
                this.tbNumberDaysOffLeft.Text = employee.NumberDaysOffLeft.ToString();
                this.tbMail.Text              = employee.EMail;
                this.chbPartTimeJob.Checked   = employee.PartTimeJob;
                this.chbIsManagement.Checked  = employee.IsManagement;

                switch (employee.NumberDaysOffAnnually)
                {
                case 20:
                    this.cbNumberDaysOffAnnually.SelectedIndex = 0;
                    break;

                case 26:
                    this.cbNumberDaysOffAnnually.SelectedIndex = 1;
                    break;
                }
                this.tbTelNumer.Text   = employee.TelNumber;
                this.tbOthersInfo.Text = employee.OtherInfo;

                if (UprawnieniePracownik.PracownikFinanse != 'x')
                {
                    //stawka
                    if (employee.RateRegular.IsMonthlyOrHourly == RateType.monthly)
                    {
                        //jezeli stawka miesieczna
                        rbRateMonthly.Checked = true;
                    }
                    else
                    {
                        //jeżeli stawka godzinowa
                        rbRateHourly.Checked = true;
                    }
                    tbRateValue.Text             = employee.RateRegular.RateValue.ToString();
                    dtpRegularRateFromDate.Value = employee.RateRegular.DateFrom;

                    //stawka nadgodzinowa
                    this.tbRateOvertimeValue.Text = employee.RateOvertime.RateValue.ToString();
                    dtpOvertimeRateFromDate.Value = employee.RateOvertime.DateFrom;
                }
                //dane opcjonalne
                TbHiredDate   = employee.HiredDate;
                TbReleaseDate = employee.ReleaseDate;
                TbNextMmedicalExaminationDate = employee.NextMmedicalExaminationDate;
                TbNextTrainingBhpDate         = employee.NextBhpTrainingDate;
            }
            catch (Exception ex)
            {
                //log
                LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.pracownik, "PracownikNowyForm.WypisywanieDanychDoEdycji()/n/n" + ex.Message));
            }
        }
예제 #9
0
 /// <summary>
 /// Stop_Connect
 /// </summary>
 public void Stop_Connect()
 {
     if (client.Stop())
     {
         LogInfo?.Invoke("服务器 断开成功!!!");
     }
     else
     {
         LogErr?.Invoke("服务器 断开异常!!!");
     }
 }
예제 #10
0
        public static string Process(Context ctx, LogInfo info, LogWarn war, LogErr err)
        {
            try
            {
                string      startobf = "Starting ";
                ModuleDefMD module   = ModuleDefMD.Load(ctx.FileName);
                module.GlobalType.FindOrCreateStaticConstructor();
                foreach (TaskID task in ctx.TasksList)
                {
                    switch (task)
                    {
                    case AntiDebugTask.ID:
                    {
                        info(startobf + "Anti-Debug Task...");
                        AntiDebugTask.Execute(module);
                    } break;

                    case StringEncodingTask.ID:
                    {
                        info(startobf + "String encoding Task...");
                        StringEncodingTask.Execute(module);
                    } break;

                    case ControlFlowTask.ID:
                    {
                        info(startobf + "Control Flow Task...");
                        ControlFlowTask.Execute(module);
                    } break;

                    case InvalidMDTask.ID:
                    {
                        info(startobf + "Invalid Metadata Task...");
                        InvalidMDTask.Execute(module);
                    } break;

                    case RenameTask.ID:
                        RenameTask.IsObfuscationActive = true; break;
                    }
                }
                info(startobf + "Rename Task..." + Environment.NewLine);
                RenameTask.Execute(module);
                module.Write(ctx.NewPath, new ModuleWriterOptions()
                {
                    Listener = NETUtils.listener
                });
                return(ctx.NewPath);
            }
            catch (Exception ex)
            {
                err(ex.Message);
                return("");
            }
        }
예제 #11
0
        internal static bool AssignDayOffData(DayOff dayOff, out int dayCounter, MainForm form)
        {
            dayCounter = 0;
            try
            {
                MainForm.mainDate = Convert.ToDateTime(form.tbDayOffDate.Text);
                //jeżeli urlop wielodniowy
                if (form.chBoxDayOffMulti.Checked)
                {
                    DateTime fromDate = Convert.ToDateTime(form.tbDayOffDate.Text);
                    DateTime toDate   = form.dtpDayOff.Value.Date;
                    //oblicza ilość dni urlopowych
                    dayCounter = Convert.ToInt32((toDate - fromDate).Days + 1);//np od 10 - 13 = 3, a ma być 4 (<=13)

                    //zmienne do bazy danych do tabeli urlop
                    dayOff.IdEmployee   = Convert.ToInt32(form.cbSelectEmployeeWork.SelectedValue);
                    dayOff.Date         = Convert.ToDateTime(form.tbDayOffDate.Text);
                    dayOff.IdTypeDayOff = Convert.ToInt32(form.cbDayOffType.SelectedValue);
                    //sprawdza czy data zakończenia urlopu nie jest mniejsza od daty rozpoczęcia
                    if (fromDate > toDate)
                    {
                        throw new WrongDateTimeException("Data rozpoczęcia urlopu jest mniejsza od daty zakończenia.\n Popraw datę i spróbuj ponownie");
                    }
                    return(true);
                }
                //urlop jednodniowy
                else
                {
                    dayCounter          = 1;
                    dayOff.IdEmployee   = Convert.ToInt32(form.cbSelectEmployeeWork.SelectedValue);
                    dayOff.Date         = Convert.ToDateTime(form.tbDayOffDate.Text);
                    dayOff.IdTypeDayOff = Convert.ToInt32(form.cbDayOffType.SelectedValue);
                    return(true);
                }
            }
            catch (WrongDateTimeException ex)
            {
                MessageBox.Show(ex.Message, "Błąd przy wpisywaniu godzin.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (FormatException)
            {
                MessageBox.Show("Wpisałeś niepoprawną datę rozpoczęcia lub zakończenia urlopu.\nPopraw dane i spróbuj ponownie.", "Błąd przy wpisywaniu urlopu.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (Exception ex)
            {
                //log
                LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.urlop, "MainForm.btnDodajGodziny_Click()/n/n" + ex.Message));
                MessageBox.Show(ex.Message, "Błąd przy wpisywaniu urlopu.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
예제 #12
0
        /// <summary>
        /// 单轴运动
        /// </summary>
        public void Interpolation_Start(decimal PosX, decimal PosY)
        {
            //设置X轴误差带
            Gts_Return = MC.GT_SetAxisBand(1, Program.SystemContainer.SysPara.Axis_X_Band, 4 * Program.SystemContainer.SysPara.Axis_X_Time);//20-0.1um,4*2-250us
            LogErr?.Invoke("X轴到位误差带", Gts_Return);
            //设置Y轴误差带
            Gts_Return = MC.GT_SetAxisBand(2, Program.SystemContainer.SysPara.Axis_Y_Band, 4 * Program.SystemContainer.SysPara.Axis_Y_Time);//20-0.1um,4*2-250us
            LogErr?.Invoke("Y轴到位误差带", Gts_Return);


            //急停按钮按下终止运行
            if (Program.SystemContainer.IO.GlobalEMG)
            {
                Interpolation_Stop();
                return;
            }

            //二轴单独控制运动
            //1、计算二轴规划位置
            decimal GoX = (Program.SystemContainer.SysPara.Work.X - PosX) * Program.SystemContainer.SysPara.Gts_Pos_reference;
            decimal GoY = (Program.SystemContainer.SysPara.Work.Y - PosY) * Program.SystemContainer.SysPara.Gts_Pos_reference;

            //2、设置运行参数
            SetAxisPara(1, Program.SystemContainer.SysPara.AxisXAcc, Program.SystemContainer.SysPara.AxisXDcc, Program.SystemContainer.SysPara.AxisXSmoothTime, GoX, Program.SystemContainer.SysPara.AxisXVelocity); //X轴运行参数
            SetAxisPara(2, Program.SystemContainer.SysPara.AxisYAcc, Program.SystemContainer.SysPara.AxisYDcc, Program.SystemContainer.SysPara.AxisYSmoothTime, GoY, Program.SystemContainer.SysPara.AxisYVelocity); //Y轴运行参数
            //3、启动运动
            Gts_Return = MC.GT_Update(1 << (1 - 1));                                                                                                                                                                 //启动X轴运动
            Gts_Return = MC.GT_Update(1 << (2 - 1));                                                                                                                                                                 //启动Y轴运动
            //4、等待运动结束
            int stsX, stsY;

            do
            {
                //急停按钮按下终止运行
                if (Program.SystemContainer.IO.GlobalEMG)
                {
                    Interpolation_Stop();
                    return;
                }
                Gts_Return = MC.GT_GetSts(1, out stsX, 1, out pClock); //读取X轴状态
                Gts_Return = MC.GT_GetSts(2, out stsY, 1, out pClock); //读取Y轴状态
                Thread.Sleep(100);
            } while (((stsX & 0x400) != 0) || ((stsY & 0x400) != 0));  //等待两轴规划停止

            //到位检测
            do
            {
                //延时
                Thread.Sleep(Program.SystemContainer.SysPara.Posed_Time);
            } while (!Program.SystemContainer.IO.Axis01_Motor_Posed || !(Program.SystemContainer.IO.Axis02_Motor_Posed));
        }
예제 #13
0
        internal static bool AssignIllnessData(Illness illness, out int dayCounter, MainForm form)
        {
            dayCounter = 0;
            try
            {
                MainForm.mainDate = Convert.ToDateTime(form.tbIllnessDate.Text);
                //jeżeli wpisywanie wielu dni
                if (form.chBoxIllnessMulti.Checked)
                {
                    DateTime fromDate = form.dtpIllness.Value.Date;
                    DateTime toDate   = Convert.ToDateTime(form.tbIllnessDate.Text);
                    dayCounter = Convert.ToInt32((fromDate - toDate).Days + 1);//np od 10 - 13 = 3, a ma być 4 (<=13)

                    illness.IdEmployee    = Convert.ToInt32(form.cbSelectEmployeeWork.SelectedValue);
                    illness.Date          = Convert.ToDateTime(form.tbIllnessDate.Text);
                    illness.IdIllnessType = Convert.ToInt32(form.cbIllnessType.SelectedValue);
                    if (toDate > fromDate)
                    {
                        throw new WrongDateTimeException("Data rozpoczęcia choroby jest mniejsza od daty zakończenia.\n Popraw datę i spróbuj ponownie");
                    }
                    return(true);
                }
                //jeżeli wpisywanie jednego dnia
                else
                {
                    dayCounter            = 1;
                    illness.IdEmployee    = Convert.ToInt32(form.cbSelectEmployeeWork.SelectedValue);
                    illness.Date          = Convert.ToDateTime(form.tbIllnessDate.Text);
                    illness.IdIllnessType = Convert.ToInt32(form.cbIllnessType.SelectedValue);
                    return(true);
                }
            }
            catch (WrongDateTimeException ex)
            {
                MessageBox.Show(ex.Message, "Błąd przy wpisywaniu godzin.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (FormatException)
            {
                MessageBox.Show("Wpisałeś niepoprawną datę rozpoczęcia lub zakończenia choroby.\nPopraw dane i spróbuj ponownie.", "Błąd przy wpisywaniu choroby.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (Exception ex)
            {
                //log
                LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.choroba, "MainForm.btnDodajGodziny_Click()/n/n" + ex.Message));
                MessageBox.Show(ex.Message, "Błąd przy wpisywaniu choroby.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
 /// <summary>
 /// Bindowanie comboboxów
 /// </summary>
 private void BindIllnessType()
 {
     try
     {
         cbType.DataSource    = ChangeIllnessTypeToString.ArrayListIllnessType;
         cbType.DisplayMember = "Name";
         cbType.ValueMember   = "Id";
     }
     catch (Exception ex1)
     {
         MessageBox.Show(ex1.Message, "Błąd podczas bindowania danych rodzaju choroby.", MessageBoxButtons.OK, MessageBoxIcon.Error);
         //log
         LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.praca, "BindRodzajChoroby()/n/n" + ex1.Message));
     }
 }
예제 #15
0
        /// <summary>
        /// 相对定位
        /// </summary>
        /// <param name="Axis"></param>
        /// <param name="acc"></param>
        /// <param name="dcc"></param>
        /// <param name="smoothTime"></param>
        /// <param name="pos"></param>
        /// <param name="vel"></param>
        public void Inc(short Axis, decimal acc, decimal dcc, short smoothTime, decimal pos, decimal vel)
        {
            //定义点位运动参数变量
            MC.TTrapPrm trapPrm = new MC.TTrapPrm();
            //定义当前位置变量
            double prfpos;
            //定义时钟
            uint pclock;
            //定义轴状态
            int sts;

            //将轴设置为点位运动模式
            Gts_Return = MC.GT_PrfTrap(Axis);
            LogErr?.Invoke("Motion--将轴设置为点位运动模式", Gts_Return);
            //读取点位运动运动参数
            Gts_Return = MC.GT_GetTrapPrm(Axis, out trapPrm);
            LogErr?.Invoke("Motion--读取轴点位运动运动参数", Gts_Return);
            //设置要修改的参数
            trapPrm.acc        = Convert.ToDouble(acc / Program.SystemContainer.SysPara.Gts_Acc_reference);
            trapPrm.dec        = Convert.ToDouble(dcc / Program.SystemContainer.SysPara.Gts_Acc_reference);
            trapPrm.smoothTime = smoothTime;
            //设置点位运动参数
            Gts_Return = MC.GT_SetTrapPrm(Axis, ref trapPrm);
            LogErr?.Invoke("Motion--读取轴设置点位运动参数", Gts_Return);

            //读取当前规划位置
            Gts_Return = MC.GT_GetPrfPos(Axis, out prfpos, 1, out pclock);
            LogErr?.Invoke("Motion--读取轴当前规划位置", Gts_Return);

            //设置目标位置
            Gts_Return = MC.GT_SetPos(Axis, Convert.ToInt32(Convert.ToDouble(pos * Program.SystemContainer.SysPara.Gts_Pos_reference) + prfpos));
            LogErr?.Invoke("Motion--设置目标位置", Gts_Return);

            //设置目标速度
            Gts_Return = MC.GT_SetVel(Axis, Convert.ToDouble(vel / Program.SystemContainer.SysPara.Gts_Vel_reference));
            LogErr?.Invoke("Motion--设置目标速度", Gts_Return);

            //启动轴运动
            Gts_Return = MC.GT_Update(1 << (Axis - 1));
            LogErr?.Invoke("Motion--启动轴运动", Gts_Return);

            do
            {
                //读取轴状态
                Gts_Return = MC.GT_GetSts(Axis, out sts, 1, out pclock);
                LogErr?.Invoke("Motion--读取轴状态", Gts_Return);
            } while ((sts & 0x400) != 0);//等待Axis规划停止
        }
예제 #16
0
        /// <summary>
        /// Zapisuje pożyczke w bazie danych
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                CheckDataCorrectness();

                DataAssignment();

                if (isEdit)
                {
                    LoanManager.EditLoan(loan, ConnectionToDB.notDisconnect);
                    Blokady.UsuwanieBlokady(Polaczenia.idUser, NazwaTabeli.pozyczka);
                }
                else
                {
                    LoanManager.AddLoan(loan, ConnectionToDB.disconnect);
                }
                //jeżeli nie było błedów ustawia poprawność na true
                Loan.correctLoan = true;

                //zamykanie formularza
                this.Close();
            }
            catch (FormatException)
            {
                MessageBox.Show("Musisz podać kwotę oddzieloną przecinkiem (np. 120,80)", "Błędne dane, popraw i spróbuj ponownie", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (EmptyStringException ex1)
            {
                MessageBox.Show(ex1.Message, "Błędne dane, popraw i spróbuj ponownie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (WrongSizeStringException ex2)
            {
                MessageBox.Show(ex2.Message, "Błędne dane, popraw i spróbuj ponownie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Błąd podczas edycji pożyczki", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //log
                LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.pozyczka, "PozyczkaNowaForm.btnDodaj_Click()/n/n" + ex1.Message));
                //zamykanie formularza
            }
            finally
            {
                Polaczenia.OdlaczenieOdBazy();
            }
        }
예제 #17
0
        public static double GetSumAllAdditionsByDate(int idEmployee, DateTime date)
        {
            string select = "select sum(kwota) from dodatek where id_pracownika=" + idEmployee +
                            " AND datepart(year,data)=" + date.Year + " AND datepart(month,data)=" + date.Month;

            try
            {
                return(Convert.ToDouble(Database.GetOneElement(select, ConnectionToDB.disconnect)));
            }
            catch (FormatException ex3)
            {
                //log
                LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.dodatek, "AdditionsAdvancesManager.GetAdditionsByDate()/n/n" + ex3.Message));

                return(0d);
            }
        }
예제 #18
0
 public static string Process(Context ctx, LogInfo info, LogWarn war, LogErr err)
 {
     try
     {
         string startobf = "Starting ";
         ModuleDefMD module = ModuleDefMD.Load(ctx.FileName);
         module.GlobalType.FindOrCreateStaticConstructor();
         foreach (TaskID task in ctx.TasksList)
         {
             switch (task)
             {
                 case AntiDebugTask.ID:
                     {
                         info(startobf + "Anti-Debug Task...");
                         AntiDebugTask.Execute(module);
                     } break;
                 case StringEncodingTask.ID:
                     {
                         info(startobf + "String encoding Task...");
                         StringEncodingTask.Execute(module);
                     } break;
                 case ControlFlowTask.ID:
                     {
                         info(startobf + "Control Flow Task...");
                         ControlFlowTask.Execute(module);
                     } break;
                case InvalidMDTask.ID:
                     {
                         info(startobf + "Invalid Metadata Task...");
                         InvalidMDTask.Execute(module);
                     } break;
                 case RenameTask.ID:
                     RenameTask.IsObfuscationActive = true; break;
             }
         }
         info(startobf + "Rename Task..." + Environment.NewLine);
             RenameTask.Execute(module);
         module.Write(ctx.NewPath, new ModuleWriterOptions() { Listener = NETUtils.listener });
         return ctx.NewPath;
     }
     catch (Exception ex)
     {
         err(ex.Message);
         return "";
     }
 }
예제 #19
0
 /// <summary>
 /// 连接指定服务器Ip和Port
 /// </summary>
 /// <param name="ip"></param>
 /// <param name="port"></param>
 public void TCP_Start(string ip, ushort port)
 {
     try
     {
         if (client.Connect(ip, port))
         {
             LogInfo?.Invoke("服务器 连接触发!!!");
         }
         else
         {
             LogErr?.Invoke("服务器 连接失败!!!");
         }
     }
     catch (Exception ex)
     {
         LogErr?.Invoke(ex.Message);
     }
 }
예제 #20
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public HPSocket_Communication()
 {
     ConnectOk = false;//连接标志 清除
     try
     {
         // 设置client事件
         client.OnPrepareConnect += new TcpClientEvent.OnPrepareConnectEventHandler(OnPrepareConnect); //准备连接事件绑定
         client.OnConnect        += new TcpClientEvent.OnConnectEventHandler(OnConnect);               //连接事件绑定
         client.OnSend           += new TcpClientEvent.OnSendEventHandler(OnSend);                     //发送事件绑定
         client.OnReceive        += new TcpClientEvent.OnReceiveEventHandler(OnReceive);               //接收事件绑定
         client.OnClose          += new TcpClientEvent.OnCloseEventHandler(OnClose);                   //关闭事件绑定
         LogInfo?.Invoke(string.Format("HP-Socket Version: {0}", client.Version));
     }
     catch (Exception ex)
     {
         LogErr?.Invoke(ex.Message);
     }
 }
예제 #21
0
 /// <summary>
 /// Przycisk wprowadzania danych do bazy
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (dtpDate.Enabled == true)
         {
             employeeFinanse.Date = dtpDate.Value.Date;
         }
         if (tbAmount.Enabled == true)
         {
             employeeFinanse.Amount = Convert.ToSingle(tbAmount.Text.Replace('.', ','));
         }
         if (tbInfo.Enabled == true)
         {
             if (tbInfo.TextLength > 100)
             {
                 throw new FormatException("Pole Info nie może mieć więcej niż 100 znaków.");
             }
             employeeFinanse.OtherInfo = tbInfo.Text;
         }
         if (employeeFinanse is Addition)
         {
             AdditionManager.Edit((Addition)employeeFinanse, ConnectionToDB.disconnect);
         }
         else
         {
             AdvanceManager.Edit((Advance)employeeFinanse, ConnectionToDB.disconnect);
         }
         EmployeeFinanse.isCorrect = true;
         //zamknięcie formularza
         this.Close();
     }
     catch (FormatException ex)
     {
         MessageBox.Show(ex.Message, "Błąd aktualizacji.", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex2)
     {
         MessageBox.Show(ex2.Message, "Błąd aktualizacji.", MessageBoxButtons.OK, MessageBoxIcon.Error);
         //log
         LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.zaliczka, "ZmianaKwotyDatyForm.btnZatwierdz_Click()/n/n" + ex2.Message));
     }
 }
예제 #22
0
        /// <summary>
        /// Bindowanie comboboxów
        /// </summary>
        private void BindEmployee()
        {
            try
            {
                EmployeeManager em = new EmployeeManager();
                em.GetEmployeesHiredRealesedToList(true, TableView.table);

                ArrayList lista = new ArrayList(EmployeeManager.arrayEmployees);

                cbEmployee.DataSource    = lista;
                cbEmployee.DisplayMember = "GetFullName";
                cbEmployee.ValueMember   = "IdEmployee";
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Błąd podczas bindowania danych pracownika.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //log
                LogErr.DodajLogErrorDoBazy(new LogErr(Polaczenia.idUser, DateTime.Now, Polaczenia.ip, 0, NazwaTabeli.pozyczka, "BindPracownik()/n/n" + ex1.Message));
            }
        }
예제 #23
0
        /// <summary>
        /// Gts控制卡初始化
        /// </summary>
        public void Reset()
        {
            //复位运动控制器
            Gts_Return = MC.GT_Reset();
            LogErr?.Invoke("Gts_Initial---GT_Reset", Gts_Return);
            //延时
            Thread.Sleep(200);
            //配置运动控制器
            Gts_Return = MC.GT_LoadConfig("Axis.cfg");
            LogErr?.Invoke("Gts_Initial--GT_LoadConfig", Gts_Return);
            //清除各轴的报警和限位
            Gts_Return = MC.GT_ClrSts(1, 4);
            LogErr?.Invoke("Gts_Initial--清除各轴的报警和限位", Gts_Return);
            //轴使能
            Gts_Return = MC.GT_AxisOn(1);
            Gts_Return = MC.GT_AxisOn(2);
            //延时
            Thread.Sleep(200);

            //设置X轴误差带
            Gts_Return = MC.GT_SetAxisBand(1, Program.SystemContainer.SysPara.Axis_X_Band, 4 * Program.SystemContainer.SysPara.Axis_X_Time);//20-0.1um,4*2-250us
            LogErr?.Invoke("X轴到位误差带", Gts_Return);

            //设置Y轴误差带
            Gts_Return = MC.GT_SetAxisBand(2, Program.SystemContainer.SysPara.Axis_Y_Band, 4 * Program.SystemContainer.SysPara.Axis_Y_Time);//20-0.1um,4*2-250us
            LogErr?.Invoke("Y轴到位误差带", Gts_Return);

            //设置X轴软件限位
            Gts_Return = MC.GT_SetSoftLimit(1, Program.SystemContainer.SysPara.AxisXSoftLimitPositive * (int)Program.SystemContainer.SysPara.Gts_Pos_reference, Program.SystemContainer.SysPara.AxisXSoftLimitNegative * (int)Program.SystemContainer.SysPara.Gts_Pos_reference);
            LogErr?.Invoke("设置X轴软件限位", Gts_Return);

            //设置Y轴软件限位
            Gts_Return = MC.GT_SetSoftLimit(2, Program.SystemContainer.SysPara.AxisYSoftLimitPositive * (int)Program.SystemContainer.SysPara.Gts_Pos_reference, Program.SystemContainer.SysPara.AxisYSoftLimitNegative * (int)Program.SystemContainer.SysPara.Gts_Pos_reference);
            LogErr?.Invoke("设置Y轴软件限位", Gts_Return);

            //轴回零完成信号
            Axis01_Homed = false;
            Axis02_Homed = false;
        }
예제 #24
0
 /// <summary>
 /// Send_Data
 /// </summary>
 /// <param name="order"></param>
 public void Send_Data(int order)
 {
     //检测是否连接
     if (!ConnectOk)
     {
         LogErr?.Invoke("相机未连接,Send命令取消!!!");
         return;
     }
     //发送数据
     try
     {
         Rec_Ok            = false;            //清除接收完成标志
         Receive_Cordinate = new Vector(0, 0); //清除接收反馈坐标值
         string send = order.ToString();
         if (send.Length == 0)
         {
             return;
         }
         byte[] bytes  = Encoding.Default.GetBytes(send);
         IntPtr connId = client.ConnectionId;
         // 发送
         if (client.Send(bytes, bytes.Length))
         {
             isSend = true;
         }
         else
         {
             isSend = false;
             LogErr?.Invoke("发送失败!!!");
         }
     }
     catch (Exception ex)
     {
         LogErr?.Invoke(ex.Message);
     }
 }
예제 #25
0
        /// <summary>
        /// Gts工控卡 上位机Axes回零
        /// </summary>
        /// <param name="Axis"></param>
        /// <returns></returns>
        public int Home_Upper_Monitor(short Axis)
        {
            //命令返回值
            short Gts_Return;
            short Capture;//捕获状态值

            MC.TTrapPrm Home_TrapPrm = new MC.TTrapPrm();
            int         Axis_Sta;    //轴状态
            uint        Axis_Pclock; //轴时钟
            Int32       Axis_Pos;    //回零是触发Home开关时的轴位置
            double      prfPos;      //回零运动过程中规划位置
            //定义时钟
            uint pclock;

            //停止轴运动
            Gts_Return = MC.GT_Stop(1 << (Axis - 1), 0); //平滑停止轴运动
            LogErr?.Invoke("Motion--停止轴运动", Gts_Return);

            //清除指定轴报警和限位
            Gts_Return = MC.GT_ClrSts(Axis, 1);
            LogErr?.Invoke("Axis_Home----GT_ClrSts", Gts_Return);

            //回零准备,向正方向前进20mm,后触发回零
            //切换到点动模式
            Gts_Return = MC.GT_PrfTrap(Axis);
            LogErr?.Invoke("Axis_Home----GT_PrfTrap", Gts_Return);

            //读取点动模式运动参数
            Gts_Return = MC.GT_GetTrapPrm(Axis, out Home_TrapPrm);
            LogErr?.Invoke("Axis_Home----GT_GetTrapPrm", Gts_Return);

            //设置点动模式运动参数
            Home_TrapPrm.acc        = Convert.ToDouble(Program.SystemContainer.SysPara.Home_acc / Program.SystemContainer.SysPara.Gts_Acc_reference);
            Home_TrapPrm.dec        = Convert.ToDouble(Program.SystemContainer.SysPara.Home_dcc / Program.SystemContainer.SysPara.Gts_Acc_reference);
            Home_TrapPrm.smoothTime = Program.SystemContainer.SysPara.Home_smoothTime;

            //设置点动模式运动参数
            Gts_Return = MC.GT_SetTrapPrm(Axis, ref Home_TrapPrm);
            LogErr?.Invoke("Axis_Home----GT_SetTrapPrm", Gts_Return);

            //设置点动模式目标速度,即回原点速度
            Gts_Return = MC.GT_SetVel(Axis, Convert.ToDouble(Program.SystemContainer.SysPara.Home_High_Speed / Program.SystemContainer.SysPara.Gts_Vel_reference));
            LogErr?.Invoke("Axis_Home----GT_SetVel", Gts_Return);

            //读取当前规划位置
            Gts_Return = MC.GT_GetPrfPos(Axis, out prfPos, 1, out pclock);
            LogErr?.Invoke("Motion--读取轴当前规划位置", Gts_Return);

            //设置点动模式目标位置,即原点准备距离 20mm
            Gts_Return = MC.GT_SetPos(Axis, Convert.ToInt32(Convert.ToDouble(20 * Program.SystemContainer.SysPara.Gts_Pos_reference) + prfPos));
            LogErr?.Invoke("Motion--设置目标位置", Gts_Return);

            //启动运动
            Gts_Return = MC.GT_Update(1 << (Axis - 1));
            LogErr?.Invoke("Axis_Home----GT_Update", Gts_Return);

            do
            {
                //读取轴状态
                Gts_Return = MC.GT_GetSts(Axis, out Axis_Sta, 1, out Axis_Pclock);
            } while ((Axis_Sta & 0x400) != 0);

            //停止轴运动
            Gts_Return = MC.GT_Stop(1 << (Axis - 1), 0); //平滑停止轴运动
            LogErr?.Invoke("Motion--停止轴运动", Gts_Return);

            //延时一段时间,等待电机稳定
            Thread.Sleep(200);//200ms

            //触发回零
            //启动Home捕捉
            Gts_Return = MC.GT_SetCaptureMode(Axis, MC.CAPTURE_HOME);
            LogErr?.Invoke("Axis_Home----GT_SetCaptureMode", Gts_Return);

            //切换到点动模式
            Gts_Return = MC.GT_PrfTrap(Axis);
            LogErr?.Invoke("Axis_Home----GT_PrfTrap", Gts_Return);

            //读取点动模式运动参数
            Gts_Return = MC.GT_GetTrapPrm(Axis, out Home_TrapPrm);
            LogErr?.Invoke("Axis_Home----GT_GetTrapPrm", Gts_Return);

            //设置点动模式运动参数
            Home_TrapPrm.acc        = Convert.ToDouble(Program.SystemContainer.SysPara.Home_acc / Program.SystemContainer.SysPara.Gts_Acc_reference);
            Home_TrapPrm.dec        = Convert.ToDouble(Program.SystemContainer.SysPara.Home_dcc / Program.SystemContainer.SysPara.Gts_Acc_reference);
            Home_TrapPrm.smoothTime = Program.SystemContainer.SysPara.Home_smoothTime;

            //设置点动模式运动参数
            Gts_Return = MC.GT_SetTrapPrm(Axis, ref Home_TrapPrm);
            LogErr?.Invoke("Axis_Home----GT_SetTrapPrm", Gts_Return);

            //设置点动模式目标速度,即回原点速度
            Gts_Return = MC.GT_SetVel(Axis, Convert.ToDouble(Program.SystemContainer.SysPara.Home_High_Speed / Program.SystemContainer.SysPara.Gts_Vel_reference));
            LogErr?.Invoke("Axis_Home----GT_SetVel", Gts_Return);

            //设置点动模式目标位置,即原点搜索距离
            Gts_Return = MC.GT_SetPos(Axis, Convert.ToInt32(Program.SystemContainer.SysPara.Search_Home * Program.SystemContainer.SysPara.Gts_Pos_reference));
            LogErr?.Invoke("Axis_Home----GT_SetPos", Gts_Return);

            //启动运动
            Gts_Return = MC.GT_Update(1 << (Axis - 1));
            LogErr?.Invoke("Axis_Home----GT_Update", Gts_Return);


            do
            {
                //读取轴状态
                Gts_Return = MC.GT_GetSts(Axis, out Axis_Sta, 1, out Axis_Pclock);
                //读取捕获状态
                Gts_Return = MC.GT_GetCaptureStatus(Axis, out Capture, out Axis_Pos, 1, out Axis_Pclock);
                //读取编码器位置
                //Gts_Return = MC.GT_GetEncPos(Axis, out encPos, 1, out Axis_Pclock);
                //如果运动停止,返回出错信息
                if (0 == (Axis_Sta & 0x400))
                {
                    LogErr?.Invoke("Axis_Home----No Home found!!", 1);
                    return(1);//整个过程Home信号一直没有触发,返回值为1
                }
            } while (Capture == 0);

            /********************************待评估***********************************/

            /*
             * //清除捕捉状态
             * //Gts_Return = MC.GT_ClearCaptureStatus(Axis);
             * //LogErr?.Invoke("Axis_Home----清除捕捉状态", Gts_Return);
             *
             * //设置捕捉Home 下降沿
             * //Gts_Return = MC.GT_SetCaptureSense(Axis, MC.CAPTURE_HOME, 0);
             * //LogErr?.Invoke("Axis_Home----设置捕捉Home 下降沿", Gts_Return);
             *
             * //设定目标位置为捕获位置+偏移量
             * Gts_Return = MC.GT_SetPos(Axis, Axis_Pos + Home_OffSet);
             * LogErr?.Invoke("Axis_Home----GT_SetPos", Gts_Return);
             *
             * //在运动状态下更新目标位置
             * Gts_Return = MC.GT_Update(1 << (Axis - 1));
             * LogErr?.Invoke("Axis_Home----GT_Update", Gts_Return);
             *
             * do
             * {
             *  //读取轴状态
             *  Gts_Return = MC.GT_GetSts(Axis, out Axis_Sta, 1, out Axis_Pclock);
             *  //读取捕获状态
             *  Gts_Return = MC.GT_GetCaptureStatus(Axis, out Capture, out Axis_Pos, 1, out Axis_Pclock);
             *  //读取编码器位置
             *  //Gts_Return = MC.GT_GetEncPos(Axis, out encPos, 1, out Axis_Pclock);
             *  //如果运动停止,返回出错信息
             *  if (0 == (Axis_Sta & 0x400))
             *  {
             *      LogErr?.Invoke("Axis_Home----No Home found!!", 1);
             *      //反转回零标志
             *      Homing_Flag = !Homing_Flag;
             *      return 1;//整个过程Home信号一直没有触发,返回值为1
             *  }
             * } while (Capture ==0);
             */
            /********************************待评估***********************************/

            //停止轴运动
            Gts_Return = MC.GT_Stop(1 << (Axis - 1), 0); //平滑停止轴运动
            LogErr?.Invoke("Motion--停止轴运动", Gts_Return);

            //延时一段时间,等待电机稳定
            Thread.Sleep(500);//200ms
            //位置清零
            Gts_Return = MC.GT_ZeroPos(Axis, 1);
            LogErr?.Invoke("Axis_Home----GT_ZeroPos", Gts_Return);

            /***************************Home_Offset偏置距离 开始********************************************/

            if (Program.SystemContainer.SysPara.Home_OffSet != 0)
            {
                //切换到点动模式
                Gts_Return = MC.GT_PrfTrap(Axis);
                LogErr?.Invoke("Axis_Home----GT_PrfTrap", Gts_Return);

                //读取点动模式运动参数
                Gts_Return = MC.GT_GetTrapPrm(Axis, out Home_TrapPrm);
                LogErr?.Invoke("Axis_Home----GT_GetTrapPrm", Gts_Return);

                //设置点动模式运动参数
                Home_TrapPrm.acc        = Convert.ToDouble(Program.SystemContainer.SysPara.Home_acc / Program.SystemContainer.SysPara.Gts_Acc_reference);
                Home_TrapPrm.dec        = Convert.ToDouble(Program.SystemContainer.SysPara.Home_dcc / Program.SystemContainer.SysPara.Gts_Acc_reference);
                Home_TrapPrm.smoothTime = Program.SystemContainer.SysPara.Home_smoothTime;

                //设置点动模式运动参数
                Gts_Return = MC.GT_SetTrapPrm(Axis, ref Home_TrapPrm);
                LogErr?.Invoke("Axis_Home----GT_SetTrapPrm", Gts_Return);

                //设置点动模式目标速度,即回原点速度
                Gts_Return = MC.GT_SetVel(Axis, Convert.ToDouble(Program.SystemContainer.SysPara.Home_High_Speed / Program.SystemContainer.SysPara.Gts_Vel_reference));
                LogErr?.Invoke("Axis_Home----GT_SetVel", Gts_Return);

                //设置点动模式目标位置,即原点搜索距离
                Gts_Return = MC.GT_SetPos(Axis, Convert.ToInt32(Program.SystemContainer.SysPara.Home_OffSet * Program.SystemContainer.SysPara.Gts_Pos_reference));
                LogErr?.Invoke("Axis_Home----GT_SetPos", Gts_Return);

                //启动运动
                Gts_Return = MC.GT_Update(1 << (Axis - 1));
                LogErr?.Invoke("Axis_Home----GT_Update", Gts_Return);

                do
                {
                    //读取轴状态
                    Gts_Return = MC.GT_GetSts(Axis, out Axis_Sta, 1, out Axis_Pclock);
                    //读取规划位置
                    Gts_Return = MC.GT_GetPrfPos(Axis, out prfPos, 1, out Axis_Pclock);
                    //读取编码器位置
                    //Gts_Return = MC.GT_GetEncPos(Axis, out encPos, 1, out Axis_Pclock);
                } while ((Axis_Sta & 0x400) != 0);

                //检查是否到达 Home_OffSet
                if (prfPos != Convert.ToInt32(Program.SystemContainer.SysPara.Home_OffSet * Program.SystemContainer.SysPara.Gts_Pos_reference))
                {
                    LogErr?.Invoke("Axis_Home----Move to Home_OffSet err!!", 1);
                    return(2);
                }
                /***************************Home_Offset偏置距离 结束********************************************/
            }
            //延时一段时间,等待电机稳定
            Thread.Sleep(500);//200ms
            //位置清零
            Gts_Return = MC.GT_ZeroPos(Axis, 1);
            LogErr?.Invoke("Axis_Home----GT_ZeroPos", Gts_Return);
            return(0);
        }
예제 #26
0
 /// <summary>
 /// 停止轴运动
 /// </summary>
 public void Interpolation_Stop()
 {
     //停止轴规划运动,停止坐标系运动
     Gts_Return = MC.GT_Stop(15, 0);//783-1-4轴全停止,坐标系1、2均停止,15-1-4轴全停止;0-平滑停止运动,783-急停运动
     LogErr?.Invoke("Establish_Coordinationg--GT_Stop", Gts_Return);
 }
예제 #27
0
 /// <summary>
 /// 清除轴状态
 /// </summary>
 /// <param name="axis"></param>
 public void StatusClear(short axis)
 {
     Gts_Return = MC.GT_ClrSts(axis, 1);
     LogErr?.Invoke("GT_ClrSts", Gts_Return);
 }
예제 #28
0
 /// <summary>
 /// 释放Gts控制卡
 /// </summary>
 public void Free()
 {
     //关闭运动控制器
     Gts_Return = MC.GT_Close();
     LogErr?.Invoke("Gts_Initial---GT_Close", Gts_Return);
 }
예제 #29
0
 /// <summary>
 /// 紧急停止轴运动
 /// </summary>
 /// <param name="Axis"></param>
 public void EmgStop(short Axis)
 {
     //停止轴运动
     Gts_Return = MC.GT_Stop(1 << (Axis - 1), 1 << (Axis - 1)); //紧急停止轴运动
     LogErr?.Invoke("Motion--停止轴运动", Gts_Return);
 }
예제 #30
0
 /// <summary>
 /// 平滑停止轴运动
 /// </summary>
 /// <param name="Axis"></param>
 public void SmoothStop(short Axis)
 {
     //停止轴运动
     Gts_Return = MC.GT_Stop(1 << (Axis - 1), 0); //平滑停止轴运动
     LogErr?.Invoke("Motion--停止轴运动", Gts_Return);
 }
예제 #31
0
        /// <summary>
        /// 轴自身Axes02 Y轴回零 返回值:0 - 回零完成呢;1 - Busy;2 - 超时;3 - 轴错误
        /// </summary>
        /// <param name="Axis"></param>
        /// <returns></returns>
        public int Axis02_Home_Down_Motor()
        {
            Axis02_Homed = false;//归零完成标志清除

            //命令返回值
            short Gts_Return = 0;

            //轴运行中,退出
            if (Program.SystemContainer.IO.Axis02_Busy)
            {
                return(1);
            }

            //停止轴运动
            Gts_Return = MC.GT_Stop(1 << 1, 0); //平滑停止轴运动
            LogErr?.Invoke("Motion--停止轴运动", Gts_Return);

            //清除指定轴报警和限位
            Gts_Return = MC.GT_ClrSts(2, 1);
            LogErr?.Invoke("Axis_Home----GT_ClrSts", Gts_Return);

            //位置清零
            Gts_Return = MC.GT_ZeroPos(2, 1);
            LogErr?.Invoke("Axis_Home----GT_ZeroPos", Gts_Return);

            //触发回零外部信号
            if (Program.SystemContainer.IO.Axis02_Home_Ex0_Control != 1)
            {
                Program.SystemContainer.IO.Axis02_Home_Ex0_Control = 1;
            }

            //延时一段时间,等待信号生效
            Thread.Sleep(500);

            //清除回零外部信号
            if (Program.SystemContainer.IO.Axis02_Home_Ex0_Control != 0)
            {
                Program.SystemContainer.IO.Axis02_Home_Ex0_Control = 0;
            }

            //捕获原点触发信号
            //等待完成
            Task.Factory.StartNew(() => {
                do
                {
                    //延时
                    Thread.Sleep(100);
                } while (!Program.SystemContainer.IO.Axis02_Home);
            }).Wait(120 * 1000);//回零超时时长120s 2min
            if (!Program.SystemContainer.IO.Axis02_Home)
            {
                MessageBox.Show("Y轴回零超时!!!");
                return(2);
            }
            //清除回零外部信号
            if (Program.SystemContainer.IO.Axis02_Home_Ex0_Control != 0)
            {
                Program.SystemContainer.IO.Axis02_Home_Ex0_Control = 0;
            }

            //延时一段时间,等待电机稳定
            Thread.Sleep(20);//200ms

            //位置清零
            Gts_Return = MC.GT_ZeroPos(2, 1);
            LogErr?.Invoke("Axis_Home----GT_ZeroPos", Gts_Return);

            //清除指定轴报警和限位
            Gts_Return = MC.GT_ClrSts(2, 1);
            LogErr?.Invoke("Axis_Home----GT_ClrSts", Gts_Return);

            //检测是否有错误发生
            if (Program.SystemContainer.IO.Axis02_Err_Occur)
            {
                return(3);
            }
            else
            {
                Axis02_Homed = true;//归零完成标志
                return(0);
            }
        }