/// <summary>
        /// 读取DB块上的任务号,位置,数量,机械手任务号,机械手放烟数量
        /// </summary>
        /// <param name="index">读取索引</param>
        /// <param name="mainbelt">主皮带</param>
        void ReadDBinfo(int mainbelt)
        {
            ListmbInfo.Clear(); //清空list
            dgvMainBeltInfo.DataSource = null;
            panelCig.Controls.Clear();
            int            ReadIndex    = 0;//读取DB索引
            List <decimal> SortNumList  = new List <decimal>();
            List <decimal> QuantityList = new List <decimal>();

            for (int i = (mainbelt - 1) * 8; i < mainbelt * 8; i++)
            {
                SortNumList.Add(listMainBelt[6].ReadD(i).CastTo <decimal>(0));         //任务号
                QuantityList.Add(listMainBelt[6].ReadD(32 + i).CastTo <decimal>(0));   //放烟数量
            }
            for (int i = 0; i < 40; i++)                                               //从电控读取数据 填充 listmbinfo
            {
                Sortnum = listMainBelt[mainbelt - 1].ReadD(ReadIndex).CastTo <int>(0); //任务号
                if (Sortnum > 0)                                                       //任务号不为0
                {
                    MainBeltInfo info = new MainBeltInfo();
                    info.SortNum      = Sortnum;                                                                               //任务号
                    info.Place        = (listMainBelt[mainbelt - 1].ReadD((ReadIndex + 1)).CastTo <decimal>(-1) / 1000);       //位置(米)
                    info.Quantity     = Convert.ToDecimal(listMainBelt[mainbelt - 1].ReadD((ReadIndex + 2)).CastTo <int>(-1)); //数量
                    info.mainbelt     = mainbelt.ToString();                                                                   //主皮带
                    info.SortNumList  = SortNumList;                                                                           //机械手任务号
                    info.QuantityList = QuantityList;                                                                          //机械手放烟数量
                    ListmbInfo.Add(info);
                }
                ReadIndex = ReadIndex + 3;
            }
            MainBeltInfoService.GetMainBeltInfo(ListmbInfo);               //填充完成之后传进方法 计算 ,
            ListmbInfo        = ListmbInfo.OrderBy(x => x.Place).ToList(); // ListmbInfo.OrderBy(a => a.Place).ThenBy(a => a.SortNum).ToList();//对距离任务号进行排序
            pbLoading.Visible = false;
        }
Example #2
0
        /// <summary>
        /// 读取预分拣DB块
        /// </summary>
        /// <param name="index"></param>
        /// <param name="groupno"></param>
        void ReadDBinfo(int index, decimal groupno)
        {
            ListmbInfo.Clear(); //清空list
            // dgvSortingBeltInfo = null;
            panelCig.Controls.Clear();
            int ReadIndex = 0;

            for (int i = 0; i < 40; i++)                                        //从电控读取数据 填充 listmbinfo
            {
                Sortnum = ListSort[index - 1].ReadD(ReadIndex).CastTo <int>(0); //任务号

                if (Sortnum > 0)                                                //任务号不为0
                {
                    MainBeltInfo info = new MainBeltInfo();
                    info.SortNum  = Sortnum;                                                                  //任务号
                    info.Place    = (ListSort[index - 1].ReadD((ReadIndex + 1)).CastTo <decimal>(-1) / 1000); //位置(米)
                    info.Quantity = ListSort[index - 1].ReadD((ReadIndex + 2)).CastTo <int>(-1);              //数量
                    info.GroupNO  = groupno;                                                                  //组号
                    ListmbInfo.Add(info);
                }
                ReadIndex = ReadIndex + 4;
            }
            MainBeltInfoService.GetSortMainBeltInfo(ListmbInfo);           //填充完成之后传进方法 计算 ,
            ListmbInfo        = ListmbInfo.OrderBy(a => a.Place).ToList(); //对距离任务号进行排序
            pbLoading.Visible = false;
        }
Example #3
0
        /// <summary>
        /// 读取预分拣DB块
        /// </summary>
        /// <param name="index"></param>
        /// <param name="groupno"></param>
        void ReadDBinfo(decimal groupno)
        {
            ListmbInfoA.Clear(); //清空list
            ListmbInfoB.Clear();
            for (int j = 0; j < 1; j++)
            {
                // dgvSortingBeltInfo = null;
                panebelt.Controls.Clear();
                int ReadIndex = 0;

                for (int i = 0; i < 40; i++)                                //从电控读取数据 填充 listmbinfo
                {
                    Sortnum = ListSort[j].ReadD(ReadIndex).CastTo <int>(0); //任务号

                    if (Sortnum > 0)                                        //任务号不为0
                    {
                        MainBeltInfo info = new MainBeltInfo();
                        info.SortNum    = Sortnum;                                                          //任务号
                        info.Place      = (ListSort[j].ReadD((ReadIndex + 1)).CastTo <decimal>(-1) / 1000); //位置(米)
                        info.Quantity   = ListSort[j].ReadD((ReadIndex + 2)).CastTo <int>(-1);              //数量
                        info.GroupNO    = groupno;                                                          //组号
                        info.DeviceName = "";
                        if (j == 0)
                        {
                            ListmbInfoA.Add(info);
                        }
                        else
                        {
                            ListmbInfoB.Add(info);
                        }
                    }
                    ReadIndex = ReadIndex + 4;
                }
                if (j == 0)
                {
                    MainBeltInfoService.GetSortMainBeltInfo(ListmbInfoA);     //填充完成之后传进方法 计算 ,
                    ListmbInfoA = ListmbInfoA.OrderBy(a => a.Place).ToList(); //对距离任务号进行排序
                    GetDviceName(ListmbInfoA, "btnA");
                }
                else
                {
                    MainBeltInfoService.GetSortMainBeltInfo(ListmbInfoB);     //填充完成之后传进方法 计算 ,
                    ListmbInfoB = ListmbInfoA.OrderBy(a => a.Place).ToList(); //对距离任务号进行排序
                    GetDviceName(ListmbInfoB, "btnB");
                }
            }
            if (isOnLine)
            {
                panel3.Visible = false;
            }
            else
            {
                lblloading.Text = "服务器连接失败!请检查网络";
            }
        }
Example #4
0
        public string GetMainBeltInfo(int mainBelt)
        {
            try
            {
                OpcServer.Connect();
            }
            catch (Exception ex)
            {
                return("远程连接失败,请检查网络");
            }
            List <MainBeltInfo> ListmbInfo = new List <MainBeltInfo>();

            int ReadIndex = 0;

            double[]       nowplace     = new double[40];
            List <decimal> SortNumList  = new List <decimal>();
            List <decimal> QuantityList = new List <decimal>();

            for (int i = (mainBelt - 1) * 8; i < mainBelt * 8; i++)
            {
                SortNumList.Add(OpcServer.MachineGroup.ReadD(i).CastTo <decimal>(0));                              //任务号
                QuantityList.Add(OpcServer.MachineGroup.ReadD(32 + i).CastTo <decimal>(0));                        //任务号
            }
            for (int i = 0; i < 40; i++)                                                                           //从电控读取数据 填充 listmbinfo
            {
                decimal Sortnum = OpcServer.listUnionTaskGroup[mainBelt - 1].ReadD(ReadIndex).CastTo <decimal>(0); //任务号


                if (Sortnum > 0)//任务号不为0
                {
                    MainBeltInfo info = new MainBeltInfo();

                    //info.Place = (listMainBelt[mainbelt - 1].ReadD((ReadIndex + 1)).CastTo<int>(-1) / 1000);//位置(米)
                    info.SortNum      = Sortnum;                                                                                                           //任务号
                    info.Place        = Convert.ToDecimal((OpcServer.listUnionTaskGroup[mainBelt - 1].ReadD((ReadIndex + 1)).CastTo <double>(-1) / 1000)); //(listMainBelt[mainbelt - 1].ReadD((ReadIndex + 1)).CastTo<int>(-1) / 1000000);//位置(米)
                    info.Quantity     = Convert.ToDecimal(OpcServer.listUnionTaskGroup[mainBelt - 1].ReadD((ReadIndex + 2)).CastTo <int>(-1));             //数量
                    info.mainbelt     = mainBelt.ToString();                                                                                               //主皮带
                    info.SortNumList  = SortNumList;
                    info.QuantityList = QuantityList;
                    ListmbInfo.Add(info);
                }
                ReadIndex = ReadIndex + 3;
            }
            MainBeltInfoService.GetMainBeltInfo(ListmbInfo); //填充完成之后传进方法 计算 ,
            ListmbInfo = ListmbInfo.OrderBy(x => x.Place).ToList();
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List <MainBeltInfo>));

            using (MemoryStream ms = new MemoryStream())
            {
                ser.WriteObject(ms, ListmbInfo);
                return(Encoding.UTF8.GetString(ms.ToArray()));
            }
        }
Example #5
0
        /// <summary>
        /// 预分拣皮带
        /// </summary>
        /// <param name="GroupNo"></param>
        /// <returns></returns>
        public string GetSortBelt(int GroupNo)
        {
            string conncetionGroupStr = "S7:[FJConnectionGroup1]";//默认为第一组

            if (GroupNo == 1 || GroupNo == 2)
            {
                conncetionGroupStr = "S7:[FJConnectionGroup1]";
            }
            else if (GroupNo == 3 || GroupNo == 4)
            {
                conncetionGroupStr = "S7:[FJConnectionGroup2]";
            }
            else if (GroupNo == 5 || GroupNo == 6)
            {
                conncetionGroupStr = "S7:[FJConnectionGroup3]";
            }
            else if (GroupNo == 7 || GroupNo == 8)
            {
                conncetionGroupStr = "S7:[FJConnectionGroup4]";
            }
            try
            {
                OpcServer.Connect(1, conncetionGroupStr);
            }
            catch (Exception ex)
            {
                return("远程连接失败,请检查网络");
            }
            List <MainBeltInfo> ListmbInfo = new List <MainBeltInfo>();

            if (GroupNo == 1 || GroupNo == 3 || GroupNo == 5 || GroupNo == 7)
            {
                int ReadIndex = 0;
                for (int i = 0; i < 40; i++)                                                            //从电控读取数据 填充 listmbinfo
                {
                    decimal Sortnum = OpcServer.listUnionTaskGroup[7].ReadD(ReadIndex).CastTo <int>(0); //任务号

                    if (Sortnum > 0)                                                                    //任务号不为0
                    {
                        MainBeltInfo info = new MainBeltInfo();
                        info.SortNum  = Sortnum;                                                                              //任务号
                        info.Place    = (OpcServer.listUnionTaskGroup[7].ReadD((ReadIndex + 1)).CastTo <decimal>(-1) / 1000); //位置(米)
                        info.Quantity = OpcServer.listUnionTaskGroup[7].ReadD((ReadIndex + 2)).CastTo <int>(-1);              //数量
                        info.GroupNO  = GroupNo;                                                                              //组号
                        ListmbInfo.Add(info);
                    }
                    ReadIndex = ReadIndex + 4;
                }
            }
            else
            {
                int ReadIndex = 0;
                for (int i = 0; i < 40; i++)                                                            //从电控读取数据 填充 listmbinfo
                {
                    decimal Sortnum = OpcServer.listUnionTaskGroup[8].ReadD(ReadIndex).CastTo <int>(0); //任务号

                    if (Sortnum > 0)                                                                    //任务号不为0
                    {
                        MainBeltInfo info = new MainBeltInfo();
                        info.SortNum  = Sortnum;                                                                              //任务号
                        info.Place    = (OpcServer.listUnionTaskGroup[8].ReadD((ReadIndex + 1)).CastTo <decimal>(-1) / 1000); //位置(米)
                        info.Quantity = OpcServer.listUnionTaskGroup[8].ReadD((ReadIndex + 2)).CastTo <int>(-1);              //数量

                        info.GroupNO = GroupNo;                                                                               //组号
                        ListmbInfo.Add(info);
                    }
                    ReadIndex = ReadIndex + 4;
                }
            }


            MainBeltInfoService.GetSortMainBeltInfo(ListmbInfo);    //填充完成之后传进方法 计算 ,
            ListmbInfo = ListmbInfo.OrderBy(a => a.Place).ToList(); //对距离任务号进行排序



            if (ListmbInfo.Count > 0)
            {
                if (ListmbInfo != null && ListmbInfo.Count > 0)
                {
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List <MainBeltInfo>));
                    using (MemoryStream ms = new MemoryStream())
                    {
                        ser.WriteObject(ms, ListmbInfo);
                        string s = Encoding.UTF8.GetString(ms.ToArray());
                        s = s.Replace("\\", "");
                        writeLog.Write("\r查询分拣:第" + GroupNo + "组\r");
                        return(s);
                    }
                }
                else
                {
                    writeLog.Write("GetSortBelt(" + GroupNo + ")查询结果集为空");
                    return("当前分拣组无数据,请重新查询!");
                }
            }
            else
            {
                writeLog.Write("GetSortBelt(" + GroupNo + ")读取DB块数据异常");
                return("从电控获取数据失败,请重新查询");
            }
        }
Example #6
0
        public string GetMainBelt(int mainBelt)
        {
            WriteLog writeLog = WriteLog.GetLog();

            try
            {
                OpcServer.Connect();
            }
            catch (Exception ex)
            {
                return("远程连接失败,请检查网络");
            }
            List <MainBeltInfo> ListmbInfo = new List <MainBeltInfo>();

            int ReadIndex = 0;

            double[]       nowplace     = new double[40];
            List <decimal> SortNumList  = new List <decimal>();
            List <decimal> QuantityList = new List <decimal>();

            for (int i = (mainBelt - 1) * 8; i < mainBelt * 8; i++)
            {
                SortNumList.Add(OpcServer.MachineGroup.ReadD(i).CastTo <decimal>(0));                              //任务号
                QuantityList.Add(OpcServer.MachineGroup.ReadD(32 + i).CastTo <decimal>(0));                        //任务号
            }
            for (int i = 0; i < 40; i++)                                                                           //从电控读取数据 填充 listmbinfo
            {
                decimal Sortnum = OpcServer.listUnionTaskGroup[mainBelt - 1].ReadD(ReadIndex).CastTo <decimal>(0); //任务号


                if (Sortnum > 0)//任务号不为0
                {
                    MainBeltInfo info = new MainBeltInfo();

                    //info.Place = (listMainBelt[mainbelt - 1].ReadD((ReadIndex + 1)).CastTo<int>(-1) / 1000);//位置(米)
                    info.SortNum      = Sortnum;                                                                                                           //任务号
                    info.Place        = Convert.ToDecimal((OpcServer.listUnionTaskGroup[mainBelt - 1].ReadD((ReadIndex + 1)).CastTo <double>(-1) / 1000)); //(listMainBelt[mainbelt - 1].ReadD((ReadIndex + 1)).CastTo<int>(-1) / 1000000);//位置(米)
                    info.Quantity     = Convert.ToDecimal(OpcServer.listUnionTaskGroup[mainBelt - 1].ReadD((ReadIndex + 2)).CastTo <int>(-1));             //数量
                    info.mainbelt     = mainBelt.ToString();                                                                                               //主皮带
                    info.SortNumList  = SortNumList;
                    info.QuantityList = QuantityList;
                    ListmbInfo.Add(info);
                }
                ReadIndex = ReadIndex + 3;
            }
            MainBeltInfoService.GetMainBeltInfo(ListmbInfo); //填充完成之后传进方法 计算 ,
            ListmbInfo = ListmbInfo.OrderBy(x => x.Place).ToList();
            foreach (var item in ListmbInfo)
            {
                foreach (var item2 in item.taskInfo)
                {
                    if (item2.groupno == 4)
                    {
                        item2.groupno = 3;
                    }
                    else if (item2.groupno == 3)
                    {
                        item2.groupno = 4;
                    }
                    if (item2.groupno == 7)
                    {
                        item2.groupno = 8;
                    }
                    else if (item2.groupno == 8)
                    {
                        item2.groupno = 7;
                    }
                }
            }
            if (ListmbInfo.Count > 0)
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List <MainBeltInfo>));
                using (MemoryStream ms = new MemoryStream())
                {
                    ser.WriteObject(ms, ListmbInfo);
                    string s = Encoding.UTF8.GetString(ms.ToArray());
                    s = s.Replace("\\", "");
                    writeLog.Write("\r查询合流:" + mainBelt + "号主皮带\r");
                    return(s);
                }
            }
            else
            {
                writeLog.Write("GetMainBelt(" + mainBelt + ")查询结果集为空");
                return("当前主皮带无数据,请重新查询!");
            }
        }
Example #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            PackageService service = new PackageService();
            //service.GetAllOrder(1);
            //List<T_PRODUCE_POKE> list = TaskService.getList(1, 1);
            //String list = AtsCellInService.getCellNoCode("1111111");
            List <MainBeltInfo> list = new List <MainBeltInfo>();
            MainBeltInfo        info = new MainBeltInfo();

            info.SortNum  = 72345;
            info.Quantity = 20;
            info.GroupNO  = 1;
            info.mainbelt = "1";
            list.Add(info);
            List <decimal> list1 = new List <decimal>();

            list1.Add(72370);
            list1.Add(72369);
            list1.Add(72362);
            list1.Add(72361);
            list1.Add(72360);
            list1.Add(72355);
            list1.Add(72352);
            list1.Add(72352);

            List <decimal> list2 = new List <decimal>();

            list2.Add(0);
            list2.Add(0);
            list2.Add(0);
            list2.Add(0);
            list2.Add(0);
            list2.Add(0);
            list2.Add(10);
            list2.Add(0);
            info.SortNumList  = list1;
            info.QuantityList = list2;
            MainBeltInfoService.GetMainBeltInfo(list);
            //  String str = "1203".Substring(0,2);


            List <MainBeltInfo> infolist = new List <MainBeltInfo>();
            MainBeltInfo        info1    = new MainBeltInfo();

            info1.SortNum = 71069;
            // info.GroupNO = 1;
            info1.Quantity = 1;
            info1.mainbelt = "2";
            infolist.Add(info);
            MainBeltInfoService.GetMainBeltInfo(infolist);
            // OpenSerialPort();
            //  OpenSerialPort1();
            if (info1.Quantity == 1)
            {
                return;
            }
            try
            {
                // throw(new Exception());


                string ls_pass;

                ls_pass = textBox2.Text;
                ls_pass = Security.MD5Encrypt(ls_pass).ToLower();
                if (ls_pass == "")
                {
                    MessageBox.Show("请输入密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (SysUserService.Login(txtUserName.Text, ls_pass))
                {
                    Constant.userName = txtUserName.Text.Trim();
                    DialogResult      = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("用户名密码不对,请重新输入!");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }