package Ġio . simple matter . smart ap artment Ċ Ċ import Ġio . simple matter . smart ap artment . vert icles . A partment Vert icle Ċ import Ġio . simple matter . smart ap artment . vert icles . Sensor Vert icle Ċ import Ġio . vertx . core . Deployment Options Ċ import Ġio . vertx . core . Vert x Ċ import Ġio . vertx . core . json . JsonObject Ċ import Ġio . vertx . core . logging . LoggerFactory Ċ import Ġkotlin . text . pad Start Ċ Ċ object ĠService Ġ{ ĊĊĠ Ġprivate Ġval Ġlog Ġ= ĠLoggerFactory . getLogger ( Service :: class . java ) ĊĠ Ġprivate Ġval Ġservice Config Ġ= ĠSmart A partment Config . load () ĊĠ Ġprivate Ġval Ġvert x Ġ= ĠVert x . vertx () ĊĊĠ Ġprivate Ġval Ġmotion Sensors Ġ= Ġ( 1 .. 5 1 ). toList (). map Ġ{ Ġ" M " Ġ+ Ġit . toString (). pad Start ( 2 , Ġ' 0 ') Ġ} ĊĠ Ġprivate Ġval Ġitem Sensors Ġ= Ġ( 1 .. 8 ). toList (). map Ġ{ Ġ" I " Ġ+ Ġit . toString (). pad Start ( 2 , Ġ' 0 ') Ġ} ĊĠ Ġprivate Ġval Ġcab inet Sensors Ġ= Ġ( 1 .. 1 2 ). toList (). map Ġ{ Ġ" D " Ġ+ Ġit . toString (). pad Start ( 2 , Ġ' 0 ') Ġ} ĊĠ Ġprivate Ġval Ġtemperature Sensors Ġ= Ġ( 1 .. 3 ). toList (). map Ġ{ Ġ" T " Ġ+ Ġit . toString (). pad Start ( 2 , Ġ' 0 ') Ġ} ĊĠ Ġprivate Ġval Ġwater Sensors Ġ= ĠlistOf (" AD 1 - A ", Ġ" AD 1 - B ") ĊĠ Ġprivate Ġval Ġburn er Sensors Ġ= ĠlistOf (" AD 1 - C ") ĊĠ Ġprivate Ġval Ġphone Sensors Ġ= ĠlistOf (" P 0 1 ") ĊĠ Ġprivate Ġval Ġsensors Ġ= Ġmotion Sensors Ġ+ Ġitem Sensors Ġ+ Ġcab inet Sensors Ġ+ Ġtemperature Sensors Ġ+ Ġwater Sensors Ġ+ Ġburn er Sensors Ġ+ Ġphone Sensors ĊĊĠ Ġprivate Ġval Ġapart ments Ġ= Ġ( 1 .. 2 6 ). toList (). map Ġ{ Ġit . toString (). pad Start ( 2 , Ġ' 0 ') Ġ} ĊĊĠ Ġ@ Jvm Static ĊĠ Ġfun Ġmain ( args : ĠArray < String >) Ġ{ ĊĠĠĠ Ġdeploy A part ments () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġdeploy A part ments () Ġ{ ĊĠĠĠ Ġfor Ġ( ap artment Id Ġin Ġapart ments ) Ġ{ ĊĠĠĠĠĠ Ġdeploy A partment ( ap artment Id , Ġservice Config ) ĊĠĠĠĠĠ Ġdeploy Sensors ( ap artment Id ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġdeploy A partment ( id : ĠString , Ġservice Config : ĠSmart A partment Config ) Ġ{ ĊĠĠĠ Ġval Ġap artment Vert icle Config Ġ= ĠJsonObject () ĊĠĠĠĠĠ Ġ. put ( A partment Vert icle . Companion . Config . ap artment Id , Ġid ) ĊĠĠĠĠĠ Ġ. put ( A partment Vert icle . Companion . Config . simulation Start , Ġservice Config . simulation . start ) ĊĠĠĠ Ġval Ġdeploy Options Ġ= ĠDeployment Options () ĊĠĠĠ Ġdeploy Options . set Config ( ap artment Vert icle Config ) ĊĠĠĠ Ġdeploy Options . is Worker Ġ= Ġtrue ĊĠĠĠ Ġdeploy Options . worker PoolSize Ġ= Ġ 1 5 ĊĊĠĠĠ Ġvert x . deploy Vert icle ( A partment Vert icle :: class . qualified Name , Ġdeploy Options ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġdeploy Sensors ( ap artment Id : ĠString ) Ġ{ ĊĠĠĠ Ġfor Ġ( sensor Ġin Ġsensors ) Ġ{ ĊĠĠĠĠĠ Ġdeploy Sensor ( sensor , Ġap artment Id , Ġservice Config ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġdeploy Sensor ( id : ĠString , Ġap artment Id : ĠString , Ġservice Config : ĠSmart A partment Config ) Ġ{ ĊĠĠĠ Ġval Ġsensor Vert icle Config Ġ= ĠJsonObject () ĊĠĠĠĠĠ Ġ. put ( Sensor Vert icle . Companion . Config . Sensor Id , Ġid ) ĊĠĠĠĠĠ Ġ. put ( Sensor Vert icle . Companion . Config . A partment Id , Ġap artment Id ) ĊĠĠĠĠĠ Ġ. put ( Sensor Vert icle . Companion . Config . Mqtt Port , Ġservice Config . mqtt . port ) ĊĠĠĠĠĠ Ġ. put ( Sensor Vert icle . Companion . Config . Mqtt Url , Ġservice Config . mqtt . host ) ĊĠĠĠĠĠ Ġ. put ( Sensor Vert icle . Companion . Config . Mqtt Topic Prefix , Ġservice Config . mqtt . topic Prefix ) ĊĠĠĠĠĠ Ġ. put ( Sensor Vert icle . Companion . Config . Qo S , Ġservice Config . mqtt . qos ) ĊĊĠĠĠ Ġval Ġdeploy Options Ġ= ĠDeployment Options () ĊĠĠĠ Ġdeploy Options . config Ġ= Ġsensor Vert icle Config ĊĠĠĠ Ġdeploy Options . is Worker Ġ= Ġtrue ĊĠĠĠ Ġdeploy Options . worker PoolSize Ġ= Ġ 5 0 ĊĊĠĠĠ Ġvert x . deploy Vert icle ( Sensor Vert icle :: class . qualified Name , Ġdeploy Options ) ĊĠ Ġ} Ċ } Ċ