Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
slietar committed Jun 22, 2023
1 parent 57fd24d commit 17a8152
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/electron/forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
/^\/node_modules(\/|$)/,
/^\/scripts(\/|$)/,
/^\/src(\/|$)/,
/^\/tsconfig.json$/,
/^\/tsconfig(?:\.[^\/]*)?\.json$/,
/^\/tmp(\/|$)/
],
afterCopy: [
Expand Down
2 changes: 1 addition & 1 deletion app/electron/src/host/app-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class ElectronAppDocumentSlot extends SnapshotProvider<DocumentSlotSnapsh
instance: this._instance && {
...this._instance
},
path: this._path.split('/'),
path: this._path.split((window.api.platform === 'win32') ? '\\' : '/'),
status: this._status
};
}
Expand Down
7 changes: 4 additions & 3 deletions host/pr1/fiber/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,13 @@ def export(self):

class FiberParser:
def __init__(self, draft: Draft, *, Parsers: Sequence[type[BaseParser]], host: 'Host'):
self._next_eval_symbol = 0
self._parsers: list[BaseParser] = [Parser(self) for Parser in Parsers]

# Must be before self._parsers is initialized
self.draft = draft
self.host = host

self._next_eval_symbol = 0
self._parsers: list[BaseParser] = [Parser(self) for Parser in Parsers]

self.analysis, protocol = self._parse()
self.protocol = protocol if not isinstance(protocol, EllipsisType) else None

Expand Down
4 changes: 2 additions & 2 deletions units/adaptyv_nikon/src/pr1_adaptyv_nikon/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(self, fiber):
objectives = executor._objectives
optconfs = executor._optconfs

assert objectives
assert optconfs
assert objectives is not None
assert optconfs is not None

self.transformers = [am.ProcessTransformer(Process, {
'capture': am.Attribute(
Expand Down
21 changes: 19 additions & 2 deletions units/core/client/src/devices/components/node-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,35 @@ export class NodeDetail extends Component<NodeDetailProps, NodeDetailState> {
magnitude = '[disabled]';
} else {
switch (spec.type) {
case 'numeric':
case 'boolean': {
magnitude = (lastValueEvent.value.innerValue as boolean) ? 'true' : 'false';
break;
}

case 'enum': {
let caseId = lastValueEvent.value.innerValue as (number | string);
let specCase = spec.cases.find((specCase) => (specCase.id === caseId))!;

magnitude = specCase.label;
break;
}

case 'numeric': {
let joint;

[magnitude, joint, unit] = ureg.formatQuantityAsReact((lastValueEvent.value.innerValue as NumericValue).magnitude, spec.resolution ?? 0, ureg.deserializeContext(spec.context), {
createElement,
sign: (spec.range && spec.range[0] < 0),
style: 'symbol'
});

break;
default:
}

default: {
magnitude = '[unknown]';
break;
}
}
}

Expand Down
34 changes: 23 additions & 11 deletions units/core/client/src/devices/components/node-hierarchy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,29 @@ export function NodeHierarchyNode(props: {
let spec = props.node.spec;

if (lastValue && (lastValue.type === 'default')) {
if (spec.type === 'numeric') {
entryValue = ureg.formatQuantityAsReact((lastValue.innerValue as NumericValue).magnitude, spec.resolution ?? 0, ureg.deserializeContext(spec.context), {
createElement,
sign: (spec.range && spec.range[0] < 0),
style: 'symbol'
});
} else if (spec.type === 'enum') {
let caseId = lastValue.innerValue as (number | string);
let specCase = spec.cases.find((specCase) => (specCase.id === caseId))!;

entryValue = (specCase.label ?? specCase.id);
switch (spec.type) {
case 'boolean': {
entryValue = (lastValue.innerValue as boolean) ? 'On' : 'Off';
break;
}

case 'enum': {
let caseId = lastValue.innerValue as (number | string);
let specCase = spec.cases.find((specCase) => (specCase.id === caseId))!;

entryValue = (specCase.label ?? specCase.id);
break;
}

case 'numeric': {
entryValue = ureg.formatQuantityAsReact((lastValue.innerValue as NumericValue).magnitude, spec.resolution ?? 0, ureg.deserializeContext(spec.context), {
createElement,
sign: (spec.range && spec.range[0] < 0),
style: 'symbol'
});

break;
}
}
} else {
entryValue = '–';
Expand Down
19 changes: 13 additions & 6 deletions units/okolab/src/pr1_okolab/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def __init__(self, *, master: 'MasterDevice'):
super().__init__(
context="temperature",
readable=True,
poll_interval=1.0
poll_interval=1.0,
resolution=(0.1 * am.ureg.K)
)

self.icon = "thermostat"
Expand All @@ -42,7 +43,8 @@ def __init__(self, *, worker: 'WorkerDevice'):
super().__init__(
context="temperature",
poll_interval=0.2,
readable=True
readable=True,
resolution=(0.1 * am.ureg.K)
)

self.icon = "thermostat"
Expand All @@ -53,7 +55,13 @@ def __init__(self, *, worker: 'WorkerDevice'):

async def _read(self):
async def read():
return (await self._worker._get_temperature_readout()) * am.ureg.degC
value = await self._worker._get_temperature_readout()

if value is None:
self.connected = False
raise am.NodeUnavailableError

return value * am.ureg.degC

try:
await self._set_value_at_half_time(read())
Expand All @@ -70,6 +78,7 @@ def __init__(self, *, worker: 'WorkerDevice'):
25.0 * am.ureg.degC,
60.0 * am.ureg.degC
),
resolution=(0.1 * am.ureg.K),
readable=True,
writable=True
)
Expand All @@ -91,7 +100,7 @@ async def read():

async def _write(self, value: Quantity | am.NullType, /):
try:
await self._worker._set_temperature_setpoint((value / am.ureg.degC).magnitude if not isinstance(value, am.NullType) else None)
await self._worker._set_temperature_setpoint(value.magnitude_as(am.ureg.degC) if not isinstance(value, am.NullType) else None)
except OkolabDeviceConnectionError as e:
raise am.NodeUnavailableError from e

Expand Down Expand Up @@ -260,8 +269,6 @@ def __init__(

self._node_readout = TemperatureReadoutNode(worker=self)
self._node_setpoint = TemperatureSetpointNode(worker=self)
self._status = None
self._status_check_task = None

self.nodes = { node.id: node for node in {self._node_readout, self._node_setpoint} }

Expand Down

0 comments on commit 17a8152

Please sign in to comment.