123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- //
- // IHLightModel.swift
- // Inhealth
- //
- // Created by weclouds on 2019/12/10.
- // Copyright © 2019 weclouds. All rights reserved.
- //
- import UIKit
- import SwiftyJSON
- ///操作
- struct Operation_Result {
- var code : HttpApiStatus?
- var msg : String?
- }
- ///操作
- class Operation_Info: NSObject {
- var result : Operation_Result?
- var isSuccess : Bool
- var status : HttpApiStatus?
-
- init(result:Operation_Result?, isSuccess:Bool, status:HttpApiStatus?) {
- self.result = result; self.isSuccess = isSuccess; self.status = status
- }
-
- static func fromJSON(_ json:JSON) -> Operation_Info? {
- let code = HttpApiStatus(rawValue: json["code"].stringValue)
- let msg = json["msg"].stringValue
- var result = Operation_Result()
- result.msg = msg
- result.code = code
- var isSuccess = false
- if code == .Success {
- isSuccess = true
- }
- return Operation_Info(result: result, isSuccess: isSuccess, status: code)
- }
- }
- struct DevData {
- var id :String?//
- var name :String?//设备名称
- var devType:String? //设备类型(1 lights,2 circadian lights,3 sensor,4 air purifiers)
- var status:String?//开关状态(0 关,1 开)(lights,circadian lights,air purifiers设备使用)
- var online:String?// 网络状态(0 离线,1 在线)(sensor 设备使用)
- var level:String?//开关等级(air purifiers设备使用)
- var light:String?//亮度值(lights,circadian lights 设备使用)
- var color:String?//色温值(lights,circadian lights 设备使用)
- var alarmStatus:String? //故障状态(0 正常,1 异常)
- var alarmInfo : String? //故障内容
- var number:String?//房间号
- var image:String? // 设备图片地址
- var deviceId:String? // 设备地址
- var floorId:String? //楼层id
- var roomId:String? //房间id
- var floor:String? // 楼层数
- var mode :String? // 设备型号-酒店(0 WE-L10,1 WE-L20,2 WE-CL10,3 WE-CL20)(lights,circadian lights设备使用)
- //设备型号-学校(教室灯 0=>EL-DP02-1200-LY,1=>EL-DP03-1200-LY,2=>EL-WKDP03-1200-LY,黑板灯 0=>EL-HZJ01-1200-LY)
- var type : String? //设备类型(4 教室灯,5 黑板灯,6 窗帘,7 面板):教室
- var brightness: String? //亮度 : 教室
- var gatewayId: String? //网关id
-
-
- }
- struct Dev_list_Result {
- var code : HttpApiStatus?
- var msg : String?
- var list : [DevData]?
- }
- class Dev_list_Info: NSObject {
- var result : Dev_list_Result?
- var isSuccess : Bool
- var status : HttpApiStatus?
-
- init(result:Dev_list_Result?, isSuccess:Bool, status:HttpApiStatus?) {
- self.result = result; self.isSuccess = isSuccess; self.status = status
- }
-
- static func fromJSON(_ json:JSON) -> Dev_list_Info? {
-
- let code = HttpApiStatus(rawValue: json["code"].stringValue)
- let msg = json["msg"].stringValue
- let data = json["data"]
- let list = data["list"]
- var mList = [DevData]()
- guard let lightlist = list.array else { return nil }
- for vJSON in lightlist {
- var light = DevData()
- light.id = vJSON["id"].stringValue
- light.name = vJSON["name"].stringValue
- light.devType = vJSON["devType"].stringValue
- light.status = vJSON["status"].stringValue
- light.online = vJSON["online"].stringValue
- light.level = vJSON["level"].stringValue
- light.light = vJSON["light"].stringValue
- light.color = vJSON["color"].stringValue
- light.alarmStatus = vJSON["alarmStatus"].stringValue
- light.alarmInfo = vJSON["alarmInfo"].stringValue
- light.number = vJSON["roomNumber"].stringValue
- light.image = vJSON["image"].stringValue
- light.floorId = vJSON["floorId"].stringValue
- light.deviceId = vJSON["deviceId"].stringValue
- light.roomId = vJSON["roomId"].stringValue
- light.floor = vJSON["floor"].stringValue
- light.mode = vJSON["model"].stringValue
- //下面是教室才有的
- light.type = vJSON["type"].stringValue
- light.brightness = vJSON["brightness"].stringValue
- light.gatewayId = vJSON["gatewayId"].stringValue
- mList.append(light)
- }
-
- var isSuccess = false
- if code == .Success {
- isSuccess = true
- }
- let result = Dev_list_Result(code: code, msg: msg, list: mList)
- return Dev_list_Info(result: result, isSuccess: isSuccess, status: code)
- }
-
- }
- struct LightData {
- var id : String? // 设备id Y
- var name : String? // 设备名称 Y
- var deviceId : String? // 设备ID Y
- var floor : String? // 楼层 Y
- var roomNumber : String? // 房间号 Y
- var voltage : String? // 电压 Y
- var current :String? // 电流 Y
- var brightness : Int? // 亮度值 Y
- var color : Int? //: 色温值 Y
- var power : String? //: 功率值 Y
- var status : String?
- var online : String? // : 在线状态(0 离线,1 在线) Y
- var alarmStatus : String? // 故障状态(0 正常,1 故障) Y
- var model :String? // 设备型号(0 WE-L10,1 WE-L20,2 WE-CL10,3 WE-CL20)(lights,circadian lights设备使用)
- // var type : String? //设备类型(4 教室灯,5 黑板灯,6 窗帘,7 面板)
- }
- struct Light_list_Result {
- var code : HttpApiStatus?
- var msg : String?
- var list : [LightData]?
- var total : String? // 设备总数 Y
- }
- class Light_list_Info: NSObject {
- var result : Light_list_Result?
- var isSuccess : Bool
- var status : HttpApiStatus?
-
- init(result:Light_list_Result?, isSuccess:Bool, status:HttpApiStatus?) {
- self.result = result; self.isSuccess = isSuccess; self.status = status
- }
-
- static func fromJSON(_ json:JSON) -> Light_list_Info? {
- let code = HttpApiStatus(rawValue: json["code"].stringValue)
- let msg = json["msg"].stringValue
- let data = json["data"]
- let list = data["list"]
- var mList = [LightData]()
- guard let lightlist = list.array else { return nil }
- for vJSON in lightlist {
- var light = LightData()
- light.id = vJSON["id"].stringValue
- light.name = vJSON["name"].stringValue
- light.deviceId = vJSON["deviceId"].stringValue
- light.floor = vJSON["floor"].stringValue
- light.roomNumber = vJSON["roomNumber"].stringValue
- light.voltage = vJSON["voltage"].stringValue
- light.current = vJSON["current"].stringValue
- light.brightness = vJSON["brightness"].intValue
- light.color = vJSON["color"].intValue
- light.status = vJSON["status"].stringValue
- light.power = vJSON["power"].stringValue
- light.online = vJSON["online"].stringValue
- light.alarmStatus = vJSON["alarmStatus"].stringValue
- light.model = vJSON["model"].stringValue
- mList.append(light)
- }
-
- var isSuccess = false
- if code == .Success {
- isSuccess = true
- }
- let total = json["total"].stringValue
- let result = Light_list_Result(code: code, msg: msg, list: mList,total: total)
- return Light_list_Info(result: result, isSuccess: isSuccess, status: code)
- }
-
- }
- //设备详情
- struct LightInfodata {
- var name : String? // 设备名称 Y
- var deviceId : String? // 设备ID Y
- var floorId : String? // 楼层 Y
- var roomId : String? // 房间id Y
- var light : Int? // 亮度值 // Y
- var color : Int? // 色温值 // Y
- var colorR : Int? // R色值 // Y
- var colorG : Int? // G色值 // Y
- var colorB : Int? // B色值 Y
- var alarmStatus : String? // 故障状态(0 正常,1 故障) Y
- var alarmInfo : String? // 故障信息 Y
- var status : String? // 路灯状态(0 关,1 开)
- var model :String? // 设备型号(0 WE-L10,1 WE-L20,2 WE-CL10,3 WE-CL20)(lights,circadian lights设备使用)
- }
- struct LightInfo_Result {
- var code : HttpApiStatus?
- var msg : String?
- var data : LightInfodata?
- }
- class LightInfo_Info: NSObject {
- var result : LightInfo_Result?
- var isSuccess : Bool
- var status : HttpApiStatus?
-
- init(result:LightInfo_Result?, isSuccess:Bool, status:HttpApiStatus?) {
- self.result = result; self.isSuccess = isSuccess; self.status = status
- }
-
- static func fromJSON(_ json:JSON) -> LightInfo_Info? {
- let code = HttpApiStatus(rawValue: json["code"].stringValue)
- let msg = json["msg"].stringValue
- let data = json["data"]
- var result = LightInfo_Result()
- result.msg = msg
- result.code = code
- let name = data["name"].stringValue
- let deviceId = data["deviceId"].stringValue
- let floorId = data["floorId"].stringValue
- let roomId = data["roomId"].stringValue
- let light = data["light"].intValue
- let color = data["color"].intValue
- let colorR = data["colorR"].intValue
- let colorG = data["colorG"].intValue
- let colorB = data["colorB"].intValue
- let alarmStatus = data["alarmStatus"].stringValue
- let alarmInfo = data["alarmInfo"].stringValue
- let status = data["status"].stringValue
-
- let model = data["model"].stringValue
- let lightdata = LightInfodata(name: name, deviceId: deviceId, floorId: floorId, roomId: roomId, light: light, color: color, colorR: colorR, colorG: colorG, colorB: colorB, alarmStatus: alarmStatus, alarmInfo: alarmInfo,status: status,model: model)
- result.data = lightdata
- var isSuccess = false
- if code == .Success {
- isSuccess = true
- }
- return LightInfo_Info(result: result, isSuccess: isSuccess, status: code)
- }
- }
- //设备日志信息
- struct ReportData {
- var dataList : [String]? // 数据列表 Y
- var dateList : [String]? // 时间列表 Y
- var timeList : [String]? //时间列表
- }
- struct Report_Result {
- var code : HttpApiStatus?
- var msg : String?
- var data : ReportData?
- }
- class Report_Info: NSObject {
- var result : Report_Result?
- var isSuccess : Bool
- var status : HttpApiStatus?
-
- init(result:Report_Result?, isSuccess:Bool, status:HttpApiStatus?) {
- self.result = result; self.isSuccess = isSuccess; self.status = status
- }
-
- static func fromJSON(_ json:JSON) -> Report_Info? {
- let code = HttpApiStatus(rawValue: json["code"].stringValue)
- let msg = json["msg"].stringValue
- let data = json["data"]
- var result = Report_Result()
- result.msg = msg
- result.code = code
- let dataList = data["dataList"]
- guard let _DataList = dataList.array else { return nil }
- var mDataList = [String]()
- for aData in _DataList {
- let dataStr = aData.stringValue
- mDataList.append(dataStr)
- }
- let dateList = data["dateList"]
- var mDateList = [String]()
- if let _DateList = dateList.array {
- for aDate in _DateList {
- let dateStr = aDate.stringValue
- mDateList.append(dateStr)
- }
- }
- let timeList = data["timeList"]
- var mTimeList = [String]()
- if let _TimeList = timeList.array {
- for aTime in _TimeList {
- let timeStr = aTime.stringValue
- mTimeList.append(timeStr)
- }
- }
- let lightListdata = ReportData(dataList: mDataList, dateList: mDateList,timeList: mTimeList)
- result.data = lightListdata
-
- var isSuccess = false
- if code == .Success {
- isSuccess = true
- }
- return Report_Info(result: result, isSuccess: isSuccess, status: code)
- }
- }
|