Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
elcojacobs committed Jul 1, 2024
1 parent 4ea07d1 commit d9e4cd5
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/plugins/quickstart/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ export const makeFridgeHeatConfig = (): PidConfig => ({
kp: inverseTempQty(20),
ti: bloxQty('2h'),
td: bloxQty('10m'),
});
});
137 changes: 78 additions & 59 deletions src/plugins/spark/components/widget/AnalogArrayEditor.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<script setup lang="ts">
import { AnalogClaimerInterfaceBlock, AnalogModuleChannel, BlockOrIntfType, GpioModuleBlock } from 'brewblox-proto/ts';
import {
ENUM_LABELS_ANALOG_SENSOR_TYPE,
} from '@/plugins/spark/const';
AnalogModuleChannel,
AnalogSensorType,
Block,
BlockOrIntfType,
} from 'brewblox-proto/ts';
import { defineProps } from 'vue';
import { ENUM_LABELS_ANALOG_SENSOR_TYPE } from '@/plugins/spark/const';
import { useSparkStore } from '@/plugins/spark/store';
import { computed, defineProps } from 'vue';
import { createBlockDialog } from '@/utils/block-dialog';
import { Block, AnalogSensorType } from 'brewblox-proto/ts';
import { createDialog } from '@/utils/dialog';
import { patchBlock } from '../../store/spark-api';
interface Props {
channels: AnalogModuleChannel[];
serviceId: string;
Expand All @@ -18,109 +20,126 @@ const sparkStore = useSparkStore();
const props = defineProps<Props>();
function existingSensors (channel : number) : Block[] {
return sparkStore.blocksByType(props.serviceId, BlockOrIntfType.TempSensorAnalog).filter(
(block) =>
block.data.analogDevice.id === props.blockId &&
block.data.analogChannel === channel
);
function existingSensors(channel: number): Block[] {
return sparkStore
.blocksByType(props.serviceId, BlockOrIntfType.TempSensorAnalog)
.filter(
(block) =>
block.data.analogDevice.id === props.blockId &&
block.data.analogChannel === channel,
);
}
function sensorToBlockType(sensorType: AnalogSensorType) : BlockOrIntfType | null{
if(sensorType === AnalogSensorType.ANALOG_SENSOR_TYPE_RTD_2WIRE ||
function sensorToBlockType(
sensorType: AnalogSensorType,
): BlockOrIntfType | null {
if (
sensorType === AnalogSensorType.ANALOG_SENSOR_TYPE_RTD_2WIRE ||
sensorType === AnalogSensorType.ANALOG_SENSOR_TYPE_RTD_3WIRE ||
sensorType === AnalogSensorType.ANALOG_SENSOR_TYPE_RTD_4WIRE){
sensorType === AnalogSensorType.ANALOG_SENSOR_TYPE_RTD_4WIRE
) {
return BlockOrIntfType.TempSensorAnalog;
}
return null;
}
function createSensor(sensorType: AnalogSensorType): void {
function createSensor(sensorType: BlockOrIntfType | null): void {
if (sensorType === null) {
return;
}
createDialog({
component: 'BlockWizardDialog',
componentProps: {
serviceId: props.serviceId,
compatible: BlockOrIntfType.TempSensorAnalog
compatible: sensorType,
},
});
}
</script>

<template>
<div class="column">
<div
v-for="channel in channels"
:key="`channel-${channel.id}`"
class="row q-gutter-xs"
>
<div
v-for="channel in channels"
:key="`channel-${channel.id}`"
class="row q-gutter-xs"
>
<LabeledField
label="Channel"
readonly
class="col-2"
>
Analog {{ channel.id }}
label="Channel"
readonly
class="col-2"
>
Analog {{ channel.id }}
</LabeledField>
<LabeledField
label="Sensor Type"
readonly
class="col-2"
>
{{ ENUM_LABELS_ANALOG_SENSOR_TYPE[channel.sensorType] }}
{{ ENUM_LABELS_ANALOG_SENSOR_TYPE[channel.sensorType] }}
</LabeledField>
<QuantityField v-if="channel.resistance !== undefined"
<QuantityField
v-if="channel.resistance !== undefined"
v-model="channel.resistance"
label="Resistance"
readonly
class="col-2"
/>
<QuantityField v-if="channel.leadResistance !== undefined"
<QuantityField
v-if="channel.leadResistance !== undefined"
v-model="channel.leadResistance"
label="Lead-wire"
readonly
class="col-2"
/>
<NumberField v-if="channel.bridgeOutput !== undefined"
<NumberField
v-if="channel.bridgeOutput !== undefined"
v-model="channel.bridgeOutput"
label="Sensor output"
readonly
class="col-2"
/>
<QuantityField v-if="channel.bridgeResistance !== undefined"
<QuantityField
v-if="channel.bridgeResistance !== undefined"
v-model="channel.bridgeResistance"
label="Sensor resistance"
readonly
class="col-2"
/>
<LabeledField
v-if="existingSensors(channel.id).length > 0"
label="Used by"
readonly
class="col-grow row">
<q-btn
v-for="userBlock in existingSensors(channel.id)"
:key="userBlock.id"
:label="userBlock.id"
dense
no-caps
flat
class="depth-1"
@click="createBlockDialog(userBlock)"
/>
v-if="existingSensors(channel.id).length > 0"
label="Used by"
readonly
class="col-grow row"
>
<q-btn
v-for="userBlock in existingSensors(channel.id)"
:key="userBlock.id"
:label="userBlock.id"
dense
no-caps
flat
class="depth-1"
@click="createBlockDialog(userBlock)"
/>
</LabeledField>
<LabeledField
v-if="sensorToBlockType(channel.sensorType) !== null && existingSensors(channel.id).length == 0"
label="Not used"
readonly
class="col-grow row">
<q-btn
label="New Sensor"
dense
no-caps
flat
class="depth-1"
@click="createSensor(channel.sensorType)"
/>
v-if="
sensorToBlockType(channel.sensorType) !== null &&
existingSensors(channel.id).length == 0
"
label="Not used"
readonly
class="col-grow row"
>
<q-btn
label="New Sensor"
dense
no-caps
flat
class="depth-1"
@click="createSensor(sensorToBlockType(channel.sensorType))"
/>
</LabeledField>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/spark/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ export const ENUM_LABELS_ANALOG_SENSOR_TYPE: EnumLabels<AnalogSensorType> = {
ANALOG_SENSOR_TYPE_RTD_3WIRE: 'RTD (3-wire)',
ANALOG_SENSOR_TYPE_RTD_4WIRE: 'RTD (4-wire)',
ANALOG_SENSOR_TYPE_RTD_3WIRE_LS: 'RTD (3-wire low side)',
};
};
23 changes: 14 additions & 9 deletions src/plugins/spark/features/GpioModule/GpioModuleWidget.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import {
GpioModuleBlock,
AnalogModuleChannel,
GpioErrorFlags,
GpioModuleBlock,
GpioModuleChannel,
GpioPins,
} from 'brewblox-proto/ts';
Expand All @@ -19,7 +19,8 @@ function listedPins(pins: GpioPins): number[] {
}
const { context } = useContext.setup();
const { serviceId, block, patchBlock } = useBlockWidget.setup<GpioModuleBlock>();
const { serviceId, block, patchBlock } =
useBlockWidget.setup<GpioModuleBlock>();
const power = computed<boolean>({
get: () => block.value.data.useExternalPower,
Expand Down Expand Up @@ -125,12 +126,12 @@ const errors = computed<string[]>(() => {
{{ block.data.modulePosition }}
</LabeledField>
<QuantityField
v-if="block.data.baroPressure != undefined"
:model-value="block.data.baroPressure"
label="Barometric pressure"
class="col-3"
readonly
/>
v-if="block.data.baroPressure != undefined"
:model-value="block.data.baroPressure"
label="Barometric pressure"
class="col-3"
readonly
/>
</div>
<q-separator />
<GpioArrayEditor
Expand All @@ -140,7 +141,11 @@ const errors = computed<string[]>(() => {

<template v-if="analogChannels.length > 0">
<q-separator />
<AnalogArrayEditor v-model:channels="analogChannels" :service-id="serviceId" :block-id="block.id"/>
<AnalogArrayEditor
v-model:channels="analogChannels"
:service-id="serviceId"
:block-id="block.id"
/>
</template>
<div class="col-break" />
<template v-if="context.mode === 'Full'">
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/spark/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ const plugins: Plugin[] = [
Variables,
];

export default plugins;
export default plugins;
2 changes: 1 addition & 1 deletion src/plugins/spark/utils/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ export function prettyLimitations(
}

return output.join(', ');
}
}

0 comments on commit d9e4cd5

Please sign in to comment.