Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.92 KB | None | 0 0
  1. case "update":
  2.             let req = tuple.message[key] as! [String]
  3.             //odeslani pozadavku na PLCComS na zaklade prijate kategorie
  4.             if req[0] == "SCENE"{
  5.                 client1.send(data: "SET:" + req[1] + ".GTSAP1_SCENE_SET" + req[2] + ",1\n")
  6.                 handler!(["update" : "OK" as AnyObject])
  7.             }
  8.             if req[0] == "SOCKET"{
  9.                 client1.send(data: "SET:" + req[1] + "_SOCKET_ONOFF," + req[2] + "\n" )
  10.                 handler!(["update" : "OK" as AnyObject])
  11.             }
  12.             if req[0] == "RELAY" {
  13.                 client1.send(data: "SET:" + req[1] + "_RELAY_ONOFF," + req[2])
  14.                 handler!(["update" : "OK" as AnyObject])
  15.             }
  16.             if req[0] == "SHUTTER" {
  17.                 client1.send(data: "SET:" + req[1] + "_SHUTTER_" + req[2] + "_CONTROL,1")
  18.                 handler!(["update" : "OK" as AnyObject])
  19.             }
  20.             if req[0] == "LIGHT" {
  21.                 let dx = req[2].split(separator: ";")
  22.                 //v pripade svetla je potreba overit kolik hodnot se ma nastavit
  23.                 switch dx.count {
  24.                 case 1:
  25.                     client1.send(data: "SET:" + req[1] + "_LIGHT_ONOFF," + dx[0])
  26.                     break
  27.                 case 2:
  28.                     client1.send(data: "SET:" + req[1] + "_LIGHT_ONOFF," + dx[0])
  29.                     client1.send(data: "SET:" + req[1] + "_LIGHT_DIMLEVEL," + dx[1])
  30.                     break
  31.                 case 3:
  32.                     client1.send(data: "SET:" + req[1] + "_LIGHT_ONOFF," + dx[0])
  33.                     client1.send(data: "SET:" + req[1] + "_LIGHT_DIMLEVEL," + dx[1])
  34.                     client1.send(data: "SET:" + req[1] + "_LIGHT_RGB," + dx[2])
  35.                     break
  36.                 default:
  37.                     break
  38.                 }
  39.                 handler!(["update" : "OK" as AnyObject])
  40.             }
  41.             handler = nil
  42.             break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement