@@ -3,10 +3,19 @@ import {
3
3
TEMPERATURE_MODULE_TYPE ,
4
4
} from '@opentrons/shared-data'
5
5
import { uuid } from '../../utils'
6
- import { TEMPERATURE_AT_TARGET , TEMPERATURE_DEACTIVATED } from '../../constants'
7
- import * as errorCreators from '../../errorCreators'
8
- import type { CommandCreator , WaitForTemperatureArgs } from '../../types'
6
+ import {
7
+ TEMPERATURE_APPROACHING_TARGET ,
8
+ TEMPERATURE_AT_TARGET ,
9
+ TEMPERATURE_DEACTIVATED ,
10
+ } from '../../constants'
9
11
import { getModuleState } from '../../robotStateSelectors'
12
+ import * as errorCreators from '../../errorCreators'
13
+ import * as warningCreators from '../../warningCreators'
14
+ import type {
15
+ CommandCreator ,
16
+ CommandCreatorWarning ,
17
+ WaitForTemperatureArgs ,
18
+ } from '../../types'
10
19
11
20
/** Set temperature target for specified module. */
12
21
export const waitForTemperature : CommandCreator < WaitForTemperatureArgs > = (
@@ -16,6 +25,7 @@ export const waitForTemperature: CommandCreator<WaitForTemperatureArgs> = (
16
25
) => {
17
26
const { module, temperature } = args
18
27
const moduleState = module ? getModuleState ( prevRobotState , module ) : null
28
+ const warnings : CommandCreatorWarning [ ] = [ ]
19
29
20
30
if ( module === null || ! moduleState ) {
21
31
return {
@@ -42,6 +52,10 @@ export const waitForTemperature: CommandCreator<WaitForTemperatureArgs> = (
42
52
'status' in moduleState &&
43
53
moduleState . status === TEMPERATURE_AT_TARGET &&
44
54
moduleState . targetTemperature !== temperature
55
+ const potentiallyUnreachableTemp =
56
+ 'status' in moduleState &&
57
+ moduleState . status === TEMPERATURE_APPROACHING_TARGET &&
58
+ moduleState . targetTemperature !== temperature
45
59
46
60
if (
47
61
unreachableTemp ||
@@ -52,6 +66,10 @@ export const waitForTemperature: CommandCreator<WaitForTemperatureArgs> = (
52
66
}
53
67
}
54
68
69
+ if ( potentiallyUnreachableTemp ) {
70
+ warnings . push ( warningCreators . potentiallyUnreachableTemp ( ) )
71
+ }
72
+
55
73
const moduleType = invariantContext . moduleEntities [ module ] ?. type
56
74
57
75
switch ( moduleType ) {
@@ -67,6 +85,7 @@ export const waitForTemperature: CommandCreator<WaitForTemperatureArgs> = (
67
85
} ,
68
86
} ,
69
87
] ,
88
+ warnings : warnings . length > 0 ? warnings : undefined ,
70
89
}
71
90
72
91
case HEATERSHAKER_MODULE_TYPE :
@@ -81,6 +100,7 @@ export const waitForTemperature: CommandCreator<WaitForTemperatureArgs> = (
81
100
} ,
82
101
} ,
83
102
] ,
103
+ warnings : warnings . length > 0 ? warnings : undefined ,
84
104
}
85
105
86
106
default :
0 commit comments