/// <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); }
/// <summary> /// 获取设备集合 /// </summary> /// <param name="server"></param> /// <returns></returns> private List <DC_DEVICE> GetDCDevices(string whereSql) { string sql = $"SELECT * FROM DC.DC_DEVICE WHERE 1=1 {whereSql}"; OracleDataReader reader = OracleDataHelper.ExecuteReader(sql); List <DC_DEVICE> lst = new List <DC_DEVICE>(); while (reader.Read()) { DC_DEVICE device = new DC_DEVICE() { CHANNEL = reader["CHANNEL"].ToString(), DESCRIPTION = reader["DESCRIPTION"].ToString(), ENABLE = GetValue(reader, "ENABLE"), ID = Convert.ToInt32(reader["ID"]), IP_ADDRESS = reader["IP_ADDRESS"].ToString(), MAC_ADDRESS = reader["MAC_ADDRESS"].ToString(), NAME = reader["NAME"].ToString(), NUM = reader["NUM"].ToString(), S7CONNECTION = reader["S7CONNECTION"].ToString(), SERVER_ID = GetValue(reader, "SERVER_ID"), CRA_ID = GetValue(reader, "CRA_ID"), FIELD1 = reader["FIELD1"].ToString(), FIELD2 = reader["FIELD2"].ToString(), FIELD3 = reader["FIELD3"].ToString(), }; lst.Add(device); } reader.Close(); return(lst); }
public int InsertDCDevice(DC_DEVICE device) { string sql = $@"INSERT INTO DC.DC_DEVICE( SERVER_ID, NUM, NAME, IP_ADDRESS, MAC_ADDRESS, CHANNEL, S7CONNECTION, DESCRIPTION, ENABLE, CRA_ID)VALUES( {GetValueStr(device.SERVER_ID)}, {GetValueStr(device.NUM)}, {GetValueStr(device.NAME)}, {GetValueStr(device.IP_ADDRESS)}, {GetValueStr(device.MAC_ADDRESS)}, {GetValueStr(device.CHANNEL)}, {GetValueStr(device.S7CONNECTION)}, {GetValueStr(device.DESCRIPTION)}, {GetValueStr(device.ENABLE)}, {GetValueStr(device.CRA_ID)} ) RETURNING ID INTO :ID"; OracleParameter para = new OracleParameter("ID", OracleDbType.Int32); int res = OracleDataHelper.ExecuteNonQuery(sql, new OracleParameter[] { para }); device.ID = ((OracleDecimal)para.Value).ToInt32(); return(res); }
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); }
/// <summary> /// 编辑plc /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void click_Modify_Device(object sender, RoutedEventArgs e) { DC_DEVICE device = (DC_DEVICE)(sender as FrameworkElement).Tag; w_Device window = new w_Device(device); if (window.ShowDialog() != true) { Load(); } }
/// <summary> /// 添加项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void click_Add_Config(object sender, RoutedEventArgs e) { DC_DEVICE device = (DC_DEVICE)(sender as FrameworkElement).Tag; w_Config window = new w_Config(device); if (window.ShowDialog() == true) { device.Configs.Add(window.Config); } }
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); }
/// <summary> /// opc注册组和数据点 /// </summary> /// <param name="device"></param> /// <param name="configs"></param> public static void OpcRegister(DC_DEVICE device, List <DC_DATA_CONFIG> configs) { OpcGroup opcGroup = new OpcGroup(device.ID); //创建组对象 OpcServer.Instance.AddGroup(opcGroup); //组添加到server opcGroup.DataReceived += OpcGroup_DataReceived; opcGroup.IsSubscribed = true; foreach (var config in configs) { OpcItem opcItem = new OpcItem(config.ID, device.CHANNEL + ":[" + device.S7CONNECTION + "]" + config.MEMORY_ADDRESS); //创建数据项对象 opcItem.IsActive = config.SUBSCRIPTION == 1?1:0; //当为0时,可读写,但不会订阅数据;为1时,可读写,会订阅数据 opcGroup.AddItem(opcItem); //项添加到组 } }
public u_Device(DC_DEVICE device) { Device = device; DC_Service dC_Service = new DC_Service(); try { Cranes = dC_Service.GetCranes(); } catch (Exception) { } InitializeComponent(); }
/// <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); } }
public int ModifyDevice(DC_DEVICE device) { string sql = $@"UPDATE DC.DC_DEVICE SET SERVER_ID={GetValueStr(device.SERVER_ID)}, NUM={GetValueStr(device.NUM)}, NAME={GetValueStr(device.NAME)}, IP_ADDRESS={GetValueStr(device.IP_ADDRESS)}, MAC_ADDRESS={GetValueStr(device.MAC_ADDRESS)}, CHANNEL={GetValueStr(device.CHANNEL)}, S7CONNECTION={GetValueStr(device.S7CONNECTION)}, DESCRIPTION={GetValueStr(device.DESCRIPTION)}, ENABLE={GetValueStr(device.ENABLE)}, CRA_ID={GetValueStr(device.CRA_ID)} WHERE ID={GetValueStr(device.ID)}"; return(OracleDataHelper.ExecuteNonQuery(sql)); }
/// <summary> /// 删除plc /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void click_Del_Device(object sender, RoutedEventArgs e) { if (MessageBox.Show("确认删除吗", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { DC_DEVICE device = (DC_DEVICE)(sender as FrameworkElement).Tag; try { dC_Service.DeleteDevice(device); MessageBox.Show("删除成功。"); DC_SERVER server = Servers.First(s => s.Devices.Contains(device)); server.Devices.Remove(device); } catch (Exception ex) { MessageBox.Show("删除异常。" + ex.Message); } } }
public w_Device(DC_DEVICE device) { IsModify = true; Device = device; DC_Service dC_Service = new DC_Service(); try { DataTable dt = dC_Service.GetCranes(); DataRow row = dt.NewRow(); row["CRA_NAME"] = "不是天车选这个"; dt.Rows.InsertAt(row, 0); Cranes = dt; } catch (Exception) { } InitializeComponent(); }
/// <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); } } }
public w_Config(DC_DEVICE device) { Config.DEVICE_ID = device.ID; InitializeComponent(); }
public int DeleteDevice(DC_DEVICE device) { string sql = $@"DELETE FROM DC.DC_DEVICE WHERE ID={GetValueStr(device.ID)}"; return(OracleDataHelper.ExecuteNonQuery(sql)); }
/// <summary> /// 获取数据点配置集合 /// </summary> /// <param name="device"></param> /// <returns></returns> public List <DC_DATA_CONFIG> GetDCDataConfigs(DC_DEVICE device) { return(GetDCDataConfigs($" AND DEVICE_ID={device.ID}")); }
/// <summary> /// 获取数据点配置集合 /// </summary> /// <param name="device"></param> /// <returns></returns> public List <DC_DATA_CONFIG> GetDCDataConfigs(DC_DEVICE device, int enable) { return(GetDCDataConfigs($" AND DEVICE_ID={device.ID} AND ENABLE={enable}")); }
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); } }