import { TEMPERATURE_MODULE_TYPE , THERMOCYCLER_MODULE_TYPE , } from '@opentrons/shared-data' ; import * as errorCreators from '../../errorCreators' ; import type { CommandCreator , SetTemperatureArgs } from '../../types' ; /** Set temperature target for specified module. */ export const setTemperature = ( args , invariantContext , prevRobotState ) => { const { module , targetTemperature } = args ; if ( module === null ) { return { errors : [ errorCreators . missingModuleError ( ) ] , } ; } const moduleType = invariantContext . moduleEntities [ module ] ?. type ; const params = { module , temperature : targetTemperature , } ; if ( moduleType === TEMPERATURE_MODULE_TYPE ) { return { commands : [ { command : 'temperatureModule/setTargetTemperature' , params , } , ] , } ; } else if ( moduleType === THERMOCYCLER_MODULE_TYPE ) { console . error ( 'Thermocycler set temp not implemented!' ) ; return { commands : [ ] , } ; } else { console . error ( `setTemperature expected module ${ module } to be ${ TEMPERATURE_MODULE_TYPE } or ${ THERMOCYCLER_MODULE_TYPE }, got ${ moduleType }` ) ; return { errors : [ errorCreators . missingModuleError ( ) ] , } ; } } ;