arbeiten am callibration
This commit is contained in:
@@ -937,6 +937,54 @@ app.post('/api/calibration/upload-npz', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ── X-Achse / Rotations-Detektion ────────────────────────────────────────────
|
||||
|
||||
const xaxisDataDir = path.join(__dirname, '..', 'data', 'xaxis');
|
||||
const ROTATION_DETECTION_FILE = path.join(xaxisDataDir, 'rotation_detection.json');
|
||||
|
||||
/** POST /api/xaxis/save-rotation-detection
|
||||
* Speichert eine Achsmessung an rotation_detection.json (append-Modus). */
|
||||
app.post('/api/xaxis/save-rotation-detection', express.json(), async (req, res) => {
|
||||
try {
|
||||
const { axis, runs, numMarkers, markers } = req.body ?? {};
|
||||
if (!axis || !axis.dir || !axis.referencePoint) {
|
||||
return res.status(400).json({ error: 'Ungültige Nutzlast: axis.dir und axis.referencePoint erwartet' });
|
||||
}
|
||||
|
||||
// Verzeichnis anlegen falls nötig
|
||||
await fsPromises.mkdir(xaxisDataDir, { recursive: true });
|
||||
|
||||
// Bestehende Einträge lesen oder leer beginnen
|
||||
let entries = [];
|
||||
try {
|
||||
const raw = await fsPromises.readFile(ROTATION_DETECTION_FILE, 'utf-8');
|
||||
entries = JSON.parse(raw);
|
||||
if (!Array.isArray(entries)) entries = [];
|
||||
} catch {
|
||||
// Datei existiert noch nicht – kein Fehler
|
||||
}
|
||||
|
||||
const newEntry = {
|
||||
timestamp: new Date().toISOString(),
|
||||
runs: runs ?? {},
|
||||
axis,
|
||||
numMarkers: numMarkers ?? null,
|
||||
markers: markers ?? [],
|
||||
};
|
||||
|
||||
entries.push(newEntry);
|
||||
await fsPromises.writeFile(ROTATION_DETECTION_FILE, JSON.stringify(entries, null, 2), 'utf-8');
|
||||
|
||||
return res.json({
|
||||
file: 'data/xaxis/rotation_detection.json',
|
||||
total: entries.length,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('save-rotation-detection error:', err);
|
||||
return res.status(500).json({ error: String(err) });
|
||||
}
|
||||
});
|
||||
|
||||
async function checkServiceReachability(name, url) {
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
|
||||
Reference in New Issue
Block a user