Beispiel #1
0
        public void SetDValue(string str1, string str2, List <DTPlcInfoSimple> pLst, int num)
        {
            DTPlcInfoSimple p = getPsFromPslLst(str1, str2, pLst);

            if (p != null)
            {
                YbtdDevice.SetDValue(p, num);
            }
            else
            {
                // MessageBox.Show(Constant.SetDataFail);
            }
        }
Beispiel #2
0
        public bool SaveDeviceToSql()
        {
            //获取数据库表格数据
            //获取是否有数据操作
            //将现有数据更新到表格

            string    sql           = " SELECT * FROM " + YbdtWorkInfo.DeviceId;
            DataTable tempDataTable = SqlHelper.ExecuteDataTable(sql);

            foreach (DataRow dr in tempDataTable.Rows)
            {
                int    opInt    = 0;
                int    valueInt = 0;
                string binStr   = dr[Constant.Bin].ToString();

                if (int.TryParse(dr[Constant.strParam3].ToString(), out opInt) && (int.TryParse(dr[Constant.strParam4].ToString(), out valueInt)))
                {
                    if (opInt == Constant.sqlWrite)
                    {
                        DTPlcInfoSimple p = getPsFromPslLst(binStr, Constant.Read, PsLstAuto);
                        if (p.Area.Equals(Constant.strDMArea[0]) || p.Area.Equals(Constant.strDMArea[1]))
                        {
                            YbtdDevice.SetDValue(p, valueInt);
                        }
                        else
                        {
                            if (p.Area.Equals(Constant.strDMArea[3]) ||
                                p.Area.Equals(Constant.strDMArea[4]) ||
                                p.Area.Equals(Constant.strDMArea[5]) ||
                                p.Area.Equals(Constant.strDMArea[6])
                                )
                            {
                                if (valueInt == Constant.M_ON)
                                {
                                    YbtdDevice.SetMValueON(p);
                                }
                                if (valueInt == Constant.M_OFF)
                                {
                                    YbtdDevice.SetMValueOFF(p);
                                }
                            }
                        }
                    }
                }
            }


            UpdatePlcStatus(YbtdDevice.DataFormLst[0]);

            return(true);
        }