Skip to content

Commit

Permalink
update analog channels in GPIO module
Browse files Browse the repository at this point in the history
  • Loading branch information
elcojacobs committed Jul 1, 2024
1 parent d4fa6a9 commit 4ea07d1
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 55 deletions.
12 changes: 6 additions & 6 deletions firmware.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[FIRMWARE]
firmware_version=1b1103d4
firmware_date=2024-06-27
firmware_sha=1b1103d46643d6b3f26dc3a8ca5754cb6afcd40a
proto_version=e50c045c
proto_date=2024-06-27
proto_sha=e50c045c341e570e1fd141f54979e9e5ce9bd62e
firmware_version=3396d383
firmware_date=2024-07-01
firmware_sha=3396d383f8b05a1a096b5f9fc7c2f31efcc07f96
proto_version=7a7cafa4
proto_date=2024-07-01
proto_sha=7a7cafa46705bfe03945a6cd3978b88f37d28102
system_version=3.2.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@quasar/extras": "^1.16.11",
"axios": "^1.6.8",
"brewblox-proto": "https://github.com/brewblox/brewblox-proto#commit=e50c045c341e570e1fd141f54979e9e5ce9bd62e",
"brewblox-proto": "https://github.com/brewblox/brewblox-proto#commit=7a7cafa46705bfe03945a6cd3978b88f37d28102",
"buffer": "^6.0.3",
"cm6-theme-basic-dark": "^0.2.0",
"codemirror": "^6.0.1",
Expand Down
126 changes: 111 additions & 15 deletions src/plugins/spark/components/widget/AnalogArrayEditor.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,126 @@
<script setup lang="ts">
import { AnalogModuleChannel } from 'brewblox-proto/ts';
import { AnalogClaimerInterfaceBlock, AnalogModuleChannel, BlockOrIntfType, GpioModuleBlock } from 'brewblox-proto/ts';

Check failure on line 2 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

This line has a length of 119. Maximum allowed is 100

Check warning on line 2 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

'AnalogClaimerInterfaceBlock' is defined but never used

Check warning on line 2 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

'GpioModuleBlock' is defined but never used
import {
ENUM_LABELS_ANALOG_SENSOR_TYPE,
} from '@/plugins/spark/const';
import { useSparkStore } from '@/plugins/spark/store';
import { computed, defineProps } from 'vue';

Check warning on line 7 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

'computed' is defined but never used
import { createBlockDialog } from '@/utils/block-dialog';
import { Block, AnalogSensorType } from 'brewblox-proto/ts';
import { createDialog } from '@/utils/dialog';
import { patchBlock } from '../../store/spark-api';

Check warning on line 11 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

'patchBlock' is defined but never used
interface Props {
channels: AnalogModuleChannel[];
serviceId: string;
blockId: string;
}
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

Check failure on line 25 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

Missing trailing comma
);
}
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){
return BlockOrIntfType.TempSensorAnalog;
}
return null;
}
function createSensor(sensorType: AnalogSensorType): void {

Check warning on line 38 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

'sensorType' is defined but never used
createDialog({
component: 'BlockWizardDialog',
componentProps: {
serviceId: props.serviceId,
compatible: BlockOrIntfType.TempSensorAnalog

Check failure on line 43 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

Missing trailing comma
},
});
}
defineProps<Props>();
</script>

<template>
<div class="column q-gutter-y-sm">
<div
v-for="channel in channels"
:key="`channel-${channel.id}`"
class="row q-gutter-sm"
>
<NumberField
v-model="channel.id"
label="ID"
readonly
/>
<div class="column">
<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 }}
</LabeledField>
<LabeledField
label="Sensor Type"
readonly
class="col-2"
>
{{ channel.sensorType }}
{{ ENUM_LABELS_ANALOG_SENSOR_TYPE[channel.sensorType] }}
</LabeledField>
<QuantityField v-if="channel.resistance !== undefined"

Check warning on line 71 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

Expected a linebreak before this attribute
v-model="channel.resistance"
label="Resistance"
readonly
class="col-2"
/>
<QuantityField v-if="channel.leadResistance !== undefined"

Check warning on line 77 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

Expected a linebreak before this attribute
v-model="channel.leadResistance"
label="Lead-wire"
readonly
class="col-2"
/>
<NumberField v-if="channel.bridgeOutput !== undefined"

Check warning on line 83 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

Expected a linebreak before this attribute
v-model="channel.bridgeOutput"
label="Sensor output"
readonly
class="col-2"
/>
<QuantityField v-if="channel.bridgeResistance !== undefined"

Check warning on line 89 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

Expected a linebreak before this attribute
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)"
/>
</LabeledField>
<LabeledField
v-if="sensorToBlockType(channel.sensorType) !== null && existingSensors(channel.id).length == 0"

Check failure on line 112 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

This line has a length of 102. Maximum allowed is 100
label="Not used"
readonly
class="col-grow row">
<q-btn
label="New Sensor"
dense
no-caps
flat
class="depth-1"
@click="createSensor(channel.sensorType)"
/>
</LabeledField>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/spark/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export const ENUM_LABELS_TEMP_SENSOR_ANALOG_SPEC: EnumLabels<TempSensorAnalogSpe
export const ENUM_LABELS_ANALOG_SENSOR_TYPE: EnumLabels<AnalogSensorType> = {
ANALOG_SENSOR_TYPE_NONE: 'None',
ANALOG_SENSOR_TYPE_STRAIN_GAUGE: 'Strain gauge',
ANALOG_SENSOR_TYPE_RTD_2WIRE: 'RTD (two wire)',
ANALOG_SENSOR_TYPE_RTD_3WIRE: 'RTD (three wire)',
ANALOG_SENSOR_TYPE_RTD_4WIRE: 'RTD (four wire)',
ANALOG_SENSOR_TYPE_RTD_3WIRE_LS: 'RTD (three wire LS)',
};
ANALOG_SENSOR_TYPE_RTD_2WIRE: 'RTD (2-wire)',
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)',
};
40 changes: 16 additions & 24 deletions src/plugins/spark/features/GpioModule/GpioModuleWidget.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import {
GpioModuleBlock,
AnalogChannel,
AnalogModuleChannel,
GpioErrorFlags,
GpioModuleChannel,
GpioPins,
Expand All @@ -19,7 +19,7 @@ function listedPins(pins: GpioPins): number[] {
}
const { context } = useContext.setup();
const { 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 @@ -120,39 +120,31 @@ const errors = computed<string[]>(() => {
<div class="row q-gutter-sm">
<LabeledField
label="Module position"
class="col-grow"
class="col-3"
>
{{ block.data.modulePosition }}
</LabeledField>
</div>

<GpioArrayEditor
v-model:channels="channels"
:error-pins="block.data.status.overCurrent"
/>

<AnalogArrayEditor v-model:channels="analogChannels" />

<div class="col-break" />

<QuantityField
<QuantityField
v-if="block.data.baroPressure != undefined"
:model-value="block.data.baroPressure"
label="Barometric pressure"
class="col-grow"
class="col-3"
readonly
/>

<NumberField
v-if="block.data.baroTemperature != undefined"
:model-value="block.data.baroTemperature"
label="Barometric temperature"
class="col-grow"
readonly
</div>
<q-separator />
<GpioArrayEditor
v-model:channels="channels"
:error-pins="block.data.status.overCurrent"
/>

<template v-if="analogChannels.length > 0">
<q-separator />
<AnalogArrayEditor v-model:channels="analogChannels" :service-id="serviceId" :block-id="block.id"/>

Check failure on line 143 in src/plugins/spark/features/GpioModule/GpioModuleWidget.vue

View workflow job for this annotation

GitHub Actions / build

This line has a length of 107. Maximum allowed is 100
</template>
<div class="col-break" />
<template v-if="context.mode === 'Full'">
<q-separator inset />
<q-separator />

<div class="column q-gutter-sm">
<div>
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3060,12 +3060,12 @@ __metadata:
languageName: node
linkType: hard

"brewblox-proto@https://github.com/brewblox/brewblox-proto#commit=e50c045c341e570e1fd141f54979e9e5ce9bd62e":
"brewblox-proto@https://github.com/brewblox/brewblox-proto#commit=7a7cafa46705bfe03945a6cd3978b88f37d28102":
version: 1.0.0
resolution: "brewblox-proto@https://github.com/brewblox/brewblox-proto.git#commit=e50c045c341e570e1fd141f54979e9e5ce9bd62e"
resolution: "brewblox-proto@https://github.com/brewblox/brewblox-proto.git#commit=7a7cafa46705bfe03945a6cd3978b88f37d28102"
dependencies:
typescript-string-enums: "npm:^1.0.0"
checksum: 10c0/a54432c9d80bef06e4c4027db9c0ba9425a2bf9fe64d875fcd1a5a9ffa81600f58ae7cba807026847b658dd82d8e973e3924eba84ade4e87c69020caa59f6123
checksum: 10c0/ef546734ba16317186030a70bc3c57557e4aa3928c8b83845cfcfa517a4eee6a6d237f2e71f01f931c74082ccfb0d20231fec5f0178c2909714e59944db416e7
languageName: node
linkType: hard

Expand Down Expand Up @@ -3096,7 +3096,7 @@ __metadata:
"@vue/test-utils": "npm:^2.4.6"
autoprefixer: "npm:^10.4.19"
axios: "npm:^1.6.8"
brewblox-proto: "https://github.com/brewblox/brewblox-proto#commit=e50c045c341e570e1fd141f54979e9e5ce9bd62e"
brewblox-proto: "https://github.com/brewblox/brewblox-proto#commit=7a7cafa46705bfe03945a6cd3978b88f37d28102"
buffer: "npm:^6.0.3"
cm6-theme-basic-dark: "npm:^0.2.0"
codemirror: "npm:^6.0.1"
Expand Down

0 comments on commit 4ea07d1

Please sign in to comment.