Thermochron Manager

The Themochron library adds data structures, data formatting and converting functions, and application specific functions to the library. This library documentation references terminology and data published in Dallas Semiconductor documentation of the Thermochron iButton. For clarity, it is assumed that the reader has access to this Dallas Semiconductor documentation.

Structure of a Mission

The MissionInfoType structure contains parameters necessary to setup and start a mission. typedef struct{ DateTimeType MRealTimeP; ULong MTimeAlarmP; SWord LowTempWP; SWord HighTempWP; SWord MStartDelay; SWord MSampleRate; ULong MSampleCount; ULong MDeviceCount; DateTimeType MStartTimeP; }MissionInfoType; typedef MissionInfoType * MissionInfoPtr;

The MissionStatusFlagType structure is convenient for holding the bit-level status of a mission read from a thermochron button.

typedef struct{ Boolean NoButtonFound; Boolean Running; Boolean Stopped; Boolean TemperatureAlarmLow; Boolean TemperatureAlarmHigh; Boolean TimeAlarm; }MissionStatusFlagType;

The MissionTimeAlarmFlagType structure is convenient for holding bit-level setup parameters for a mission.

typedef struct{ Boolean TimeAlarmSearch; Boolean TemperatureHighAlarmSearch; Boolean TemperatureLowAlarmSearch; Boolean Rollover; Boolean Enable; Boolean MinuteAlarm; Boolean HourAlarm; Boolean DayofWeekAlarm; Word Minute; Word Hour; Word DayofWeek; }MissionTimeAlarmFlagType; In addition, Thermochron manager supports optional text fields: CharPtr ButtonID; CharPtr MissionNumber; CharPtr MissionName; CharPtr Instructions;

Thermochron Functions

The following calls can be used to manipulate mission objects.

  • TcrGetAlarmData
  • TcrGetControlSelection
  • TcrGetDateTime
  • TcrGetHistogramData
  • TcrGetMissionDeviceCount
  • TcrGetMissionSampleCount
  • TcrGetStartTime
  • TcrGetTempData
  • TcrGetTempSetpoints
  • TcrGetTimeRateSettings
  • TcrMissionControlAlarmsToFlags
  • TcrMissionStatusToFlags
  • TcrMissionTimeAlarmFlagsToControl
  • TcrReadMissionStatus
  • TcrReadMissionInfo
  • TcrSetDateTime
  • TcrSetTempSetpoints
  • TcrSetTimeRateSettings
  • TcrStartMission
  • TcrStopMission
  • TcrGetAlarmData

    Purpose:
    Read the mission alarm data from the Thermochron button
    Prototype:
    Handle TcrGetAlarmData(void);
    Parameters:
    None
    Result:
    returns a handle to the mission alarm data (96bytes)
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results; i.e., data may be read from the button at the address of thermochron's temperature data and the function will return that data.

    The function allocates a handle of 96 bytes and initializes this memory to zero prior to attempting to read the button alarm data. If the attempt to read the button fails or if no alarm data has been recorded, the memory in the returned handle will remain zero. In this case, the reason that the handle is zero can not be uniquely determined. For example, the button may not be attached to the probe or a mission may not have been started. If all data is returned as zero, read mission parameters such as status, sample rate or start time to determine a cause.

    Usage:
    //allocation VoidHand buttonDataH; CharPtr buttonDataP; char * s; Handle buttonInfoH; CharPtr buttonInfoP; VoidHand alarmDataH; VoidPtr alarmDataP; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //read the alarm data alarmDataH= IcnGetTempData (): alarmDataP=MemHandleLock(alarmDataH); //do something with the data: test it, graph it, store it, etc. //release the memory MemHandleFree(alarmDataH); } else { buttonInfoH=MemHandleNew(25); buttonInfoP=MemHandleLock(buttonInfoH); StrCopy(buttonInfoP,"Wrong Button"); //handle or report the error //release the memory MemHandleFree(buttonInfoH); } MemHandleFree(buttonDataH);

    TcrGetControlSelection

    Purpose:
    Read the mission control and time alarm settings
    Prototype:
    ULong TcrGetControlSelection(void);
    Parameters:
    None
    Result:
    Returns an unsigned Long integer packed with the control register and three time alarm settings (Day-of-Week, hour, minute)
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results; i.e., data may be read from the button at the target address and the function will return that data. Data packing in the ULong variable is: Most significant byte = control register Byte 2 = Day of Week alarm Byte 3 = Hour alarm Least significant byte = Minute Alarm Second alarm is not returned.
    See also:
    TcrMissionControlAlarmsToFlags
    Usage:
    //allocation CharPtr buttonDataP; VoidHand buttonDataH; char *s; MissionTimeAlarmFlagType mtaFlag; ULong controlData; buttonDataH=IcnReadButtonID(): buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { controlData = TcrGetControlSelection(); // do something with the data TcrMissionControlAlarmsToFlags(&controlData,mtaFlag); if(mtaFlag.Rollover) { StrCopy(buttonDataP,"Rollover enabled"); //report rollover is enabled } } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrGetDateTime

    Purpose:
    Read the Thermochron button's real time clock
    Prototype:
    Err TcrGetDateTime(DateTimeType *dateP);
    Parameters:
    Pointer to DateTimeType structure filled in by the function
    Result:
    0 if successful IcnErrIncomplete did not receive enough data IcnErrTimeOut reader did not respond within timeout period
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results. Thermochron manager may deliver data stored at the target address. The function will interpret this data as date and time. If transaction is not completed as expected, the function will return zero's in the DateTimeType structure equivalent to 12:00 00/00/00 (not a valid date).
    Usage:
    //allocation Handle buttonDataH; CharPtr buttonDataP; char *s; Handle errorH; Err *errorP; VoidHand mdataH; DateTimeType * dateP; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if(!(StrNCompare(s,"21",2)) //family code = 21 { //call function to read button time errorH=MemHandleNew(sizeof(Err)); *errorP=MemHandleLock(errorH); mdateH=MemHandleNew(sizeof(DataTimeType)); mdateP=MemHandleLock(mdateH); *errorP = TcrGetDateTime(mdateP); if(*errorP = 0 ) { // do something with the data, display it, check it, store it, etc } else { //handle or report the error } MemHandleFree(mdateH); MemHandleFree(errorH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrGetHistogramData

    Purpose:
    Read the mission histogramdata from the Thermochron button
    Prototype:
    Handle TcrGetGetHistogramData(void);
    Parameters:
    None
    Result:
    Returns a handle filled in with the mission histogram data (128 bytes)
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results; i.e., data may be read from the button at the address of thermochron's temperature data and the function will return that data.

    The function allocates a handle of 128 bytes and initializes this memory to zero prior to attempting to read the button histogram data. If the attempt to read the button fails or if no histogram data has been recorded, the memory in the returned handle will remain zero. If this is the case, the reason that the handle is zero can not be uniquely determined. For example, the button may not be attached to the probe or a mission may not have been started. If all data is returned as zero, read mission parameters such as status, sample rate or start date to determine a cause.

    Usage:
    //allocation VoidHand buttonDataH; CharPtr buttonDataP; char *s; Handle buttonInfoH; CharPtr buttonInfoP; VoidHand histogramDataH; VoidPtr histogramDataP; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //read the histogram data histogramDataH= TcrGetHistogramData (): histogramDataP=MemHandleLock(histogramDataH); //do something with the data: test it, graph it, store it, etc. //release the memory MemHandleFree(histogramDataH); } else { buttonInfoH=MemHandleNew(25); buttonInfoP=MemHandleLock(buttonInfoH); StrCopy(buttonInfoP,"Wrong Button"); //handle or report the error //release the memory MemHandleFree(buttonInfoH); } MemHandleFree(buttonDataH);

    TcrGetMissionDeviceCount

    Purpose:
    Read the button's device count register
    Prototype:
    ULong TcrGetMissionDeviceCount(void);
    Parameters:
    None
    Result:
    Returns an unsigned Long integer with the device count data.
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results; i.e., data may be read from the button at the target address and the function will return that data.
    Usage:
    //allocation CharPtr buttonDataP; VoidHand buttonDataH; char *s; ULong deviceCount; buttonDataH=IcnReadButtonID(): buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { deviceCount = TcrGetMissionDeviceCount(); // do something with the data } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrGetMissionSampleCount

    Purpose:
    Read the mission sample count register
    Prototype:
    ULong TcrGetMissionSampleCount(void);
    Parameters:
    None
    Result:
    Returns an unsigned Long integer with the sample count data.
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results; i.e., data may be read from the button at the target address and the function will return that data.
    Usage:
    //allocation CharPtr buttonDataP; VoidHand buttonDataH; char *s; ULong sampleCount; buttonDataH=IcnReadButtonID(): buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { sampleCount = TcrGetMissionSampleCount(); // do something with the data } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrGetStartTime

    Purpose:
    Read the Thermochron button's time stamp with the mission start time
    Prototype:
    Err TcrGetStartTime(DateTimeType *dateP);
    Parameters:
    Pointer to DateTimeType structure filled in by the function
    Result:
    0 if successful icnErrIncomplete did not receive enough data icnErrTimeOut reader did not respond within timeout period
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results. Thermochron manager may deliver data stored at the target address which the function will attempt to interpret as date and time. If transaction is not completed as expected, the function will return zero's in the DateTimeType structure equivalent to 12:00 00/00/00 (not a valid date).
    Usage:
    //allocation Handle buttonDataH; CharPtr buttonDataP; char *s; Handle errorH; Err *errorP; VoidHand mdataH; DateTimeType * dateP; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if(!(StrNCompare(s,"21",2)) //family code = 21 { //call function to read button time errorH=MemHandleNew(sizeof(Err)); *errorP=MemHandleLock(errorH); mdateH=MemHandleNew(sizeof(DataTimeType)); mdateP=MemHandleLock(mdateH); *errorP = TcrGetStartTime(mdateP); if(*errorP = 0 ) { // do something with the data, display it, check it, store it, etc } else { //handle or report the error } MemHandleFree(mdateH); MemHandleFree(errorH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrGetTempData

    Purpose:
    Read the mission temperature from the Thermochron button
    Prototype:
    Handle TcrGetTempData(void);
    Parameters:
    None
    Result:
    Returns a handle to the mission temperature data (2048 bytes)
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results; i.e., data may be read from the button at the address of thermochron's temperature data and the function will return that data.

    The function allocates a handle of 2048 bytes and initializes this memory to zero prior to attempting to read the button temperature data. If the attempt to read the button fails or if no temperature data has been recorded, the memory in the returned handle will remain zero. If this is the case, the reason that the handle is zero can not be uniquely determined. For example, the button may not be attached to the probe or a mission may not have been started. If all data is returned as zero, read mission parameters such as status, sample rate or start time to determine a cause.

    Usage:
    //allocation Handle buttonDataH; CharPtr buttonDataP; char *s; VoidHand tempDataH; VoidPtr tempDataP; Handle buttonInfoH; CharPtr buttonInfoP; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //read the temperature data tempDataH= TcrGetTempData (): tempDataP=MemHandleLock(tempDataH); //do something with the data: test it, graph it, store it, etc. //Release the memory MemHandleFree(tempDataH); } else { buttonInfoH=MemHandleNew(25); buttonInfoP=MemHandleLock(buttonInfoH); StrCopy(buttonInfoP,"Wrong Button"); //handle or report the error //release the memory MemHandleFree(buttonInfoH); }

    TcrGetTempSetpoints

    Purpose:
    Read the Thermochron button's low and high temperature alarm limits
    Prototype:
    Boolean TcrGetTempSetpoints(SWord * lowTemp, SWord * highTemp);
    Parameters:
    Pointers to low and high temperature alarm limits to be filled in by the function.
    Result:
    true if successful, false if not successful
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results. Thermochron manager may read data at the target address and will assume the transaction is sucessful.

    The Thermochron button stores only one byte for each parameter. The function will return the binary byte (0-255) representation of the temperature alarm as stored in the button. The high order byte of the SWord variables will be set to zero.

    Data Representation: In the thermochron button, temperature data is represented by a single byte binary integer. It is dimensionless. Temperature is related to engineering units by the following equations:

    Degrees C = Binary/2 -40 Degrees F = 9 * Binary/10 - 40 Binary = 2 * Degrees C + 80 Binary = 10 * ( Degrees F + 40 )/9 This function does not convert button data from binary to engineering units, but loads the specified pointers with the button data as received. It is the programmer's responsibility to convert button data to the desired engineering units.
    Usage:
    //allocation Handle buttonDataH; CharPtr buttonDataP; char *s; Handle lowTempH; SWord *lowTemp; Handle highTempH; SWord *highTemp; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if(!(StrNCompare(s,"21",2)) //family code = 21 { //allocate memory for the alarm limit variables highTempH=MemHandleNew(sizeof(SWord)); *highTemp=MemHandleLock(highTempH); lowTempH=MemHandleNew(sizeof(SWord)); *lowTemp=MemHandleLock(lowTempH); //read data from the button if(TcrGetTempSetpoints(*lowTemp,*highTemp)) { // do something on success, display, store, compare, etc. } else { //handle or report the error } MemHandleFree(highTempH); MemHandleFree(lowTempH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrGetTimeRateSettings

    Purpose:
    Read the Thermochron button's mission start delay and sample rate parameters
    Prototype:
    Boolean TcrGetTimeRateSettings(SWord * timeSettings, SWord * rateSettings);
    Parameters:
    Pointers to mission start delay and sample rate parameters.
    Result:
    true if successful, false if not successful
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results. Thermochron manager may read data at the target address and will assume the transaction is sucessful.

    The two-byte start delay variable allows a range of 0-65,395 minutes. Only the least significant byte of the sample rate variable will be read, allowing a variable range of 1-255.

    Note that if the mission is started with a non-zero start delay parameter, sampling will not begin until the delay in minutes has expired. The start delay variable will "count-down" to start. Reading the start delay variable with this function in real time will report the time remaining until mission start. Once the mission has started, the start delay variable will be zero.

    Usage:
    //allocation Handle buttonDataH; CharPtr buttonDataP; char *s; Handle sampleRateH; SWord *sampleRate; Handle startDelayH; SWord *startDelay; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if(!(StrNCompare(s,"21",2)) //family code = 21 { //allocate memory for the time and rate variables startDelayH=MemHandleNew(sizeof(SWord)); *startDelay=MemHandleLock(startDelayH); sampleRateH=MemHandleNew(sizeof(SWord)); *sampleRate=MemHandleLock(sampleRateH); //read from the button if(TcrGetTimeRateSettings (*startDelay,*sampleRate)) { // do something on success, display, report, etc } else { //handle or report the error } MemHandleFree(startDelayH); MemHandleFree(sampleRateH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrMissionControlAlarmsToFlags

    Purpose:
    Set/clear the MissionTimeAlarmFlagType flags based on the control and time alarm bytes passed.
    Prototype:
    Boolean TcrMissionControlAlarmsToFlags(ULong * realTimeAlarm, MissionTimeAlarmFlagType mTimeAlarmFlag);
    Parameters:
    realTimeAlarm - pointer to control and time alarm data returned by TcrGetControlSelection. mTimeAlarmFlag - structure holding control and time alarm flags. See documentation or header file for flag details.
    Result:
    Returns true if successful, false otherwise. Return value may be used to specify that flags are valid.
    Comment:
    This function does not read the button but operates on the pointer passed.
    See Also:
    TcrMissionStatusToFlags, TcrMissionTimeAlarmFlagsToControl
    Usage:
    //allocation CharPtr buttonDataP; VoidHand buttonDataH; char *s; MissionTimeAlarmFlagType mTimeAlarmFlag; VoidHand realTimeAlarmH; ULong * realTimeAlarm; buttonDataH=IcnReadButtonID(): buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //get time and call function to set button time realTimeAlarmH=MemHandleNew(sizeof(ULong)); *realTimeAlarm=MemHandleLock(realTimeAlarmH); *realTimeAlarm = TcrGetControlSelection(); if(TcrMissionControlAlarmsToFlags (*realTimeAlarm, mTimeAlarmFlag)) //flags are valid, use to display, store, etc. mission control and time alarms } else { //handle or report an error } MemHandleFree(realTimeAlarmH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrMissionStatusToFlags

    Purpose:
    Set/clear the MissionStatusFlagType flags based on the status byte passed.
    Prototype:
    Boolean TcrMissionStatusToFlags(CharPtr statusP, MissionStatusFlagType mstatusFlag);
    Parameters:
    statusP - pointer to status byte returned by TcrReadMissionStatus(); MstatusFlag - structure holding status flags. See documentation or header file for flag details.
    Result:
    Returns true if successful, false otherwise. Return value may be used to specify that flags are valid.
    Comment:
    This function does not read the button but operates on the pointer passed.
    See Also:
    TcrMissionControlAlarmsToFlags, TcrMissionTimeAlarmFlagsToControl
    Usage:
    //allocation CharPtr buttonDataP; VoidHand buttonDataH; char *s; MissionStatusFlagType mstatusFlag); VoidHand buttonStatusH; VoidPtr buttonStatusP; buttonDataH=IcnReadButtonID(): buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //get time and call function to set button time buttonStatusH=TcrReadButtonStatus(); buttonStatusP=MemHandleLock(buttonStatusH); if(StrCompare(buttonStatusP,"N")!=0) { if(TcrMissionStatusToFlags(buttonstatusP, mstatusFlag)) //flags are valid, use to display, store, etc. mission status } else { //handle or report an error } } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH); MemHandleFree(buttonStatusH);

    TcrMissionTimeAlarmFlagsToControl

    Purpose:
    Performs bit manipulation to construct the control byte from the alarm flag structure in preparation for starting a mission.
    Prototype:
    Boolean TcrMissionTimeAlarmFlagsToControl(MissionTimeAlarmFlagType mTimeAlarmFlag, ULong *RealTimeAlarms);
    Parameters:
    mTimeAlarmFlag - structure holding control and time alarm flags. *realTimeAlarm - pointer to receive control and time alarm data constructed by the function. See documentation or header file for flag details.
    Result:
    Returns true if successful, false otherwise.
    Comment:
    This function does not read/write the button but operates on the pointer passed.
    See Also:
    TcrMissionStatusToFlags, TcrMissionControlAlarmsToFlags
    Usage:
    //allocation CharPtr buttonDataP; VoidHand buttonDataH; char *s; MissionTimeAlarmFlagType mTimeAlarmFlag; VoidHand realTimeAlarmH; ULong * realTimeAlarm; buttonDataH=IcnReadButtonID(): buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //allocate memory and read the button to fill it in. realTimeAlarmH=MemHandleNew(sizeof(ULong)); *realTimeAlarm=MemHandleLock(realTimeAlarmH); *realTimeAlarm = TcrGetControlSelection(); //set/clear flags TcrMissionControlAlarmsToFlags (*realTimeAlarm, mTimeAlarmFlag); //display, adjust, update etc. //construct alarms in button format from flags TcrMissionTimeAlarmFlagsToControl(mTimeAlarmFlag, *realTimeAlarm);o //store, display, write to button, etc. MemHandleFree(realTimeAlarmH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrReadMissionStatus

    Purpose:
    Read the mission status byte in the Thermochron button
    Prototype:
    Handle TcrReadMissionStatus(void);
    Parameters:
    None
    Result:
    Returns a handle to the mission status byte
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results; i.e., data may be read from the button at the address of thermochron's status byte and the function will return that byte. If transaction is not completed as expected the function will return the ascii character "N" (this character is not a valid status byte and may be decoded as "No button found".)
    See Also:
    TcrMissionStatusToFlags
    Usage:
    //allocation CharPtr buttonDataP; VoidHand buttonDataH; char *s; VoidHand buttonStatusH; VoidPtr buttonStatusP; buttonDataH=IcnReadButtonID(): buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //get time and call function to set button time buttonStatusH=TcrReadButtonStatus(); buttonStatusP=MemHandleLock(buttonStatusH); if(StrCompare(buttonStatusP,"N")!=0) { // report status or take action based on status. } else { //handle or report an error } } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH); MemHandleFree(buttonStatusH);

    TcrReadMissionInfo

    Purpose:
    Read the mission parameters in the Thermochron button
    Prototype:
    Err TcrReadMissionInfo(MissionInfoPtr missionInfoP);
    Parameters:
    MissionInfoPtr structure to be filled in by the function. (See the specification and description of the MissionInfoType Structure and MissionInfoPtr in this document or in the tchron.h header file)
    Result:
    Returns errorcode 0 if successful icnErrIncomplete did not receive enough data icnErrTimeOut reader did not respond within timeout period
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results; i.e., data may be read from the button at the address of thermochron's mission register pages and the function will return that data.
    Usage:
    //allocation CharPtr buttonDataP; VoidHand buttonDataH; VoidHand buttonIDH; VoidPtr buttonIDP; char *s; VoidHand errorH; Err * errorP; buttonDataH=IcnReadButtonID(): buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //it is a thermochron button //allocate memory for missionInfo if necessary missionInfoH=MemHandleNew(sizeof(MissionInfoType)); missionInfoP=MemHandleLock(missionInfoH); errorH=MemHandleNew(sizeof(Err)); *errorP = MemHandleLock(errorH); *errorP = TcrReadMissionInfo(missionInfoP); if(*errorP == 0) { // report or take action based on mission parameters. } else { //handle or report an error } MemHandleFree(missionInfoH); MemHandleFree(errorH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonIDH); MemHandleFree(buttonDataH);

    TcrSetDateTime

    Purpose:
    Set the Thermochron button's real time clock
    Prototype:
    Boolean TcrSetDateTime(DateTimeType *dateP);
    Parameters:
    Pointer to DateTimeType structure filled with time to set
    Result:
    true if time set correctly (reader generates positive response) false otherwise
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to set another type button will return unpredictable results; i.e., data may be written to a button of alternate type at the address of Thermochron's realtime clock and the function will return an indication of success. If transaction is not completed as expected, the function will return false.
    Usage:
    //allocation Handle buttondataH; CharPtr buttonDataP; char *s; VoidHand mdateH; DateTimeType * mdateP; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //get time and call function to set button time mdateH=MemHandleNew(sizeof(DateTimeType)); mdateP=MemHandleLock(mdateH); //get the current time from Palm clock or other source and load mdateP structure if(IcnSetCurrentButtonTime(*mdateP)) { // indicate time set, read it back, display etc. } else { //handle or report and error } MemHandleFree(mdateH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrSetTempSetpoints

    Purpose:
    Set the Thermochron button's low and high temperature alarm limits
    Prototype:
    Boolean TcrSetTempSetpoints(SWord * lowTemp, SWord * highTemp);
    Parameters:
    Pointers to low and high temperature alarm limits.
    Result:
    true if successful, false if not successful
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results. Thermochron manager may write data at the target address and will assume the transaction is sucessful. Only the least significant byte of each parameter will be written. Any data in the high order bytes of the Sword variables will be ignored.

    Data Representation:
    In the thermochron button, temperature data is represented by a single byte binary integer. It is dimensionless. Temperature is related to engineering units by the following equations: Degrees C = Binary/2 - 40 Degrees F = 9 * Binary/10 - 40 Binary = 2 * Degrees C + 80 Binary = 10 * ( Degrees F + 40 )/9 This function does not convert data from engineering units to binary, but writes the contents of the passed pointers to the button as received. It is programmer's responsibility to convert the user's desired engineering units to button data.

    Usage:
    //allocation Handle buttonDataH; CharPtr buttonDataP; char *s; Handle lowTempH; SWord *lowTemp; Handle highTempH; SWord *highTemp; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if(!(StrNCompare(s,"21",2)) //family code = 21 { //allocate memory for the alarm limit variables highTempH=MemHandleNew(sizeof(SWord)); *highTemp=MemHandleLock(highTempH); lowTempH=MemHandleNew(sizeof(SWord)); *lowTemp=MemHandleLock(lowTempH); //assign values to the limits, notice units unspecified *lowTemp = 12; *highTemp = 25; //write to the button if(TcrSetTempSetpoints(*lowTemp,*highTemp)) { // do something on success } else { //handle or report the error } MemHandleFree(highTempH); MemHandleFree(lowTempH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrSetTimeRateSettings

    Purpose:
    Set the Thermochron button's mission start delay and sample rate parameters
    Prototype:
    Boolean TcrSetTimeRateSettings(SWord * timeSettings, SWord * rateSettings);
    Parameters:
    Pointers to mission start delay and sample rate parameters.
    Result:
    true if successful, false if not successful
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to read another type button will return unpredictable results. Thermochron manager may write data at the target address and will assume the transaction is sucessful.

    The two-byte start delay variable allows a range of 0-65,395 minutes. Only the least significant byte of the sample rate variable will be written, allowing a variable range of 1-255. (If the sample rate variable is zero, the Thermochron manager will write this value, but it will not be a legitimate value for the button. Any data in the high order bytes of the Sample rate variable will be ignored.

    Usage:
    //allocation Handle buttonDataH; CharPtr buttonDataP; char *s; Handle sampleRateH; SWord *sampleRate; Handle startDelayH; SWord *startDelay; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if(!(StrNCompare(s,"21",2)) //family code = 21 { //allocate memory for the time and rate variables startDelayH=MemHandleNew(sizeof(SWord)); *startDelay=MemHandleLock(startDelayH); sampleRateH=MemHandleNew(sizeof(SWord)); *sampleRate=MemHandleLock(sampleRateH); //assign values to the parameters *startDelay = 60; *sampleRate = 2; //write to the button if(TcrSetTimeRateSettings (*startDelay,*sampleRate)) { // do something on success } else { //handle or report the error } MemHandleFree(startDelayH); MemHandleFree(sampleRateH); } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);

    TcrStartMission

    Purpose:
    Start a mission with data in the MissionInfoPtr structure.
    Prototype:
    Boolean IcnStartMission(MissionInfoPtr missionInfoP);
    Parameters:
    MissionInfoPtr filled in with parameters specifying the mission. (See the specification and description of the MissionInfoPtr in this document or in the tchron.h header file)
    Result:
    Returns true if the mission parameters are written successfully, false otherwise.
    Comment:
    Calling program is responsible for determining if attached button is a thermochron button. Calling this function in an attempt to start a mission with another type button will return unpredictable results; i.e., data may be written to the unknown button at addresses of thermochron's mission parameters.

    While the name of this function implies that the mission will be started, that may not necessarily be the case. By design, a mission starts only after a defined start delay, and in the case where start delay is specified as zero, only on a minute-transition of the thermochron's real-time clock. To insure that the mission is indeed started, read the mission status byte or mission info after the specified start delay +1 minute.

    Usage:
    //allocation CharPtr missionInfoP; VoidHand missionInfoH; VoidHand buttonStatusH; VoidPtr buttonStatusP; Handle buttonDataH: CharPtr buttonDataP; MissionStatusFlagType mFlags; Handle buttonIDH; CharPtr buttonIDP; char *s; buttonIDH=IcnReadButtonID(): buttonIDP=MemHandleLock(buttonIDH); s=buttonIDP+12; if((StrNCompare(s,"21",2)) //family code = 21 { //yes it is a thermochron button, check if there is a mission already running //allocate some memory for result reporting buttonDataH=MemHandleNew(25); buttonDataP=MemHandleLock(buttonDataH); MemSet(buttonDataP,25,0); buttonStatusH=IcnReadMisionStatus(); buttonStatusP=MemHandleLock(buttonStatusH); TcrMissionStatusToFlags(buttonStatusP,mFlags); if(mFlags.Stopped) { //no mission running, ok to start a new one //fill in missionInfoP structufre with mission parameters if(TcrStartMission(missionInfoP)) { StrCopy(buttonDataP,"Start OK"); // report the successful operation } else { StrCopy(buttonDataP,"Could not Start"); // report or handle the error } } else { StrCopy(buttonDataP,"Mission already running"); //report status or take other action } //release the memory MemHandleFree(buttonDataH); MemHandleFree(buttonStatusH); MemHandleFree(missionInfoH); MemHandleFree(buttonDataP);

    TcrStopMission

    Purpose:
    Stop the Thermochron button's mission in progress.
    Prototype:
    Boolean TcrStopMission(void);
    Parameters:
    None.
    Result:
    true if the function call ends with the mission stopped, false otherwise.

    Comment:
    The function attempts to stop the mission by clearing the mission in process bit in the Thermochron mission status byte. This leaves the mission data intact so that it may be read by other functions.

    Calling program is responsible for determining if attached button is a thermochron button. Calling this function to write to another button type will return unpredictable results.

    The return value indicates the state of the mission, not necessarily the success or failure of the function. For example, if the mission is stopped and the function is called, the function will return true without taking further action. If the button cannot be read, the function will return false even though the state of the mission is unknown.

    Usage:
    //allocation Handle buttonDataH; CharPtr buttonDataP; char *s; buttonDataH=IcnReadButtonID(); buttonDataP=MemHandleLock(buttonDataH); s=buttonDataP+12; if(!(StrNCompare(s,"21",2)) //family code = 21 { //call the function if(StopMission()) { // do something on success, display, report, store, etc } else { //handle or report the error } } else { StrCopy(buttonDataP,"Wrong Button"); //handle or report the error } //release the memory MemHandleFree(buttonDataH);