/// <summary> /// 设备登录 /// </summary> /// <param name="_connId">连接ID</param> /// <param name="_prodName">产品名称</param> /// <param name="_devId">设备ID</param> /// <returns>登录是否成功</returns> public bool Login(DevInfo dev) { if (dev != null) { for (int i = 0; i < devList.Count; i++) { if (devList[i].DevId == dev.DevId) //设备Id存在,则进行更新 { devList[i].ConnId = dev.ConnId; devList[i].IsOnline = true; devList[i].ProdName = dev.ProdName; devList[i].ConnTime = dev.ConnTime; devList[i].LastActiveTime = dev.LastActiveTime; return(true); } } AddDevice(dev); //设备不存在,则添加一个设备 } return(false); }
/// <summary> /// 根据连接ID获取产品名称 /// </summary> /// <param name="_connId"></param> /// <returns></returns> public string GetProdName(uint _connId) { DevInfo dev = GetDevInfo(_connId); return((dev != null) ? dev.ProdName : string.Empty); }
/// <summary> /// 根据连接ID获取设备ID /// </summary> /// <param name="_connId"></param> /// <returns></returns> public uint GetDevId(uint _connId) { DevInfo dev = GetDevInfo(_connId); return((dev != null) ? dev.DevId : 0); }