/** * @param $name * @param $subject * @param Configuration $configuration * @param array $params * * @return FormEvent */ public static function create($name, $subject, $configuration, $params = array()) { $event = new self($name, $subject); $event->setConfiguration($configuration); foreach ($params as $key => $value) { $event->setParam($key, $value); } return $event; }
public static function fromArray(array $params = array()) { $self = new self(); $self->setConfiguration($params); return $self; }
/** * Creates a new Deployment from parsed response body. * * @param array $parsed The parsed response body in array representation. * * @return Deployment */ public static function create($parsed) { $result = new self(); $name = Utilities::tryGetValue($parsed, Resources::XTAG_NAME); $label = Utilities::tryGetValue($parsed, Resources::XTAG_LABEL); $url = Utilities::tryGetValue($parsed, Resources::XTAG_URL); $locked = Utilities::tryGetValue($parsed, Resources::XTAG_LOCKED); $rollbackAllowed = Utilities::tryGetValue($parsed, Resources::XTAG_ROLLBACK_ALLOWED); $sdkVersion = Utilities::tryGetValue($parsed, Resources::XTAG_SDK_VERSION); $inputEndpointList = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_INPUT_ENDPOINT_LIST, Resources::XTAG_INPUT_ENDPOINT); $roleList = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_ROLE_LIST, Resources::XTAG_ROLE); $roleInstanceList = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_ROLE_INSTANCE_LIST, Resources::XTAG_ROLE_INSTANCE); $status = Utilities::tryGetValue($parsed, Resources::XTAG_STATUS); $slot = Utilities::tryGetValue($parsed, Resources::XTAG_DEPLOYMENT_SLOT); $privateId = Utilities::tryGetValue($parsed, Resources::XTAG_PRIVATE_ID); $configuration = Utilities::tryGetValue($parsed, Resources::XTAG_CONFIGURATION); $upgradeDomainCount = Utilities::tryGetValue($parsed, Resources::XTAG_UPGRADE_DOMAIN_COUNT); $upgradeStatus = Utilities::tryGetValue($parsed, Resources::XTAG_UPGRADE_STATUS); $result->setConfiguration($configuration); $result->setLabel($label); $result->setLocked(Utilities::toBoolean($locked)); $result->setName($name); $result->setPrivateId($privateId); $result->setRollbackAllowed(Utilities::toBoolean($rollbackAllowed)); $result->setSdkVersion($sdkVersion); $result->setSlot($slot); $result->setStatus($status); $result->setUpgradeDomainCount(intval($upgradeDomainCount)); $result->setUpgradeStatus(UpgradeStatus::create($upgradeStatus)); $result->setUrl($url); $result->setRoleInstanceList(Utilities::createInstanceList(Utilities::getArray($roleInstanceList), 'WindowsAzure\\ServiceManagement\\Models\\RoleInstance')); $result->setRoleList(Utilities::createInstanceList(Utilities::getArray($roleList), 'WindowsAzure\\ServiceManagement\\Models\\Role')); $result->setInputEndpointList(Utilities::createInstanceList(Utilities::getArray($inputEndpointList), 'WindowsAzure\\ServiceManagement\\Models\\InputEndpoint')); return $result; }
public static function syncEwattch($_ip) { $request_http = new com_http($_ip . '/log.json?mode=10'); $result = json_decode($request_http->exec(1, 1), true); foreach ($result['resource']['electricity'] as $resource) { $eqLogic = self::byLogicalId('electricity_' . $resource['name'], 'ewattch'); if (!is_object($eqLogic)) { $eqLogic = new self(); $eqLogic->setName('electricity_' . $resource['name']); $eqLogic->setEqType_name('ewattch'); $eqLogic->setIsVisible(1); $eqLogic->setIsEnable(1); $eqLogic->setLogicalId('electricity_' . $resource['name']); $eqLogic->setConfiguration('ip', $_ip); $eqLogic->setCategory('energy', 1); $eqLogic->save(); } $index = $eqLogic->getCmd(null, 'index'); if (!is_object($index)) { $index = new ewattchCmd(); $index->setLogicalId('index'); $index->setIsVisible(1); $index->setName(__('Index', __FILE__)); } $index->setUnite('wh'); $index->setType('info'); $index->setSubType('numeric'); $index->setEventOnly(1); $index->setEqLogic_id($eqLogic->getId()); $index->save(); $cost = $eqLogic->getCmd(null, 'cost'); if (!is_object($cost)) { $cost = new ewattchCmd(); $cost->setLogicalId('cost'); $cost->setIsVisible(1); $cost->setName(__('Coût', __FILE__)); } $cost->setUnite('€'); $cost->setType('info'); $cost->setSubType('numeric'); $cost->setEventOnly(1); $cost->setEqLogic_id($eqLogic->getId()); $cost->save(); } foreach ($result['resource']['water'] as $resource) { $eqLogic = self::byLogicalId('water_' . $resource['name'], 'ewattch'); if (!is_object($eqLogic)) { $eqLogic = new self(); $eqLogic->setName('water_' . $resource['name']); $eqLogic->setEqType_name('ewattch'); $eqLogic->setIsVisible(1); $eqLogic->setIsEnable(1); $eqLogic->setLogicalId('water_' . $resource['name']); $eqLogic->setConfiguration('ip', $_ip); $eqLogic->setCategory('energy', 1); $eqLogic->save(); } $index = $eqLogic->getCmd(null, 'index'); if (!is_object($index)) { $index = new ewattchCmd(); $index->setLogicalId('index'); $index->setIsVisible(1); $index->setName(__('Index', __FILE__)); } $index->setUnite('L'); $index->setType('info'); $index->setSubType('numeric'); $index->setEventOnly(1); $index->setEqLogic_id($eqLogic->getId()); $index->save(); $cost = $eqLogic->getCmd(null, 'cost'); if (!is_object($cost)) { $cost = new ewattchCmd(); $cost->setLogicalId('cost'); $cost->setIsVisible(1); $cost->setName(__('Coût', __FILE__)); } $cost->setUnite('€'); $cost->setType('info'); $cost->setSubType('numeric'); $cost->setEventOnly(1); $cost->setEqLogic_id($eqLogic->getId()); $cost->save(); } foreach ($result['resource']['heating'] as $resource) { $eqLogic = self::byLogicalId('heating_' . $resource['name'], 'ewattch'); if (!is_object($eqLogic)) { $eqLogic = new self(); $eqLogic->setName('heating_' . $resource['name']); $eqLogic->setEqType_name('ewattch'); $eqLogic->setIsVisible(1); $eqLogic->setIsEnable(1); $eqLogic->setLogicalId('heating_' . $resource['name']); $eqLogic->setConfiguration('ip', $_ip); $eqLogic->setCategory('heating', 1); $eqLogic->save(); } $index = $eqLogic->getCmd(null, 'index'); if (!is_object($index)) { $index = new ewattchCmd(); $index->setLogicalId('index'); $index->setIsVisible(1); $index->setName(__('Index', __FILE__)); } $index->setUnite('wh'); $index->setType('info'); $index->setSubType('numeric'); $index->setEventOnly(1); $index->setEqLogic_id($eqLogic->getId()); $index->save(); } foreach ($result['resource']['environment'] as $resource) { $eqLogic = self::byLogicalId('environment_' . $resource['name'], 'ewattch'); if (!is_object($eqLogic)) { $eqLogic = new self(); $eqLogic->setName('environment_' . $resource['name']); $eqLogic->setEqType_name('ewattch'); $eqLogic->setIsVisible(1); $eqLogic->setIsEnable(1); $eqLogic->setLogicalId('environment_' . $resource['name']); $eqLogic->setConfiguration('ip', $_ip); $eqLogic->save(); } $value = $eqLogic->getCmd(null, 'value'); if (!is_object($value)) { $value = new ewattchCmd(); $value->setLogicalId('value'); $value->setIsVisible(1); $value->setName(__('Valeur', __FILE__)); } $value->setUnite($resource['units']); $value->setType('info'); $value->setSubType('numeric'); $value->setEventOnly(1); $value->setEqLogic_id($eqLogic->getId()); $value->save(); } }
public static function syncSonos() { $sonos = self::getSonos(true); $controllers = $sonos->getControllers(); $speakers = sonos3::getSpeaker(); foreach ($controllers as $controller) { $eqLogic = sonos3::byLogicalId($controller->ip, 'sonos3'); if (!is_object($eqLogic)) { $eqLogic = new self(); $eqLogic->setLogicalId($controller->ip); $eqLogic->setName($controller->room . ' - ' . $controller->name); $object = object::byName($controller->room); if (is_object($object)) { $eqLogic->setObject_id($object->getId()); $eqLogic->setName($controller->name); } if (strpos($controller->name, 'PLAY:1') !== false) { $eqLogic->setConfiguration('model', 'PLAY1'); } if (strpos($controller->name, 'PLAY:3') !== false) { $eqLogic->setConfiguration('model', 'PLAY3'); } if (strpos($controller->name, 'PLAY:5') !== false) { $eqLogic->setConfiguration('model', 'PLAY5'); } if (strpos($controller->name, 'PLAYBAR') !== false) { $eqLogic->setConfiguration('model', 'PLAYBAR'); } if (strpos($controller->name, 'CONNECT') !== false) { $eqLogic->setConfiguration('model', 'CONNECT'); } if (strpos($controller->name, 'CONNECT:AMP') !== false) { $eqLogic->setConfiguration('model', 'CONNECTAMP'); } $eqLogic->setEqType_name('sonos3'); $eqLogic->setIsVisible(1); $eqLogic->setIsEnable(1); } $speakers_array = array(); foreach ($speakers as $speaker) { $speakers_array[$speaker->ip] = $speaker->room; } $eqLogic->setConfiguration('speakers', json_encode($speakers_array)); $eqLogic->save(); } }