Skip to content

Commit

Permalink
Merge pull request #95 from coronasafe/preset-query
Browse files Browse the repository at this point in the history
fixed fetching monitor presets
  • Loading branch information
mathew-alex authored Sep 7, 2023
2 parents f5f7c0c + 3337a78 commit 719d98f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
32 changes: 15 additions & 17 deletions src/automation/autoDataExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ const getSanitizedData = (data) => {
return sanitizedData;
};

const extractData = async (camParams, bedId) => {
const coordinates = await getMonitorCoordinates(bedId);
console.log("Moving to coordinates: ", coordinates);
await CameraUtils.absoluteMove({ camParams, ...coordinates });
const extractData = async (camParams, monitorPreset = { x: 0, y: 0, z: 0 }) => {
console.log("Moving to coordinates: ", monitorPreset);
await CameraUtils.absoluteMove({ camParams, ...monitorPreset });

const snapshotUrl = await CameraUtils.getSnapshotUri({ camParams });

Expand Down Expand Up @@ -112,26 +111,25 @@ const extractData = async (camParams, bedId) => {
return getSanitizedData(response.data.data);
};


const _getCamParams = (params) => {
const { hostname, username, password, port } = params;

const camParams = {
useSecure: Number(port) === 443,
hostname,
username,
password,
port: Number(port),
};
const { hostname, username, password, port } = params;

const camParams = {
useSecure: Number(port) === 443,
hostname,
username,
password,
port: Number(port),
};

return camParams;
return camParams;
};

export const updateObservationAuto = async (cameraParams, bedId) => {
export const updateObservationAuto = async (cameraParams, monitorPreset) => {
try {
const cameraParamsSanitized = _getCamParams(cameraParams);

const payload = await extractData(cameraParamsSanitized, bedId);
const payload = await extractData(cameraParamsSanitized, monitorPreset);

return payload;
} catch (err) {
Expand Down
1 change: 0 additions & 1 deletion src/automation/helper/getMonitorCoordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const getMonitorCoordinates = async (bedId) => {
const preset = await prisma.preset.findFirst({
where: {
bed: { externalId: bedId },
deleted: false,
},
});

Expand Down
5 changes: 4 additions & 1 deletion src/controller/ObservationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ const updateObservationsToCare = async () => {

console.log("updateObservationsToCare:cameraParams", cameraParams);

const v2Payload = await updateObservationAuto(cameraParams, bed_id);
const v2Payload = await updateObservationAuto(
cameraParams,
monitorPreset
);
await makeDataDumpToJson(
payload,
v2Payload,
Expand Down
1 change: 1 addition & 0 deletions src/utils/dailyRoundUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const getBedById = async (bedId) => {
},
include: {
camera: true,
monitorPreset: true,
},
});
};

0 comments on commit 719d98f

Please sign in to comment.