IHLightCommandManager.swift 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // IHLightCommandManager.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2020/8/21.
  6. // Copyright © 2020 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHLightCommandManager: NSObject {
  10. lazy var mainView : IHLightCommandView = {
  11. let mainView = Bundle.main.loadNibNamed("IHLightCommandView", owner: nil, options: nil)?.first as! IHLightCommandView
  12. // colorView.isHidden = true
  13. mainView.delegate = self
  14. return mainView
  15. }()
  16. // lazy var clientSocket: GCDAsyncUdpSocket? = {
  17. // var mainQueue = DispatchQueue.main
  18. // var clientSocket = GCDAsyncUdpSocket(delegate: self, delegateQueue: DispatchQueue.global())
  19. // return clientSocket
  20. // }()
  21. // var modelList = [gatewayInfor]()
  22. weak var vc : IHLightCommandCtr?
  23. func bindController(_ vc : UIViewController) {
  24. self.vc = vc as? IHLightCommandCtr
  25. self.vc?.view.addSubview(mainView)
  26. mainView.schollDeviceInfor = self.vc?.schollDeviceInfor
  27. }
  28. deinit {
  29. log.debug("IHLightCommandManager销毁")
  30. }
  31. }
  32. extension IHLightCommandManager : IHLightCommandViewDelegate{
  33. //灯的开关
  34. func setDeviceTurnOn(_ isTurnOn: Bool, _ device: (address: String, type: String,location : String)) {
  35. IHLightCommandService.share.setCWOrOtherLightTurnOn(isTurnOn: isTurnOn, device: device, ip: self.vc!.gateway!.ip!, port: self.vc!.gateway!.port!)
  36. }
  37. //设置灯的亮度与色温
  38. func setLampCWBrightnessAndColorValue(device: (address: String, type: String, location: String), brightness: String, color: String,isColor : Bool) {
  39. IHLightCommandService.share.setLightCWBrightnessAndColorValue(device : device,brightness: brightness, color: color, ip: self.vc!.gateway!.ip!, port: self.vc!.gateway!.port!,isColor : isColor)
  40. }
  41. }