Skip to content
Snippets Groups Projects
Commit a3e2473a authored by Nils Brinckmann's avatar Nils Brinckmann
Browse files

Add field for inserting firmware version

parent e5e4d09e
No related branches found
No related tags found
1 merge request!67Add field for inserting firmware version
......@@ -103,6 +103,18 @@ permissions and limitations under the Licence.
/>
</v-menu>
</v-col>
<v-col
cols="12"
md="2"
>
<v-text-field
:value="value.firemwareVersion"
label="Firmware version"
:readonly="readonly"
:disabled="readonly"
@change="update('firmwareVersion', $event)"
/>
</v-col>
</v-row>
</div>
</template>
......@@ -176,6 +188,9 @@ export default class DeviceConfigurationAttributesForm extends Vue {
case 'calibrationDate':
newObj.calibrationDate = stringToDate(value)
break
case 'firmwareVersion':
newObj.firmwareVersion = String(value)
break
default:
throw new TypeError('key ' + key + ' is not valid')
}
......
......@@ -37,6 +37,7 @@ export interface IDeviceConfigurationAttributes {
offsetY: number
offsetZ: number
calibrationDate: Date | null
firmwareVersion: string
}
export class DeviceConfigurationAttributes implements IDeviceConfigurationAttributes {
......@@ -45,6 +46,7 @@ export class DeviceConfigurationAttributes implements IDeviceConfigurationAttrib
private _offsetY: number = 0
private _offsetZ: number = 0
private _calibrationDate: Date | null = null
private _firmwareVersion: string = ''
constructor (device: Device) {
this._device = device
......@@ -57,6 +59,7 @@ export class DeviceConfigurationAttributes implements IDeviceConfigurationAttrib
newObject.offsetY = someObject.offsetY
newObject.offsetZ = someObject.offsetZ
newObject.calibrationDate = someObject.calibrationDate instanceof Date ? new Date(someObject.calibrationDate.getTime()) : null
newObject.firmwareVersion = someObject.firmwareVersion
return newObject
}
......@@ -100,4 +103,12 @@ export class DeviceConfigurationAttributes implements IDeviceConfigurationAttrib
set calibrationDate (date: Date | null) {
this._calibrationDate = date
}
get firmwareVersion (): string {
return this._firmwareVersion
}
set firmwareVersion (newFirmwareVersion: string) {
this._firmwareVersion = newFirmwareVersion
}
}
......@@ -187,7 +187,8 @@ export class ConfigurationSerializer {
offsetX: element.offset_x || 0.0,
offsetY: element.offset_y || 0.0,
offsetZ: element.offset_z || 0.0,
calibrationDate: element.calibration_date != null ? new Date(element.calibration_date) : null
calibrationDate: element.calibration_date != null ? new Date(element.calibration_date) : null,
firmwareVersion: element.firmware_version || ''
})
listOfDeviceAttributes.push(deviceAttribute)
......@@ -306,6 +307,7 @@ export class ConfigurationSerializer {
if (calibrationDate != null) {
elementData.calibration_date = calibrationDate.toISOString()
}
elementData.firmware_version = deviceAttributeLookupById[id].firmwareVersion
}
listOfChildren.push(elementData)
}
......
......@@ -47,7 +47,14 @@ describe('DeviceConfigurationAttributes', () => {
device.id = '1'
const now = new Date()
const attributes = DeviceConfigurationAttributes.createFromObject({ device, offsetX: 1, offsetY: 1, offsetZ: 1, calibrationDate: now })
const attributes = DeviceConfigurationAttributes.createFromObject({
device,
offsetX: 1,
offsetY: 1,
offsetZ: 1,
calibrationDate: now,
firmwareVersion: 'v.1.0'
})
expect(typeof attributes).toBe('object')
expect(attributes.device).toBe(device)
expect(attributes).toHaveProperty('id', '1')
......@@ -55,5 +62,6 @@ describe('DeviceConfigurationAttributes', () => {
expect(attributes).toHaveProperty('offsetY', 1)
expect(attributes).toHaveProperty('offsetZ', 1)
expect(attributes).toHaveProperty('calibrationDate', now)
expect(attributes).toHaveProperty('firmwareVersion', 'v.1.0')
})
})
......@@ -90,14 +90,16 @@ describe('ConfigurationSerializer', () => {
offset_x: 7.0,
offset_y: 8.0,
offset_z: 9.0,
calibration_date: '2020-01-01T13:49:48.015620+00:00'
calibration_date: '2020-01-01T13:49:48.015620+00:00',
firmware_version: 'v1.0'
}, {
type: 'device',
id: '40',
offset_x: 10.0,
offset_y: 11.0,
offset_z: 12.0,
calibration_date: null
calibration_date: null,
firmware_version: null
}]
}]
}, {
......@@ -606,14 +608,16 @@ describe('ConfigurationSerializer', () => {
offsetX: 7.0,
offsetY: 8.0,
offsetZ: 9.0,
calibrationDate: new Date('2020-01-01T13:49:48.015620+00:00')
calibrationDate: new Date('2020-01-01T13:49:48.015620+00:00'),
firmwareVersion: 'v1.0'
}),
DeviceConfigurationAttributes.createFromObject({
device: expectedDevice2,
offsetX: 10.0,
offsetY: 11.0,
offsetZ: 12.0,
calibrationDate: null
calibrationDate: null,
firmwareVersion: ''
})
]
......@@ -1182,7 +1186,8 @@ describe('ConfigurationSerializer', () => {
offsetX: 11.0,
offsetY: 12.0,
offsetZ: 13.0,
calibrationDate: null
calibrationDate: null,
firmwareVersion: ''
}),
// none for device4
DeviceConfigurationAttributes.createFromObject({
......@@ -1190,7 +1195,8 @@ describe('ConfigurationSerializer', () => {
offsetX: 22.0,
offsetY: 23.0,
offsetZ: 24.0,
calibrationDate: new Date('2020-11-09T00:00:00.000Z')
calibrationDate: new Date('2020-11-09T00:00:00.000Z'),
firmwareVersion: 'v.2.0'
})
]
......@@ -1215,7 +1221,8 @@ describe('ConfigurationSerializer', () => {
id: '3',
offset_x: 11.0,
offset_y: 12.0,
offset_z: 13.0
offset_z: 13.0,
firmware_version: ''
}, {
type: 'device',
id: '4'
......@@ -1225,7 +1232,8 @@ describe('ConfigurationSerializer', () => {
offset_x: 22.0,
offset_y: 23.0,
offset_z: 24.0,
calibration_date: '2020-11-09T00:00:00.000Z'
calibration_date: '2020-11-09T00:00:00.000Z',
firmware_version: 'v.2.0'
}]
}]
}, {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment