Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed fetching monitor presets #95

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
},
});
};
Loading