123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // IHClassLightingSettingManager.swift
- // Inhealth
- //
- // Created by weclouds on 2020/7/24.
- // Copyright © 2020 weclouds. All rights reserved.
- //
- import UIKit
- import PKHUD
- class IHClassLightingSettingManager: NSObject {
- lazy var mainView: IHClassLightSettingView = {
- let mainView = IHClassLightSettingView.init(frame: self.vc!.view.bounds )
-
- mainView.delegate = self
-
- return mainView
- }()
-
- private weak var vc : UIViewController?
- func bindController(_ vc: UIViewController){
- self.vc = vc
- self.vc?.view.addSubview(mainView)
- let classLightVC = vc as! IHClassLightSettingCtr
- // mainView.devData = classLightVC.devData
-
-
- //获取教室灯
- getClassLightModel(id: (classLightVC.devData?.id)!)
- }
- }
- extension IHClassLightingSettingManager{
- fileprivate func getClassLightModel(id : String){
- // HUD.flash(.label("加载中..."), delay: 8.0)
- HUD.flash(.progress, delay: 8.0)
- IHClassLightService.share.getSchoolLightModel(id: id) { (classLight_info) in
- //获取数据 : ClassLight_info
- guard let classLightInfo = classLight_info else{return}
- HUD.flash(.label(classLightInfo.msg), delay: 1)
- if classLightInfo.code == "0000"{
- self.mainView.classLightModel = classLightInfo.result
- }
- }
- }
- }
- extension IHClassLightingSettingManager : ClassLightSettingViewDelegate{
- //设备灯
-
- func setClassLight(classLight: [[String : [String : String]]]) {
-
- var lightDataModel = ClassLightModelData.init()
- for i in 0..<classLight.count {
- let dic = classLight[i]
- let valueDic = dic.values.first!
- if dic.keys.first! == "全开模式" {
- lightDataModel.open_light = valueDic["Brightness"]!
- lightDataModel.open_color = valueDic["Color temperature"]!
- }
-
- if dic.keys.first! == "全关模式" {
- lightDataModel.close_light = valueDic["Brightness"]!
- lightDataModel.close_color = valueDic["Color temperature"]!
- }
- if dic.keys.first! == "上课模式" {
- lightDataModel.att_class_light = valueDic["Brightness"]!
- lightDataModel.att_class_color = valueDic["Color temperature"]!
- }
- if dic.keys.first! == "下课模式" {
- lightDataModel.fin_class_light = valueDic["Brightness"]!
- lightDataModel.fin_class_color = valueDic["Color temperature"]!
- }
- if dic.keys.first! == "午休模式" {
- lightDataModel.break_light = valueDic["Brightness"]!
- lightDataModel.break_color = valueDic["Color temperature"]!
- }
- if dic.keys.first! == "自习模式" {
- lightDataModel.self_stu_light = valueDic["Brightness"]!
- lightDataModel.self_stu_color = valueDic["Color temperature"]!
- }
- if dic.keys.first! == "板书模式" {
- lightDataModel.blackboard_light = valueDic["Brightness"]!
- lightDataModel.blackboard_color = valueDic["Color temperature"]!
- }
- if dic.keys.first! == "投影模式" {
- lightDataModel.shadow_light = valueDic["Brightness"]!
- lightDataModel.shadow_color = valueDic["Color temperature"]!
- }
- }
- let classLightVC = vc as! IHClassLightSettingCtr
- IHClassLightService.share.setSchoolLightModel(id: (classLightVC.devData?.id)!, close_light: lightDataModel.close_light, close_color: lightDataModel.close_color, open_light: lightDataModel.open_light, open_color: lightDataModel.open_color, att_class_light: lightDataModel.att_class_light, att_class_color: lightDataModel.att_class_color, fin_class_light: lightDataModel.fin_class_light, fin_class_color: lightDataModel.fin_class_color, break_light: lightDataModel.break_light, break_color: lightDataModel.break_color, self_stu_light: lightDataModel.self_stu_light, self_stu_color: lightDataModel.self_stu_color, blackboard_light: lightDataModel.blackboard_light, blackboard_color: lightDataModel.blackboard_color, shadow_light: lightDataModel.shadow_light, shadow_color: lightDataModel.shadow_color, compelete:{ (respone, code) in
-
- HUD.flash(.label(respone), delay: 1.0)
-
- })
-
- }
-
-
- }
|