Skip to content

Commit

Permalink
Merge pull request #1873 from elcojacobs/feature/gpio-module-merge
Browse files Browse the repository at this point in the history
Update display of analog channels in gpio module
  • Loading branch information
steersbob authored Jul 1, 2024
2 parents 1912d03 + 96ca097 commit c8a5c4a
Show file tree
Hide file tree
Showing 14 changed files with 181 additions and 313 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=7debb0ff
firmware_date=2024-05-17
firmware_sha=7debb0ff847e26973987fe974b96443f0de06eb4
proto_version=085aa575
proto_date=2024-05-17
proto_sha=085aa5756728fe8815c434d6d2a61976b642f4b4
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=4f015c84245de0cc0dbf07c8f23e90e4ba1b1779",
"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
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const opts = computed<SelectOption<IoChannelAddress>[]>(() => {
.filter(
(block): block is IoArrayInterfaceBlock =>
isCompatible(block.type, BlockIntfType.IoArrayInterface) &&
block.type !== BlockType.OneWireGpioModule,
block.type !== BlockType.GpioModule,
)
.flatMap((block): IoChannelAddress[] =>
block.data.channels.map((channel: IoChannel) => ({
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/quickstart/components/QuickstartDiscoveryTask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
BlockType,
DS2408Block,
DS2413Block,
OneWireGpioModuleBlock,
GpioModuleBlock,
TempSensorOneWireBlock,
} from 'brewblox-proto/ts';
import { computed, onBeforeMount } from 'vue';
Expand Down Expand Up @@ -37,7 +37,7 @@ const discoveredBlocks = computed<Block[]>(
.filter((block) =>
isCompatible(block.type, [
BlockIntfType.OneWireDeviceInterface,
BlockType.OneWireGpioModule,
BlockType.GpioModule,
]),
)
.sort(makeObjectSorter('id')) ?? [],
Expand All @@ -48,7 +48,7 @@ function about(block: Block): string {
return prettyQty(block.data.value);
}
if (matchesType<OneWireGpioModuleBlock>(BlockType.OneWireGpioModule, block)) {
if (matchesType<GpioModuleBlock>(BlockType.GpioModule, block)) {
return `Position ${block.data.modulePosition}`;
}
Expand Down
10 changes: 4 additions & 6 deletions src/plugins/quickstart/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
BlockType,
DigitalActuatorBlock,
OneWireGpioModuleBlock,
GpioModuleBlock,
PidBlock,
} from 'brewblox-proto/ts';
import cloneDeep from 'lodash/cloneDeep';
Expand All @@ -26,14 +26,12 @@ const digitalActuatorFilter = makeTypeFilter<DigitalActuatorBlock>(
BlockType.DigitalActuator,
);

const oneWireGpioFilter = makeTypeFilter<OneWireGpioModuleBlock>(
BlockType.OneWireGpioModule,
);
const GpioFilter = makeTypeFilter<GpioModuleBlock>(BlockType.GpioModule);

export function resetGpioChanges(serviceId: string): GpioChange[] {
return useSparkStore()
.blocksByService(serviceId)
.filter(oneWireGpioFilter)
.filter(GpioFilter)
.sort((a, b) => a.data.modulePosition - b.data.modulePosition)
.map((block) => ({
blockId: block.id,
Expand Down Expand Up @@ -69,7 +67,7 @@ export function unlinkedActuators(
export function changedIoModules(
serviceId: string,
changes: GpioChange[],
): QuickstartPatch<OneWireGpioModuleBlock>[] {
): QuickstartPatch<GpioModuleBlock>[] {
return changes.map((change) => {
const { blockId, channels } = change;
return { blockId, patch: { channels } };
Expand Down
133 changes: 125 additions & 8 deletions src/plugins/spark/components/widget/AnalogArrayEditor.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,147 @@
<script setup lang="ts">
import { AnalogModuleChannel } from 'brewblox-proto/ts';
import {
AnalogModuleChannel,
AnalogSensorType,
Block,
BlockOrIntfType,
} from 'brewblox-proto/ts';
import { computed } from 'vue';
import { ENUM_LABELS_ANALOG_SENSOR_TYPE } from '@/plugins/spark/const';
import { useSparkStore } from '@/plugins/spark/store';
import { BlockAddress } from '@/plugins/spark/types';
import { createBlockDialog } from '@/utils/block-dialog';
import { createDialog } from '@/utils/dialog';
interface Props {
channels: AnalogModuleChannel[];
address: BlockAddress;
}
const sparkStore = useSparkStore();
defineProps<Props>();
const props = defineProps<Props>();
const existingSensors = computed<{ [channelId: number]: Block[] }>(() => {
const sensors = sparkStore
.blocksByType(props.address.serviceId, BlockOrIntfType.TempSensorAnalog)
.filter((block) => block.data.analogDevice.id === props.address.id);
return props.channels.reduce((acc, channel) => {
acc[channel.id] = sensors.filter(
(block) => block.data.analogChannel === channel.id,
);
return acc;
}, {});
});
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: BlockOrIntfType | null): void {
if (sensorType == null) {
return;
}
createDialog({
component: 'BlockWizardDialog',
componentProps: {
serviceId: props.address.serviceId,
compatible: sensorType,
},
});
}
</script>

<template>
<div class="column q-gutter-y-sm">
<div class="column">
<div
v-for="channel in channels"
:key="`channel-${channel.id}`"
class="row q-gutter-sm"
class="row q-gutter-xs"
>
<LabeledField
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] }}
</LabeledField>
<QuantityField
v-if="channel.resistance !== undefined"
v-model="channel.resistance"
label="Resistance"
readonly
class="col-2"
/>
<QuantityField
v-if="channel.leadResistance !== undefined"
v-model="channel.leadResistance"
label="Lead-wire"
readonly
class="col-2"
/>
<NumberField
v-model="channel.id"
label="ID"
v-if="channel.bridgeOutput !== undefined"
v-model="channel.bridgeOutput"
label="Sensor output"
readonly
class="col-2"
/>
<QuantityField
v-if="channel.bridgeResistance !== undefined"
v-model="channel.bridgeResistance"
label="Sensor resistance"
readonly
class="col-2"
/>
<LabeledField
label="Sensor Type"
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"
>
{{ channel.sensorType }}
<q-btn
label="New Sensor"
dense
no-caps
flat
class="depth-1"
@click="createSensor(sensorToBlockType(channel.sensorType))"
/>
</LabeledField>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 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)',
};
78 changes: 0 additions & 78 deletions src/plugins/spark/features/AnalogGpioModule/index.ts

This file was deleted.

Loading

0 comments on commit c8a5c4a

Please sign in to comment.