Esempio n. 1
0
 /// <summary>
 /// 异步写
 /// </summary>
 /// <param name="dataPoint"></param>
 /// <param name="value"></param>
 /// <param name="callBack"></param>
 public static void WriteAsync(DC_DATA_CONFIG config, dynamic value, Action <bool> callBack)
 {
     Task.Run(() =>
     {
         return(Write(config, value));
     }).ContinueWith(s => callBack?.Invoke(s.Result));
 }
Esempio n. 2
0
        private void LoadConfig(DC_DEVICE device)
        {
            DC_DATA_CONFIG time         = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_TIME");
            DC_DATA_CONFIG x            = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_X");
            DC_DATA_CONFIG y            = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_Y");
            DC_DATA_CONFIG l_y          = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_LITTLE_Y");
            DC_DATA_CONFIG z            = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_Z");
            DC_DATA_CONFIG l_z          = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_LITTLE_Z");
            DC_DATA_CONFIG wgt          = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_WEIGHT");
            DC_DATA_CONFIG l_wgt        = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_LITTLE_WEIGHT");
            DC_DATA_CONFIG symbol       = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_SYMBOL");
            DC_DATA_CONFIG count        = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_OBJ_COUNT");
            DC_DATA_CONFIG cNum         = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_CACHE_NUM");
            DC_DATA_CONFIG rNum         = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "ACTION_READED_NUM");
            ActionObject   actionObject = new ActionObject();

            actionObject.Operator             = Operator;
            actionObject.Cra_ID               = (int)device.CRA_ID;
            actionObject.ACTION_TIME          = time;
            actionObject.ACTION_X             = x;
            actionObject.ACTION_Y             = y;
            actionObject.ACTION_LITTLE_Y      = l_y;
            actionObject.ACTION_Z             = z;
            actionObject.ACTION_LITTLE_Z      = l_z;
            actionObject.ACTION_WEIGHT        = wgt;
            actionObject.ACTION_LITTLE_WEIGHT = l_wgt;
            actionObject.ACTION_SYMBOL        = symbol;
            actionObject.ACTION_OBJ_COUNT     = count;
            actionObject.ACTION_CACHE_NUM     = cNum;
            actionObject.ACTION_READED_NUM    = rNum;
            ActionObjects.Add(actionObject);
        }
Esempio n. 3
0
        public int DeleteDataConfig(DC_DATA_CONFIG config)
        {
            DeleteRealData(config.ID);
            string sql = $@"DELETE FROM DC.DC_DATA_CONFIG WHERE ID={GetValueStr(config.ID)}";

            return(OracleDataHelper.ExecuteNonQuery(sql));
        }
Esempio n. 4
0
 /// <summary>
 /// 异步读
 /// </summary>
 /// <param name="dataPoint"></param>
 /// <param name="callBacck"></param>
 public static void ReadAsync(DC_DATA_CONFIG config, Action <object> callBack)
 {
     Task.Run(() =>
     {
         return(Read(config));
     }).ContinueWith(s => callBack?.Invoke(s.Result));
 }
Esempio n. 5
0
        /// <summary>
        /// 复制项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void click_Copy_Config(object sender, RoutedEventArgs e)
        {
            DC_DATA_CONFIG config     = (DC_DATA_CONFIG)(sender as FrameworkElement).Tag;
            DC_DATA_CONFIG copyConfig = new DC_DATA_CONFIG()
            {
                IDENTITY_COLUMN      = config.IDENTITY_COLUMN,
                CONVERTER            = config.CONVERTER,
                DESCRIPTION          = config.DESCRIPTION,
                DEVICE_ID            = config.DEVICE_ID,
                ENABLE               = config.ENABLE,
                FIELD_DATA_LENGTH    = config.FIELD_DATA_LENGTH,
                FIELD_DATA_PRECISION = config.FIELD_DATA_PRECISION,
                FIELD_DATA_SCALE     = config.FIELD_DATA_SCALE,
                FIELD_DATA_TYPE      = config.FIELD_DATA_TYPE,
                MEMORY_ADDRESS       = config.MEMORY_ADDRESS,
                TABLE_NAME           = config.TABLE_NAME,
                SUBSCRIPTION         = config.SUBSCRIPTION,
                TABLE_USER           = config.TABLE_USER,
                NAME           = config.NAME,
                NUM            = config.NUM,
                FIELD_NAME     = config.FIELD_NAME,
                IDENTITY_VALUE = config.IDENTITY_VALUE,
            };

            dC_Service.InsertDataConfig(copyConfig);
            dC_Service.InsertRealData(copyConfig.ID);
            DC_SERVER server = Servers.First(s => s.Devices.FirstOrDefault(p => p.ID == config.DEVICE_ID) != null);
            DC_DEVICE device = server.Devices.First(s => s.ID == config.DEVICE_ID);

            device.Configs.Add(copyConfig);
        }
Esempio n. 6
0
        /// <summary>
        /// 同步读
        /// </summary>
        /// <param name="dataPointID"></param>
        /// <returns></returns>
        public static object Read(DC_DATA_CONFIG config)
        {
            if (config.DEVICE_ID == null)
            {
                throw new NullReferenceException("DEVICE_ID为空,无法进行读写");
            }
            int id = (int)config.DEVICE_ID;

            return(OpcServer.Instance.OpcGroups[id].Read(config.ID));
        }
Esempio n. 7
0
        /// <summary>
        /// 异步读
        /// </summary>
        /// <param name="dataPointID"></param>
        /// <returns></returns>
        public static void ReadAsync(DC_DATA_CONFIG config)
        {
            if (config.DEVICE_ID == null)
            {
                throw new NullReferenceException("DEVICE_ID为空,无法进行读写");
            }
            int id = (int)config.DEVICE_ID;

            OpcServer.Instance.OpcGroups[id].ReadAsync(config.ID);
        }
Esempio n. 8
0
        /// <summary>
        /// 异步写
        /// </summary>
        /// <param name="dataPointID"></param>
        /// <returns></returns>
        public static void WriteAsync(DC_DATA_CONFIG config, object value)
        {
            if (config.DEVICE_ID == null)
            {
                throw new NullReferenceException("DEVICE_ID为空,无法进行读写");
            }
            int id = (int)config.DEVICE_ID;

            OpcServer.Instance.OpcGroups[id].WriteAsync(config.ID, value);
        }
Esempio n. 9
0
        /// <summary>
        /// 编辑项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void click_Modify_Config(object sender, RoutedEventArgs e)
        {
            DC_DATA_CONFIG config = (DC_DATA_CONFIG)(sender as FrameworkElement).Tag;
            w_Config       window = new w_Config(config);

            if (window.ShowDialog() != true)
            {
                Load();
            }
        }
Esempio n. 10
0
        private void LoadConfig(DC_DEVICE device)
        {
            DC_DATA_CONFIG time      = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "CAL_TIME");
            DC_DATA_CONFIG flag      = BaseData.Configs.FirstOrDefault(s => s.DEVICE_ID == device.ID && s.NUM == "CAL_WRITE_FLAG");
            CalObject      calObject = new CalObject();

            calObject.Operator       = Operator;
            calObject.CAL_TIME       = time;
            calObject.CAL_WRITE_FLAG = flag;
            CalObjects.Add(calObject);
        }
Esempio n. 11
0
        /// <summary>
        /// 值的字符串
        /// </summary>
        /// <param name="config"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private string GetValueStr(DC_DATA_CONFIG config, DC_REAL_DATA data)
        {
            if (string.IsNullOrEmpty(data.VALUE))
            {
                return("null");
            }
            string type = config.FIELD_DATA_TYPE.ToUpper();

            if (type == "DATE")
            {
                return($"TO_DATE('{data.VALUE}','yyyy/mm/dd hh24:mi:ss')");
            }
            return($"'{data.VALUE}'");
        }
Esempio n. 12
0
        /// <summary>
        /// 复制plc
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void click_Copy_Device(object sender, RoutedEventArgs e)
        {
            DC_DEVICE device  = (DC_DEVICE)(sender as FrameworkElement).Tag;
            DC_DEVICE copyDev = new DC_DEVICE()
            {
                CHANNEL      = device.CHANNEL,
                CRA_ID       = device.CRA_ID,
                DESCRIPTION  = device.DESCRIPTION,
                ENABLE       = device.ENABLE,
                IP_ADDRESS   = device.IP_ADDRESS,
                MAC_ADDRESS  = device.MAC_ADDRESS,
                S7CONNECTION = device.S7CONNECTION,
                NAME         = device.NAME,
                NUM          = device.NUM,
                SERVER_ID    = device.SERVER_ID,
                Configs      = new ObservableCollection <DC_DATA_CONFIG>()
            };

            dC_Service.InsertDCDevice(copyDev);
            DC_SERVER server = Servers.First(s => s.Devices.Contains(device));

            server.Devices.Add(copyDev);
            foreach (var config in device.Configs)
            {
                DC_DATA_CONFIG copyConfig = new DC_DATA_CONFIG()
                {
                    IDENTITY_COLUMN      = config.IDENTITY_COLUMN,
                    CONVERTER            = config.CONVERTER,
                    DESCRIPTION          = config.DESCRIPTION,
                    DEVICE_ID            = copyDev.ID,
                    ENABLE               = config.ENABLE,
                    FIELD_DATA_LENGTH    = config.FIELD_DATA_LENGTH,
                    FIELD_DATA_PRECISION = config.FIELD_DATA_PRECISION,
                    FIELD_DATA_SCALE     = config.FIELD_DATA_SCALE,
                    FIELD_DATA_TYPE      = config.FIELD_DATA_TYPE,
                    MEMORY_ADDRESS       = config.MEMORY_ADDRESS,
                    TABLE_NAME           = config.TABLE_NAME,
                    SUBSCRIPTION         = config.SUBSCRIPTION,
                    TABLE_USER           = config.TABLE_USER,
                    NAME           = config.NAME,
                    NUM            = config.NUM,
                    FIELD_NAME     = config.FIELD_NAME,
                    IDENTITY_VALUE = config.IDENTITY_VALUE,
                };
                dC_Service.InsertDataConfig(copyConfig);
                dC_Service.InsertRealData(copyConfig.ID);
                copyDev.Configs.Add(copyConfig);
            }
        }
Esempio n. 13
0
        public int InsertDataConfig(DC_DATA_CONFIG config)
        {
            string          sql  = $@"INSERT INTO DC.DC_DATA_CONFIG(
DEVICE_ID, 
NUM, 
NAME, 
MEMORY_ADDRESS, 
SUBSCRIPTION, 
DESCRIPTION, 
ENABLE,
TABLE_USER,
TABLE_NAME,
IDENTITY_COLUMN,
IDENTITY_VALUE,
FIELD_NAME,
FIELD_DATA_TYPE,
FIELD_DATA_LENGTH,
FIELD_DATA_PRECISION,
FIELD_DATA_SCALE,
CONVERTER
)VALUES(
{GetValueStr(config.DEVICE_ID)},
{GetValueStr(config.NUM)},
{GetValueStr(config.NAME)},
{GetValueStr(config.MEMORY_ADDRESS)},
{GetValueStr(config.SUBSCRIPTION)},
{GetValueStr(config.DESCRIPTION)},
{GetValueStr(config.ENABLE)},
{GetValueStr(config.TABLE_USER)},
{GetValueStr(config.TABLE_NAME)},
{GetValueStr(config.IDENTITY_COLUMN)},
{GetValueStr(config.IDENTITY_VALUE)},
{GetValueStr(config.FIELD_NAME)},
{GetValueStr(config.FIELD_DATA_TYPE)},
{GetValueStr(config.FIELD_DATA_LENGTH)},
{GetValueStr(config.FIELD_DATA_PRECISION)},
{GetValueStr(config.FIELD_DATA_SCALE)},
{GetValueStr(config.CONVERTER)}
) RETURNING ID INTO :ID";
            OracleParameter para = new OracleParameter("ID", OracleDbType.Int32);
            int             res  = OracleDataHelper.ExecuteNonQuery(sql, new OracleParameter[] { para });

            config.ID = ((OracleDecimal)para.Value).ToInt32();
            InsertRealData(config.ID);
            return(res);
        }
Esempio n. 14
0
 /// <summary>
 /// 删除项
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void click_Del_Config(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("确认删除吗", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
     {
         DC_DATA_CONFIG config = (DC_DATA_CONFIG)(sender as FrameworkElement).Tag;
         try
         {
             dC_Service.DeleteDataConfig(config);
             dC_Service.DeleteRealData(config.ID);
             MessageBox.Show("删除成功。");
             DC_SERVER server = Servers.First(s => s.Devices.FirstOrDefault(p => p.ID == config.DEVICE_ID) != null);
             DC_DEVICE device = server.Devices.First(s => s.ID == config.DEVICE_ID);
             device.Configs.Remove(config);
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除异常。" + ex.Message);
         }
     }
 }
Esempio n. 15
0
        /// <summary>
        /// 获取数据点配置集合
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public List <DC_DATA_CONFIG> GetDCDataConfigs(string whereSql)
        {
            string                sql    = $"SELECT * FROM DC.DC_DATA_CONFIG WHERE 1=1 {whereSql}";
            OracleDataReader      reader = OracleDataHelper.ExecuteReader(sql);
            List <DC_DATA_CONFIG> lst    = new List <DC_DATA_CONFIG>();

            while (reader.Read())
            {
                DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                {
                    DESCRIPTION          = reader["DESCRIPTION"].ToString(),
                    ENABLE               = GetValue(reader, "ENABLE"),
                    ID                   = Convert.ToInt32(reader["ID"]),
                    NAME                 = reader["NAME"].ToString(),
                    NUM                  = reader["NUM"].ToString(),
                    DEVICE_ID            = GetValue(reader, "DEVICE_ID"),
                    CONVERTER            = GetValue(reader, "CONVERTER"),
                    FIELD_DATA_LENGTH    = GetValue(reader, "FIELD_DATA_LENGTH"),
                    FIELD_DATA_PRECISION = GetValue(reader, "FIELD_DATA_PRECISION"),
                    FIELD_DATA_SCALE     = GetValue(reader, "FIELD_DATA_SCALE"),
                    FIELD_DATA_TYPE      = GetValue(reader, "FIELD_DATA_TYPE"),
                    TABLE_NAME           = GetValue(reader, "TABLE_NAME"),
                    TABLE_USER           = GetValue(reader, "TABLE_USER"),
                    IDENTITY_VALUE       = GetValue(reader, "IDENTITY_VALUE"),
                    IDENTITY_COLUMN      = GetValue(reader, "IDENTITY_COLUMN"),
                    FIELD_NAME           = GetValue(reader, "FIELD_NAME"),
                    MEMORY_ADDRESS       = reader["MEMORY_ADDRESS"].ToString(),
                    SUBSCRIPTION         = GetValue(reader, "SUBSCRIPTION"),
                    FIELD1               = reader["FIELD1"].ToString(),
                    FIELD2               = reader["FIELD2"].ToString(),
                    FIELD3               = reader["FIELD3"].ToString(),
                };
                lst.Add(config);
            }
            reader.Close();
            return(lst);
        }
Esempio n. 16
0
        public int ModifyDataConfig(DC_DATA_CONFIG config)
        {
            string sql = $@"UPDATE DC.DC_DATA_CONFIG SET
DEVICE_ID={GetValueStr(config.DEVICE_ID)},
NUM={GetValueStr(config.NUM)},
NAME={GetValueStr(config.NAME)},
MEMORY_ADDRESS={GetValueStr(config.MEMORY_ADDRESS)},
SUBSCRIPTION={GetValueStr(config.SUBSCRIPTION)},
DESCRIPTION={GetValueStr(config.DESCRIPTION)},
ENABLE={GetValueStr(config.ENABLE)},
TABLE_USER={GetValueStr(config.TABLE_USER)},
TABLE_NAME={GetValueStr(config.TABLE_NAME)},
IDENTITY_COLUMN={GetValueStr(config.IDENTITY_COLUMN)},
IDENTITY_VALUE={GetValueStr(config.IDENTITY_VALUE)},
FIELD_NAME={GetValueStr(config.FIELD_NAME)},
FIELD_DATA_TYPE={GetValueStr(config.FIELD_DATA_TYPE)},
FIELD_DATA_LENGTH={GetValueStr(config.FIELD_DATA_LENGTH)},
FIELD_DATA_PRECISION={GetValueStr(config.FIELD_DATA_PRECISION)},
FIELD_DATA_SCALE={GetValueStr(config.FIELD_DATA_SCALE)},
CONVERTER={GetValueStr(config.CONVERTER)} WHERE ID='{config.ID}'
";

            return(OracleDataHelper.ExecuteNonQuery(sql));
        }
Esempio n. 17
0
        private void btn_OK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DC_SERVER   server = this.cmb_Server.SelectedItem as DC_SERVER;
                DataRowView cra    = this.cmb_Crane.SelectedItem as DataRowView;

                DC_DEVICE device = new DC_DEVICE()
                {
                    CHANNEL      = "S7",
                    CRA_ID       = Convert.ToInt32(cra["ID"]),
                    ENABLE       = 1,
                    NAME         = cra["CRA_NAME"].ToString(),
                    NUM          = cra["CRA_NUM"].ToString(),
                    S7CONNECTION = this.txt_Conn.Text.Trim(),
                    DESCRIPTION  = cra["CRA_NAME"].ToString(),
                    SERVER_ID    = server.ID,
                    Configs      = new ObservableCollection <DC_DATA_CONFIG>(),
                };
                dC_Service.InsertDCDevice(device);

                DataTable columnInfo = dC_Service.GetColumns("CRANE_REAL_INFO");

                {
                    DataRow        row    = columnInfo.Rows.Cast <DataRow>().First(s => s["COLUMN_NAME"].ToString() == "COORD_X");
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM                  = "REAL_X",
                        NAME                 = "实时_X",
                        MEMORY_ADDRESS       = "DB1,DINT4000",
                        DESCRIPTION          = "实时_X",
                        SUBSCRIPTION         = 1,
                        DEVICE_ID            = device.ID,
                        ENABLE               = 1,
                        IDENTITY_VALUE       = dC_Service.GetCraRealInfoID(cra["ID"].ToString()),
                        TABLE_USER           = "******",
                        TABLE_NAME           = "CRANE_REAL_INFO",
                        FIELD_NAME           = row["COLUMN_NAME"].ToString(),
                        FIELD_DATA_TYPE      = row["DATA_TYPE"].ToString(),
                        FIELD_DATA_LENGTH    = GetValue(row["DATA_LENGTH"]),
                        FIELD_DATA_PRECISION = GetValue(row["DATA_PRECISION"]),
                        FIELD_DATA_SCALE     = GetValue(row["DATA_SCALE"]),
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DataRow        row    = columnInfo.Rows.Cast <DataRow>().First(s => s["COLUMN_NAME"].ToString() == "COORD_Y");
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM                  = "REAL_Y",
                        NAME                 = "实时_Y",
                        MEMORY_ADDRESS       = "DB1,DINT4004",
                        DESCRIPTION          = "实时_Y",
                        SUBSCRIPTION         = 1,
                        DEVICE_ID            = device.ID,
                        ENABLE               = 1,
                        IDENTITY_VALUE       = dC_Service.GetCraRealInfoID(cra["ID"].ToString()),
                        TABLE_USER           = "******",
                        TABLE_NAME           = "CRANE_REAL_INFO",
                        FIELD_NAME           = row["COLUMN_NAME"].ToString(),
                        FIELD_DATA_TYPE      = row["DATA_TYPE"].ToString(),
                        FIELD_DATA_LENGTH    = GetValue(row["DATA_LENGTH"]),
                        FIELD_DATA_PRECISION = GetValue(row["DATA_PRECISION"]),
                        FIELD_DATA_SCALE     = GetValue(row["DATA_SCALE"]),
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DataRow        row    = columnInfo.Rows.Cast <DataRow>().First(s => s["COLUMN_NAME"].ToString() == "LITTLE_HOOK_Y");
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM                  = "REAL_LITTLE_Y",
                        NAME                 = "实时_副Y",
                        MEMORY_ADDRESS       = "DB1,DINT4008",
                        DESCRIPTION          = "实时_副Y",
                        SUBSCRIPTION         = 1,
                        DEVICE_ID            = device.ID,
                        ENABLE               = 1,
                        IDENTITY_VALUE       = dC_Service.GetCraRealInfoID(cra["ID"].ToString()),
                        TABLE_USER           = "******",
                        TABLE_NAME           = "CRANE_REAL_INFO",
                        FIELD_NAME           = row["COLUMN_NAME"].ToString(),
                        FIELD_DATA_TYPE      = row["DATA_TYPE"].ToString(),
                        FIELD_DATA_LENGTH    = GetValue(row["DATA_LENGTH"]),
                        FIELD_DATA_PRECISION = GetValue(row["DATA_PRECISION"]),
                        FIELD_DATA_SCALE     = GetValue(row["DATA_SCALE"]),
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DataRow        row    = columnInfo.Rows.Cast <DataRow>().First(s => s["COLUMN_NAME"].ToString() == "COORD_Z");
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM                  = "REAL_Z",
                        NAME                 = "实时_Z",
                        MEMORY_ADDRESS       = "DB1,DINT4012",
                        DESCRIPTION          = "实时_Z",
                        SUBSCRIPTION         = 1,
                        DEVICE_ID            = device.ID,
                        ENABLE               = 1,
                        IDENTITY_VALUE       = dC_Service.GetCraRealInfoID(cra["ID"].ToString()),
                        TABLE_USER           = "******",
                        TABLE_NAME           = "CRANE_REAL_INFO",
                        FIELD_NAME           = row["COLUMN_NAME"].ToString(),
                        FIELD_DATA_TYPE      = row["DATA_TYPE"].ToString(),
                        FIELD_DATA_LENGTH    = GetValue(row["DATA_LENGTH"]),
                        FIELD_DATA_PRECISION = GetValue(row["DATA_PRECISION"]),
                        FIELD_DATA_SCALE     = GetValue(row["DATA_SCALE"]),
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DataRow        row    = columnInfo.Rows.Cast <DataRow>().First(s => s["COLUMN_NAME"].ToString() == "LITTLE_HOOK_Z");
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM                  = "REAL_LITTLE_Z",
                        NAME                 = "实时_副Z",
                        MEMORY_ADDRESS       = "DB1,DINT4016",
                        DESCRIPTION          = "实时_副Z",
                        SUBSCRIPTION         = 1,
                        DEVICE_ID            = device.ID,
                        ENABLE               = 1,
                        IDENTITY_VALUE       = dC_Service.GetCraRealInfoID(cra["ID"].ToString()),
                        TABLE_USER           = "******",
                        TABLE_NAME           = "CRANE_REAL_INFO",
                        FIELD_NAME           = row["COLUMN_NAME"].ToString(),
                        FIELD_DATA_TYPE      = row["DATA_TYPE"].ToString(),
                        FIELD_DATA_LENGTH    = GetValue(row["DATA_LENGTH"]),
                        FIELD_DATA_PRECISION = GetValue(row["DATA_PRECISION"]),
                        FIELD_DATA_SCALE     = GetValue(row["DATA_SCALE"]),
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DataRow        row    = columnInfo.Rows.Cast <DataRow>().First(s => s["COLUMN_NAME"].ToString() == "WEIGHT");
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM                  = "REAL_WEIGHT",
                        NAME                 = "实时_主钩重量",
                        MEMORY_ADDRESS       = "DB1,DINT4020",
                        DESCRIPTION          = "实时_主钩重量",
                        SUBSCRIPTION         = 1,
                        DEVICE_ID            = device.ID,
                        ENABLE               = 1,
                        IDENTITY_VALUE       = dC_Service.GetCraRealInfoID(cra["ID"].ToString()),
                        TABLE_USER           = "******",
                        TABLE_NAME           = "CRANE_REAL_INFO",
                        FIELD_NAME           = row["COLUMN_NAME"].ToString(),
                        FIELD_DATA_TYPE      = row["DATA_TYPE"].ToString(),
                        FIELD_DATA_LENGTH    = GetValue(row["DATA_LENGTH"]),
                        FIELD_DATA_PRECISION = GetValue(row["DATA_PRECISION"]),
                        FIELD_DATA_SCALE     = GetValue(row["DATA_SCALE"]),
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DataRow        row    = columnInfo.Rows.Cast <DataRow>().First(s => s["COLUMN_NAME"].ToString() == "LITTLE_HOOK_WEIGHT");
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM                  = "REAL_LITTLE_WEIGHT",
                        NAME                 = "实时_副钩重量",
                        MEMORY_ADDRESS       = "DB1,DINT4024",
                        DESCRIPTION          = "实时_副钩重量",
                        SUBSCRIPTION         = 1,
                        DEVICE_ID            = device.ID,
                        ENABLE               = 1,
                        IDENTITY_VALUE       = dC_Service.GetCraRealInfoID(cra["ID"].ToString()),
                        TABLE_USER           = "******",
                        TABLE_NAME           = "CRANE_REAL_INFO",
                        FIELD_NAME           = row["COLUMN_NAME"].ToString(),
                        FIELD_DATA_TYPE      = row["DATA_TYPE"].ToString(),
                        FIELD_DATA_LENGTH    = GetValue(row["DATA_LENGTH"]),
                        FIELD_DATA_PRECISION = GetValue(row["DATA_PRECISION"]),
                        FIELD_DATA_SCALE     = GetValue(row["DATA_SCALE"]),
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DataRow        row    = columnInfo.Rows.Cast <DataRow>().First(s => s["COLUMN_NAME"].ToString() == "OBJ_COUNT");
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM                  = "REAL_OBJ_COUNT",
                        NAME                 = "实时_吊物数量",
                        MEMORY_ADDRESS       = "DB1,B4029",
                        DESCRIPTION          = "实时_吊物数量",
                        SUBSCRIPTION         = 1,
                        DEVICE_ID            = device.ID,
                        ENABLE               = 1,
                        IDENTITY_VALUE       = dC_Service.GetCraRealInfoID(cra["ID"].ToString()),
                        TABLE_USER           = "******",
                        TABLE_NAME           = "CRANE_REAL_INFO",
                        FIELD_NAME           = row["COLUMN_NAME"].ToString(),
                        FIELD_DATA_TYPE      = row["DATA_TYPE"].ToString(),
                        FIELD_DATA_LENGTH    = GetValue(row["DATA_LENGTH"]),
                        FIELD_DATA_PRECISION = GetValue(row["DATA_PRECISION"]),
                        FIELD_DATA_SCALE     = GetValue(row["DATA_SCALE"]),
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DataRow        row    = columnInfo.Rows.Cast <DataRow>().First(s => s["COLUMN_NAME"].ToString() == "IS_ONLINE");
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM                  = "REAL_IS_ONLINE",
                        NAME                 = "实时_网络状态",
                        MEMORY_ADDRESS       = "&statepathval()",
                        DESCRIPTION          = "实时_网络状态",
                        SUBSCRIPTION         = 1,
                        DEVICE_ID            = device.ID,
                        ENABLE               = 1,
                        IDENTITY_VALUE       = dC_Service.GetCraRealInfoID(cra["ID"].ToString()),
                        TABLE_USER           = "******",
                        TABLE_NAME           = "CRANE_REAL_INFO",
                        FIELD_NAME           = row["COLUMN_NAME"].ToString(),
                        FIELD_DATA_TYPE      = row["DATA_TYPE"].ToString(),
                        FIELD_DATA_LENGTH    = GetValue(row["DATA_LENGTH"]),
                        FIELD_DATA_PRECISION = GetValue(row["DATA_PRECISION"]),
                        FIELD_DATA_SCALE     = GetValue(row["DATA_SCALE"]),
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_X",
                        NAME           = "动作_X",
                        MEMORY_ADDRESS = "DB1,DINT4054",
                        DESCRIPTION    = "动作_X",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_Y",
                        NAME           = "动作_Y",
                        MEMORY_ADDRESS = "DB1,DINT4058",
                        DESCRIPTION    = "动作_Y",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_LITTLE_Y",
                        NAME           = "动作_副Y",
                        MEMORY_ADDRESS = "DB1,DINT4062",
                        DESCRIPTION    = "动作_副Y",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_Z",
                        NAME           = "动作_Z",
                        MEMORY_ADDRESS = "DB1,DINT4066",
                        DESCRIPTION    = "动作_Z",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_LITTLE_Z",
                        NAME           = "动作_副Z",
                        MEMORY_ADDRESS = "DB1,DINT4070",
                        DESCRIPTION    = "动作_副Z",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_WEIGHT",
                        NAME           = "动作_主钩重量",
                        MEMORY_ADDRESS = "DB1,DINT4074",
                        DESCRIPTION    = "动作_主钩重量",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_LITTLE_WEIGHT",
                        NAME           = "动作_副钩重量",
                        MEMORY_ADDRESS = "DB1,DINT4078",
                        DESCRIPTION    = "动作_副钩重量",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_SYMBOL",
                        NAME           = "动作_动作类型",
                        MEMORY_ADDRESS = "DB1,B4082",
                        DESCRIPTION    = "动作_动作类型",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_OBJ_COUNT",
                        NAME           = "动作_吊物数量",
                        MEMORY_ADDRESS = "DB1,B4083",
                        DESCRIPTION    = "动作_吊物数量",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_CACHE_NUM",
                        NAME           = "动作_缓存序号",
                        MEMORY_ADDRESS = "DB1,DINT4050",
                        DESCRIPTION    = "动作_缓存序号",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_READED_NUM",
                        NAME           = "动作_已读序号",
                        MEMORY_ADDRESS = "DB1,DINT4035",
                        DESCRIPTION    = "动作_已读序号",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "ACTION_TIME",
                        NAME           = "动作_动作时间",
                        MEMORY_ADDRESS = "DB1,B4084,6",
                        DESCRIPTION    = "动作_动作时间",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "CAL_TIME",
                        NAME           = "校正_校正时间",
                        MEMORY_ADDRESS = "DB1,B4100,6",
                        DESCRIPTION    = "校正_校正时间",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                {
                    DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                    {
                        NUM            = "CAL_WRITE_FLAG",
                        NAME           = "校正_写入标志",
                        MEMORY_ADDRESS = "DB1,B4106",
                        DESCRIPTION    = "校正_写入标志",
                        SUBSCRIPTION   = 0,
                        DEVICE_ID      = device.ID,
                        ENABLE         = 1,
                    };
                    dC_Service.InsertDataConfig(config);
                    device.Configs.Add(config);
                }

                MessageBox.Show("操作成功。");

                AddCraSuccess?.Invoke(server, device);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 18
0
 /// <summary>
 /// 读
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public object Read(DC_DATA_CONFIG config)
 {
     return(OpcHelper.Read(config));
 }
Esempio n. 19
0
 /// <summary>
 /// 写
 /// </summary>
 /// <param name="config"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public bool Write(DC_DATA_CONFIG config, object value)
 {
     return(OpcHelper.Write(config, value));
 }
Esempio n. 20
0
 public w_Config(DC_DATA_CONFIG config)
 {
     IsModify = true;
     Config   = config;
     InitializeComponent();
 }
Esempio n. 21
0
 public u_Config(DC_DATA_CONFIG config)
 {
     Config = config;
     InitializeComponent();
 }