コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $inputs = $request->all();
     $i = 0;
     for ($i = 1; $i <= 8; $i++) {
         if (isset($inputs['serial' . $i]) && isset($inputs['temperature' . $i])) {
             Temperature::create(['sensor_id' => $inputs['serial' . $i], 'value' => $inputs['temperature' . $i]]);
         }
     }
 }
コード例 #2
0
ファイル: ProcessController.php プロジェクト: sfadi215/Smart
 public function index()
 {
     $controls = Control::all()->keyBy('name');
     // we will get temperatures here as well to pass them to home view
     $temps = collect(Temperature::getLatest())->keyBy('sensor_id');
     // get water level value(s) and pass to view
     $waterLevel = WaterLevel::getLatest()->first();
     $rainSensor = RainSensor::getLatest()->first();
     // pass it to the view
     return view('home', compact('controls', 'temps', 'waterLevel', 'rainSensor'));
 }
コード例 #3
0
 public function getCurrentEnvironmentValue($id)
 {
     $currentLight = Light::where("sensor_id", "=", $id)->orderBy('created_at', 'desc')->first();
     $currentSoilMoisture = SoilMoisture::where("sensor_id", "=", $id)->orderBy('created_at', 'desc')->first();
     $currentTemperature = Temperature::where("sensor_id", "=", $id)->orderBy('created_at', 'desc')->first();
     $currentAirHumidity = Humidity::where("sensor_id", "=", $id)->orderBy('created_at', 'desc')->first();
     $json = array();
     $json[0] = $currentLight;
     $json[1] = $currentTemperature;
     $json[2] = $currentAirHumidity;
     $json[3] = $currentSoilMoisture;
     return $json;
 }
コード例 #4
0
ファイル: routes.php プロジェクト: bossgame1234/MS4SF
     if ($notificationCheck->minLux != 0 && $notificationCheck->minLux > $humid) {
         $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach minimum light <" . $notificationCheck->minLux . " lux", $id);
     }
     if ($notificationCheck->maxLux != 0 && $notificationCheck->maxLux < $humid) {
         $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach maximum light >" . $notificationCheck->maxLux . " lux", $id);
     }
 }
 if ($checkHourly == 6) {
     $lightMin = Light::where('sensor_id', '=', $SensorPrimaryKey)->min('luxValue');
     $lightAverage = Light::where('sensor_id', '=', $SensorPrimaryKey)->avg('luxValue');
     $lightMax = Light::where('sensor_id', '=', $SensorPrimaryKey)->max('luxValue');
     Light::where('sensor_id', 'like', $SensorPrimaryKey)->delete();
     $temperatureMin = Temperature::where('sensor_id', '=', $SensorPrimaryKey)->min('celsiusValue');
     $temperatureAverage = Temperature::where('sensor_id', '=', $SensorPrimaryKey)->avg('celsiusValue');
     $temperatureMax = Temperature::where('sensor_id', '=', $SensorPrimaryKey)->max('celsiusValue');
     Temperature::where('sensor_id', 'like', $SensorPrimaryKey)->delete();
     $humidityMin = Humidity::where('sensor_id', '=', $SensorPrimaryKey)->min('humidityPercentage');
     $humidityAverage = Humidity::where('sensor_id', '=', $SensorPrimaryKey)->avg('humidityPercentage');
     $humidityMax = Humidity::where('sensor_id', '=', $SensorPrimaryKey)->max('humidityPercentage');
     Humidity::where('sensor_id', 'like', $SensorPrimaryKey)->delete();
     $soilMoistureMin = SoilMoisture::where('sensor_id', '=', $SensorPrimaryKey)->min('soilValue');
     $soilMoistureAverage = SoilMoisture::where('sensor_id', '=', $SensorPrimaryKey)->avg('soilValue');
     $soilMoistureMax = SoilMoisture::where('sensor_id', '=', $SensorPrimaryKey)->max('soilValue');
     SoilMoisture::where('sensor_id', 'like', $SensorPrimaryKey)->delete();
     $daily = new Daily();
     $daily->minLight = $lightMin;
     $daily->avgLight = $lightAverage;
     $daily->maxLight = $lightMax;
     $daily->minTemperature = $temperatureMin;
     $daily->avgTemperature = $temperatureAverage;
     $daily->maxTemperature = $temperatureMax;
コード例 #5
0
ファイル: TempTableSeeder.php プロジェクト: sfadi215/Smart
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // this is one user
     Temperature::create(['sensor_id' => '28 f2 68 97 06 00 00 9b', 'value' => 0]);
 }