Files
thetool/application/Measurement/Measurement.php
AI Development Engine 7560529699 feat: implement issue #
2026-03-02 21:08:38 +00:00

54 lines
1.6 KiB
PHP

<?php
class Measurement extends mfBaseModel
{
private $device;
private $sensor;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if($name == "device") {
$this->device = mfValuecache::singleton()->get("Device-id-".$this->device_id);
if($this->device === null) {
$this->device = new Device($this->device_id);
if($this->device->id) {
mfValuecache::singleton()->set("Device-id-".$this->device_id, $this->device);
}
}
return $this->device;
}
if($name == "sensor") {
// Sensor would be a separate entity if it exists
// For now, just return the sensor_id
return $this->sensor_id;
}
$classname = ucfirst($name);
$idfield = $name."_id";
if(property_exists($this->data, $idfield)) {
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
if(!$this->$name) {
$this->$name = new $classname($this->$idfield);
}
if($this->$name->id) {
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
return $this->$name;
} else {
return null;
}
}
return null;
}
return $this->$name;
}
}