DAQ+GUI: Work in progress
This commit is contained in:
+22
-10
@@ -9,7 +9,7 @@ from aaredaqlib.coordinate import SmargonCoordinate, Coordinate
|
||||
from aaredaqlib.models import SampleShortInfo, DAQStatusModel, BeamlineStateEnum, BeamlineSettingsModel, \
|
||||
SampleShortInfoList, SessionStatus, SampleCameraSettings, AutofocusSettings, TokenData
|
||||
from aaredaqlib.raster_grid import RasterGridRequest, CompletedRasterGrid
|
||||
from aaredaqlib.rotation_scan import RotationScanRequest
|
||||
from aaredaqlib.rotation_scan import RotationScanRequest, CompletedRotationScan
|
||||
from aaredaqlib.sample_geometry import SampleGeometryModel
|
||||
from fastapi import FastAPI, Depends
|
||||
from fastapi import HTTPException
|
||||
@@ -162,7 +162,7 @@ async def get_image(token: str = Depends(oauth2_scheme)):
|
||||
|
||||
|
||||
# TELL procedures
|
||||
@app.get("/tell/sample")
|
||||
@app.get("/sample/curr_sample")
|
||||
async def sample(token: str = Depends(oauth2_scheme)) -> SampleShortInfo:
|
||||
token_data = auth.parse_token(token)
|
||||
auth.check_jwt_ro(cfg, auth.parse_token(token))
|
||||
@@ -175,12 +175,12 @@ async def sample(token: str = Depends(oauth2_scheme)) -> SampleShortInfo:
|
||||
puck_name="",
|
||||
dewar_name="",
|
||||
db_id=-1,
|
||||
pin=sample.pin,
|
||||
location=sample.location
|
||||
pin=s.pin,
|
||||
location=s.location
|
||||
)
|
||||
|
||||
|
||||
@app.post("/tell/mount")
|
||||
@app.post("/sample/mount")
|
||||
async def mount(dbid: int, token: str = Depends(oauth2_scheme)):
|
||||
token_data = auth.parse_token(token)
|
||||
auth.check_jwt_rw(cfg, auth.parse_token(token))
|
||||
@@ -204,12 +204,25 @@ async def mount(dbid: int, token: str = Depends(oauth2_scheme)):
|
||||
)
|
||||
|
||||
|
||||
@app.post("/tell/unmount")
|
||||
@app.post("/sample/unmount")
|
||||
async def unmount(token: str = Depends(oauth2_scheme)):
|
||||
auth.check_jwt_rw(cfg, auth.parse_token(token))
|
||||
daq.sample = None
|
||||
return "OK"
|
||||
|
||||
@app.post("/sample/clear")
|
||||
async def sample_clear(token: str = Depends(oauth2_scheme)):
|
||||
auth.check_jwt_rw(cfg, auth.parse_token(token))
|
||||
daq.clear_current_sample()
|
||||
return "OK"
|
||||
|
||||
@app.post("/sample/manual")
|
||||
async def manual(s: SampleShortInfo, token: str = Depends(oauth2_scheme)):
|
||||
auth.check_jwt_rw(cfg, auth.parse_token(token))
|
||||
print(f"DB ID prior creating {s.db_id}")
|
||||
daq.create_sample(s)
|
||||
print(f"DB ID after creating {s.db_id}")
|
||||
|
||||
|
||||
def get_spreadsheet(data: TokenData) -> SampleShortInfoList:
|
||||
if data.staff:
|
||||
@@ -242,7 +255,7 @@ async def spreadsheet_sse(token: str = Depends(oauth2_scheme)):
|
||||
)
|
||||
|
||||
|
||||
@app.get("/tell/spreadsheet")
|
||||
@app.get("/sample/spreadsheet")
|
||||
async def spreadsheet(token: str = Depends(oauth2_scheme)) -> SampleShortInfoList:
|
||||
return get_spreadsheet(auth.parse_token(token))
|
||||
|
||||
@@ -280,10 +293,9 @@ async def raster(val: RasterGridRequest, token: str = Depends(oauth2_scheme)) ->
|
||||
|
||||
|
||||
@app.post("/scan/rotation")
|
||||
async def rotation(val: RotationScanRequest, token: str = Depends(oauth2_scheme)):
|
||||
async def rotation(val: RotationScanRequest, token: str = Depends(oauth2_scheme)) -> CompletedRotationScan:
|
||||
auth.check_jwt_rw(cfg, auth.parse_token(token))
|
||||
daq.measure_rotation(val)
|
||||
return "OK"
|
||||
return daq.measure_rotation(val)
|
||||
|
||||
@app.post("/scan/auto")
|
||||
async def auto(s: SampleShortInfo, token: str = Depends(oauth2_scheme)):
|
||||
|
||||
Reference in New Issue
Block a user