123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- //
- // IHSensorDeviceCell2.swift
- // Inhealth
- //
- // Created by weclouds on 2020/10/30.
- // Copyright © 2020 weclouds. All rights reserved.
- //
- import UIKit
- let KNotifiIHSensorDeviceCell2SetStatus = "KNotifiIHSensorDeviceCell2SetStatus"
- class IHSensorDeviceCell2: UITableViewCell {
- @IBOutlet weak var leveLabel: UILabel!
-
- @IBOutlet weak var statusLabel: UILabel!
-
- @IBOutlet weak var connectStatusLabel: UILabel!
-
- @IBOutlet weak var DemoModeBtn: UIButton!
-
- override func awakeFromNib() {
- super.awakeFromNib()
- // Initialization code
- }
- var sensorData:SensorInfodata?{
- didSet{
- if let sensorData = self.sensorData {
- if let batteryLevel = sensorData.batteryLevel ,
- let batteryStatus = sensorData.batteryStatus,
- let online = sensorData.online,
- let wifiLevel = sensorData.wifiLevel{
- if batteryLevel == "" || batteryStatus == "" || online == "" || wifiLevel == ""{
- g_showHUD("No data")
- return
- }
-
- //NA不支持的意思
- self.leveLabel.text = "NA"
- if online == "0" {
- connectStatusLabel.text = "Off-line"
- }else if online == "1"{
- connectStatusLabel.text = "On-line"
- }
- statusLabel.text = "NA"
- //开关探头3秒巡检指令 status
- if sensorData.status == "0"{
- //关
- DemoModeBtn.isSelected = false
- DemoModeBtn.setImage(UIImage.init(named: "offSwitch"), for: .normal)
- }else{
- //开
- DemoModeBtn.isSelected = true
- DemoModeBtn.setImage(UIImage.init(named: "onSwitch_gray"), for: .normal)
- }
- }
- }
- }
- }
- deinit {
- NotificationCenter.default.removeObserver(self)
- }
- @IBAction func setStatusActionBtn(_ sender: UIButton) {
- sender.isSelected = !sender.isSelected
- var status = "0"
- if sensorData?.status == "0"{
- //打开
- status = "1"
- }else{
- //关闭
- status = "0"
- }
- NotificationCenter.default.post(name: NSNotification.Name(KNotifiIHSensorDeviceCell2SetStatus), object: nil, userInfo: ["setStatus" : status])
- }
- }
|