-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubiCoreMain.php
45 lines (32 loc) · 1.26 KB
/
ubiCoreMain.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
//echo("Loaded ubiCoreMain.<br>");
require_once 'objectsManager.php';
require_once 'ubiObj.php';
require_once './objects/std.php';
require_once './objects/stabs.php';
session_start(); // セッションを開始
$weatherInfo = new weatherInfo();
// 既存のオブジェクトマネージャがセッションにある場合はそれを使用
if (isset($_SESSION['manager'])) {
$manager = $_SESSION['manager'];
echo "Loaded manager from session.<br>";
} else {
$manager = new objectsManager();
echo "Created new manager.<br>";
}
// HTTP POSTでデバイスタイプを受け取り、新しいインスタンスを作成
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$objectType = $_POST['device_type'];
$objectName = $_POST['device_name'];
echo "Received POST data: device_type = $objectType, device_name = $objectName<br>";
if ($objectType === 'Sunscreen') {
$newObject = new Sunscreen($objectName, $manager,$weatherInfo);
} elseif ($objectType === 'Door') {
$newObject = new Door($objectName, $manager, $weatherInfo);
}
// 新しいデバイスをキューに追加
$manager->addDevice($newObject);
}
// オブジェクトマネージャをセッションに保存
$_SESSION['manager'] = $manager;
?>