示例#1
0
        public OpcClient()
        {
            xmlSettings         = new XMLSettings();
            m_productionInfoDao = new ProductionInfoDao();
            m_statusInfoDao     = new StatusInfoDao();
            m_uaClient          = new UaClient();
            db203Site_KeyValue  = new Dictionary <string, string>();

            xmlSettings.ReadXMLSettings();
            db203Site_KeyValue.Add("Heartbeat", xmlSettings.Heartbeat);
            db203Site_KeyValue.Add("WorkpieceType", xmlSettings.WorkpieceType);
            db203Site_KeyValue.Add("PrimerColor", xmlSettings.PrimerColor);
            db203Site_KeyValue.Add("PrimerCraft", xmlSettings.PrimerCraft);
            db203Site_KeyValue.Add("PrimerFirm", xmlSettings.PrimerFirm);
            db203Site_KeyValue.Add("PigmentedCoatingColor", xmlSettings.PigmentedCoatingColor);
            db203Site_KeyValue.Add("PigmentedCoatingCraft", xmlSettings.PigmentedCoatingCraft);
            db203Site_KeyValue.Add("PigmentedCoatingFirm", xmlSettings.PigmentedCoatingFirm);
            db203Site_KeyValue.Add("VarnishColor", xmlSettings.VarnishColor);
            db203Site_KeyValue.Add("VarnishCraft", xmlSettings.VarnishCraft);
            db203Site_KeyValue.Add("VarnishFirm", xmlSettings.VarnishFirm);
            db203Site_KeyValue.Add("BatchNo", xmlSettings.BatchNo);
            db203Site_KeyValue.Add("Receive_1", xmlSettings.Receive_1);
            db203Site_KeyValue.Add("Receive_2", xmlSettings.Receive_2);
            db203Site_KeyValue.Add("Receive_3", xmlSettings.Receive_3);
            db203Site_KeyValue.Add("Receive_4", xmlSettings.Receive_4);
            db203Site_KeyValue.Add("Receive_5", xmlSettings.Receive_5);
            db203Site_KeyValue.Add("Receive_6", xmlSettings.Receive_6);
            db203Site_KeyValue.Add("Receive_7", xmlSettings.Receive_7);
            db203Site_KeyValue.Add("Receive_8", xmlSettings.Receive_8);
            db203Site_KeyValue.Add("Receive_9", xmlSettings.Receive_9);
            db203Site_KeyValue.Add("Receive_10", xmlSettings.Receive_10);
            db203Site_KeyValue.Add("TotalNum", xmlSettings.TotalNum);

            //m_uaClient = new OpcUaClient.UaClient();
        }
        private void UpWorkpiece()
        {
            Models.ProductionPlan production = this.gridView.GetRow(this.gridView.FocusedRowHandle) as Models.ProductionPlan;
            //productionPlans.Add(production);

            if (m_xmlSettings == null)
            {
                m_xmlSettings = new XMLSettings();
                m_xmlSettings.ReadXMLSettings();
            }

            int result = opcClient.ReadDataFromOpcServer(m_xmlSettings.Count);

            if (!_isStop && result > 0)
            {
                this.gridView.SetRowCellValue(m_focusedRowHandle, "TotalNum", result);
            }

            _isStop            = true;
            m_focusedRowHandle = this.gridView.FocusedRowHandle;

            opcClient.WriteDataToOpcServer(m_xmlSettings.Count, (ushort)0);

            opcClient.WriteDataToOpcServer(production);
            RunAsync(() =>
            {
                ReadAsync(production.WorkpieceType, production.TotalNum, 0);
            });
        }
示例#3
0
        public StationInfoControl3()
        {
            InitializeComponent();
            opcClient = new OpcClient();

            m_xmlSettings = new XMLSettings();
            m_xmlSettings.ReadXMLSettings();

            GetDataValue();
        }
示例#4
0
        public LabelProductionInfoControl()
        {
            InitializeComponent();
            _productionInfoDao = new ProductionInfoDao();
            m_xmlSettings      = new XMLSettings();
            m_xmlSettings.ReadXMLSettings();

            m_uaClient = new OpcClient();
            //gridControl.DataSource = _productionInfoDao.GetDataSource();
        }
        public ProductionPlanControl()
        {
            InitializeComponent();
            m_productionPlanDao  = new ProductionPlanDao();
            m_productionPlanList = new BindingList <Models.ProductionPlan>();
            productionPlans      = new List <Models.ProductionPlan>();
            m_productionInfoDao  = new ProductionInfoDao();
            opcClient            = new OpcClient();
            string batchNo = DateTime.Now.ToString("yyyyMMdd");

            productionPlans        = m_productionPlanDao.GetDataSourceList(batchNo);
            gridControl.DataSource = productionPlans;

            Dictionary <object, string> dicButtons = new Dictionary <object, string>();

            dicButtons.Add("Up", "上件");
            dicButtons.Add("Stop", "暂停");
            //dicButtons.Add("Finish", "结束上件");
            RepositoryItemButtonEdit ribe = ItemOperation.CreateRepositoryItemButtonEdit(dicButtons);

            ribe.ButtonClick += new ButtonPressedEventHandler(this.ribe_ButtonClick);               //绑定事件

            this.gridView.Columns["Operating"].ColumnEdit = ribe;

            m_xmlSettings = new XMLSettings();
            m_xmlSettings.ReadXMLSettings();


            if (opcClient.WriteDataToOpcServer(m_xmlSettings.Count, (ushort)0))
            {
                opcClient.WriteDataToOpcServer(new Models.ProductionPlan
                {
                    BatchNo               = "0",
                    WorkpieceType         = "0",
                    PrimerColor           = "0",
                    PigmentedCoatingColor = "0",
                    VarnishColor          = "0",
                    WorkpieceNo           = "0",
                    PrimerFirm            = "0",
                    PrimerCraft           = "0",
                    PigmentedCoatingFirm  = "0",
                    PigmentedCoatingCraft = "0",
                    VarnishFirm           = "0",
                    VarnishCraft          = "0",
                    TotalNum              = 0
                });
            }

            Task t1 = Task.Run(() =>
            {
                byte data = 0;
                while (data < 128)
                {
                    try
                    {
                        opcClient.WriteDataToOpcServer(m_xmlSettings.Heartbeat, data);
                        data++;
                        if (data == 128)
                        {
                            data = 0;
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.WriteLog(LogFile.Warning, $"t1:{ex.Message}");
                    }
                }
            });

            Task t2 = Task.Run(() =>
            {
                while (true)
                {
                    try
                    {
                        short tagInitializationNo202 = Convert.ToInt16(opcClient.ReadData(m_xmlSettings.TagInitializationNo202).Value);
                        short tagInitializationNo203 = Convert.ToInt16(opcClient.ReadData(m_xmlSettings.TagInitializationNo203).Value);

                        if (tagInitializationNo202 >= tagInitializationNo203)
                        {
                            int value = tagInitializationNo202 <= 454 ? 454 : tagInitializationNo202;
                            opcClient.WriteStrDataToOpcServer(m_xmlSettings.TagInitializationNo203, $"{value}");
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.WriteLog(LogFile.Warning, $"t2:{ex.Message}");
                    }
                }
            });
        }
        /// <summary>
        /// 全部上件
        /// </summary>
        private void InstallAllWorkpiece()
        {
            _isStop = false;
            if (m_xmlSettings == null)
            {
                m_xmlSettings = new XMLSettings();
                m_xmlSettings.ReadXMLSettings();
            }

            opcClient.WriteDataToOpcServer(m_xmlSettings.Count, (ushort)0);

            int rowCount = this.gridView.RowCount;

            productionPlans = new List <Models.ProductionPlan>();
            for (int i = 0; i < rowCount; i++)
            {
                Models.ProductionPlan productionPlan = this.gridView.GetRow(i) as Models.ProductionPlan;
                productionPlans.Add(productionPlan);
            }

            Task t = Task.Run(() =>
            {
                for (int i = 0; i < productionPlans.Count; i++)
                {
                    Models.ProductionPlan production = productionPlans[i];
                    opcClient.WriteDataToOpcServer(production);
                    int result = 0;
                    while (production.TotalNum > result)
                    {
                        result = opcClient.ReadDataFromOpcServer(m_xmlSettings.Count);
                        RunInMainthread(() =>
                        {
                            this.lbl_CurrentInstall.Text   = $"当前上件的程序号:{production.WorkpieceType},已经上件{result}";
                            this.gridView.FocusedRowHandle = i;
                        });

                        if (_isStop)
                        {
                            RunInMainthread(() =>
                            {
                                this.lbl_CurrentInstall.Text = $"当前没有上件";
                            });
                            return;
                        }
                    }

                    if (production.TotalNum <= result)
                    {
                        if (opcClient.WriteDataToOpcServer(m_xmlSettings.Count, (ushort)0))
                        {
                            opcClient.WriteDataToOpcServer(new Models.ProductionPlan
                            {
                                BatchNo               = "0",
                                WorkpieceType         = "0",
                                PrimerColor           = "0",
                                PigmentedCoatingColor = "0",
                                VarnishColor          = "0",
                                WorkpieceNo           = "0",
                                PrimerFirm            = "0",
                                PrimerCraft           = "0",
                                PigmentedCoatingFirm  = "0",
                                PigmentedCoatingCraft = "0",
                                VarnishFirm           = "0",
                                VarnishCraft          = "0",
                                TotalNum              = 0
                            });
                        }
                        RunInMainthread(() =>
                        {
                            foreach (var windowsUIButton in this.windowsUIButtonPanel.Buttons)
                            {
                                if (windowsUIButton.GetType() == typeof(WindowsUIButton))
                                {
                                    WindowsUIButton button = (WindowsUIButton)windowsUIButton;
                                    if (button.Caption == "全部上件")
                                    {
                                        button.Enabled = true;
                                    }
                                }
                            }
                            this.lbl_CurrentInstall.Text   = $"当前没有上件";
                            this.gridView.FocusedRowHandle = 0;
                        });
                    }
                }
            });
        }