/// <summary> /// 获取设备的传感器列表 /// </summary> /// <param name="strDeviceId"></param> /// <returns></returns> public SensorInfoCollection GetSensorInfos(string strDeviceId) { try { SensorInfoCollection infos = new SensorInfoCollection(); string strSQL = "select * from v_sensorinfo where DeviceId=?DeviceId"; List <MySqlParameter> sqlParameters = new List <MySqlParameter> { new MySqlParameter("?DeviceId", strDeviceId) }; SensorInfo info = new SensorInfo(); Dictionary <string, Type> dEnum = new Dictionary <string, Type>(); dEnum.Add("ParType", typeof(SysHelper.Enums.DeviceParameterType)); CreateDataList <SensorInfo>(infos, strSQL, sqlParameters, info, dEnum); return(infos); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取生产线的所有设备集合 /// </summary> /// <param name="strAssemblyLineId"></param> /// <returns></returns> public DeviceInfoCollection GetAssemblyLineDevices(string strAssemblyLineId) { try { DeviceInfoCollection infos = new DeviceInfoCollection(); string strSQL = "select *from v_assemblylinedevices where AssemblyLineId=?AssemblyLineId"; List <MySqlParameter> sqlParameters = new List <MySqlParameter> { new MySqlParameter("?AssemblyLineId", strAssemblyLineId) }; DeviceInfo info = new DeviceInfo(); CreateDataList <DeviceInfo>(infos, strSQL, sqlParameters, info, null); //按设备获取对应的传感器集合 foreach (DeviceInfo item in infos) { string strDeviceId = item.DeviceId; SensorInfoCollection sensors = GetSensorInfos(strDeviceId); item.Sensors = sensors; } return(infos); } catch (Exception ex) { throw ex; } }
public DeviceInfo() { Sensors = new SensorInfoCollection(); }