From 627030d638f748e317e0100666223bd75b3e58f3 Mon Sep 17 00:00:00 2001 From: Machriam Date: Tue, 7 May 2024 13:52:47 +0200 Subject: [PATCH 1/2] over_voltage according to https://github.com/raspberrypi/linux/issues/2555 fixes camera issues with the raspberry pi zero, which yield to crashes of the system --- PlantMonitorControl/Install/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PlantMonitorControl/Install/install.sh b/PlantMonitorControl/Install/install.sh index 43ffda41..b94e7106 100644 --- a/PlantMonitorControl/Install/install.sh +++ b/PlantMonitorControl/Install/install.sh @@ -14,4 +14,5 @@ sudo cp ./Install/PlantMonitorStart.service /lib/systemd/system/ sudo chmod 644 /lib/systemd/system/PlantMonitorStart.service sudo systemctl daemon-reload sudo systemctl enable PlantMonitorStart.service -sudo systemctl start PlantMonitorStart.service \ No newline at end of file +sudo systemctl start PlantMonitorStart.service +echo -e "\nover_voltage=4\n" | sudo tee -a /boot/config.txt \ No newline at end of file From a7ee87c1433584b6b1833deb117b87dbc0079534 Mon Sep 17 00:00:00 2001 From: Machriam Date: Tue, 7 May 2024 14:10:36 +0200 Subject: [PATCH 2/2] The photo tour only transmits those pictures of the desired places with duplication. Moving of the device is only permissible, if atleast one byte array has been received --- .../features/deviceProgramming/+page.svelte | 42 +++++++++++++++---- .../src/services/DeviceStreaming.ts | 4 +- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/GatewayApp/Frontend/Plantmonitor.Website/src/features/deviceProgramming/+page.svelte b/GatewayApp/Frontend/Plantmonitor.Website/src/features/deviceProgramming/+page.svelte index c3993e7a..8e38b42a 100644 --- a/GatewayApp/Frontend/Plantmonitor.Website/src/features/deviceProgramming/+page.svelte +++ b/GatewayApp/Frontend/Plantmonitor.Website/src/features/deviceProgramming/+page.svelte @@ -25,7 +25,6 @@ let moveSteps = 100; let currentlyMoving = false; let removeSteps = false; - let storePictures = false; let currentPosition: number | undefined; let currentTime: Date | undefined; let movementPlan = new DeviceMovement(); @@ -98,17 +97,43 @@ while (currentPosition != stepCountAfterMove) await Task.delay(100); await Task.delay(1000); } - const pictureClient = new DeviceClient(); - if (storePictures) await pictureClient.killCamera(selectedDeviceData?.ip); currentlyMoving = false; } + async function takePhotoTour() { + if (selectedDeviceData?.ip == undefined) return; + let positionsToReach = movementPlan.movementPlan.stepPoints.map((sp) => + sp[stepsToReach](movementPlan.movementPlan.stepPoints) + ); + const connection = new DeviceStreaming().buildVideoConnection( + selectedDeviceData.ip, + 1, + defaultFocus / 100, + true, + positionsToReach + ); + await hubconnection?.stop(); + hubconnection = connection.connection; + let firstImageReceived = false; + connection.start(async (step, data, date) => { + const image = document.getElementById(videoCanvasId) as HTMLImageElement; + currentPosition = step; + currentTime = date; + firstImageReceived = true; + image.src = data; + }); + previewEnabled = true; + while (!firstImageReceived) await Task.delay(100); + await moveToAll(); + const pictureClient = new DeviceClient(); + await pictureClient.killCamera(selectedDeviceData?.ip); + } async function showPreview() { if (selectedDeviceData?.ip == undefined) return; const connection = new DeviceStreaming().buildVideoConnection( selectedDeviceData.ip, - storePictures ? 1 : dev ? 8 : 4, + dev ? 8 : 4, defaultFocus / 100, - storePictures + false ); await hubconnection?.stop(); hubconnection = connection.connection; @@ -131,8 +156,6 @@ {#if previewEnabled} - previewEnabled} class="col-md-4" label="Store Pictures" bind:value={storePictures} - > @@ -141,8 +164,9 @@ {:else} - - + +
+ {/if}
{#if movementPlan?.movementPlan?.stepPoints != undefined && movementPlan?.movementPlan?.stepPoints.length > 0} diff --git a/GatewayApp/Frontend/Plantmonitor.Website/src/services/DeviceStreaming.ts b/GatewayApp/Frontend/Plantmonitor.Website/src/services/DeviceStreaming.ts index 404edb9f..d82bc39c 100644 --- a/GatewayApp/Frontend/Plantmonitor.Website/src/services/DeviceStreaming.ts +++ b/GatewayApp/Frontend/Plantmonitor.Website/src/services/DeviceStreaming.ts @@ -10,7 +10,7 @@ export interface IReplayedPicture { Steps: number; } export class DeviceStreaming { - buildVideoConnection(device: string, sizeDivider = 4, focusInMeter = 10, storeData = false) { + buildVideoConnection(device: string, sizeDivider = 4, focusInMeter = 10, storeData = false, positionsToStream: number[] = []) { const url = dev ? Constants.developmentUrl : `https://${location.hostname}`; const connection = new signalR.HubConnectionBuilder() .withUrl(`${url}/hub/video`, { withCredentials: false }) @@ -22,7 +22,7 @@ export class DeviceStreaming { await connection.start(); connection.stream("StreamPictures", new StreamingMetaData({ distanceInM: focusInMeter, - positionsToStream: [], quality: 100, resolutionDivider: sizeDivider, storeData: storeData + positionsToStream: positionsToStream, quality: 100, resolutionDivider: sizeDivider, storeData: storeData }).toJSON(), device).subscribe({ next: async (x) => { const payload = x as Uint8Array;