Пример #1
0
        /// <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;
        }
Пример #2
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()));
            }
        }
Пример #3
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("当前主皮带无数据,请重新查询!");
            }
        }
Пример #4
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);
            }
        }