static void releaseCfgRecords(void); static Boolean ConfigEventHandler(EventPtr event); static Boolean ConfigEventHandler(EventPtr event) { FormPtr frm; Err error; double v; switch (event->eType) { case frmOpenEvent: WinEraseWindow(); frm = FrmGetActiveForm(); fieldptr_cfgAltHalfstepsize = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAltHalfstepsize)); FldSetTextHandle (fieldptr_cfgAltHalfstepsize, (Handle) DmGetRecord(eldobDB, 0)); fieldptr_cfgAltHorizontlimit = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAltHorizontlimit)); FldSetTextHandle (fieldptr_cfgAltHorizontlimit, (Handle) DmGetRecord(eldobDB, 1)); fieldptr_cfgAltZenitlimit = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAltZenitlimit)); FldSetTextHandle (fieldptr_cfgAltZenitlimit, (Handle) DmGetRecord(eldobDB, 2)); fieldptr_cfgAltCorrectionspeed = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAltCorrectionspeed)); FldSetTextHandle (fieldptr_cfgAltCorrectionspeed, (Handle) DmGetRecord(eldobDB, 3)); fieldptr_cfgAltGotospeed = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAltGotospeed)); FldSetTextHandle (fieldptr_cfgAltGotospeed, (Handle) DmGetRecord(eldobDB, 4)); fieldptr_cfgAltFollowspeed = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAltFollowspeed)); FldSetTextHandle (fieldptr_cfgAltFollowspeed, (Handle) DmGetRecord(eldobDB, 5)); fieldptr_cfgAltEncodersize = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAltEncodersize)); FldSetTextHandle (fieldptr_cfgAltEncodersize, (Handle) DmGetRecord(eldobDB, 6)); fieldptr_cfgAzHalfstepsize = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAzHalfstepsize)); FldSetTextHandle (fieldptr_cfgAzHalfstepsize, (Handle) DmGetRecord(eldobDB, 7)); fieldptr_cfgAzCorrectionspeed = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAzCorrectionspeed)); FldSetTextHandle (fieldptr_cfgAzCorrectionspeed, (Handle) DmGetRecord(eldobDB, 8)); fieldptr_cfgAzGotospeed = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAzGotospeed)); FldSetTextHandle (fieldptr_cfgAzGotospeed, (Handle) DmGetRecord(eldobDB, 9)); fieldptr_cfgAzFollowspeed = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAzFollowspeed)); FldSetTextHandle (fieldptr_cfgAzFollowspeed, (Handle) DmGetRecord(eldobDB, 10)); fieldptr_cfgAzEncodersize = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgAzEncodersize)); FldSetTextHandle (fieldptr_cfgAzEncodersize, (Handle) DmGetRecord(eldobDB, 11)); fieldptr_cfgLatitude = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgLatitude)); FldSetTextHandle (fieldptr_cfgLatitude, (Handle) DmGetRecord(eldobDB, 12)); fieldptr_cfgLongitude = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgLongitude)); FldSetTextHandle (fieldptr_cfgLongitude, (Handle) DmGetRecord(eldobDB, 13)); fieldptr_cfgUtcAdjust = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgUtcAdjust)); FldSetTextHandle (fieldptr_cfgUtcAdjust, (Handle) DmGetRecord(eldobDB, 14)); fieldptr_cfgTcct = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgTcct)); FldSetTextHandle (fieldptr_cfgTcct, (Handle) DmGetRecord(eldobDB, 15)); fieldptr_cfgTgct = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgTgct)); FldSetTextHandle (fieldptr_cfgTgct, (Handle) DmGetRecord(eldobDB, 16)); fieldptr_cfgTfct = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgTfct)); FldSetTextHandle (fieldptr_cfgTfct, (Handle) DmGetRecord(eldobDB, 17)); fieldptr_cfgFrHalfstepsize = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgFrHalfstepsize)); FldSetTextHandle (fieldptr_cfgFrHalfstepsize, (Handle) DmGetRecord(eldobDB, 18)); fieldptr_cfgFrCorrectionspeed = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgFrCorrectionspeed)); FldSetTextHandle (fieldptr_cfgFrCorrectionspeed, (Handle) DmGetRecord(eldobDB, 19)); fieldptr_cfgFrGotospeed = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgFrGotospeed)); FldSetTextHandle (fieldptr_cfgFrGotospeed, (Handle) DmGetRecord(eldobDB, 20)); fieldptr_cfgFrFollowspeed = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID_cfgFrFollowspeed)); FldSetTextHandle (fieldptr_cfgFrFollowspeed, (Handle) DmGetRecord(eldobDB, 21)); FrmDrawForm (frm); break; case ctlSelectEvent: if (event->data.ctlEnter.controlID== buttonID_ConfigDone) { // set all values to use as actual values if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAltHalfstepsize),&scope.alt_halfstepsize) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAltHorizontlimit),&scope.alt_horizontlimit) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAltZenitlimit),&scope.alt_zenitlimit) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAltCorrectionspeed),&scope.alt_correctionspeed) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAltGotospeed),&scope.alt_gotospeed) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAltFollowspeed),&scope.alt_followspeed) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAltEncodersize),&scope.alt_encodersize) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAzHalfstepsize),&scope.az_halfstepsize) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAzCorrectionspeed),&scope.az_correctionspeed) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAzGotospeed),&scope.az_gotospeed) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAzFollowspeed),&scope.az_followspeed) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgAzEncodersize),&scope.az_encodersize) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgLatitude),&scope.latitude) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgLongitude),&scope.longitude) == false){ FrmAlert(alertID_variableerror); } scope.utcadjust = StrAToI((const Char *)FldGetTextPtr(fieldptr_cfgUtcAdjust) ); if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgTcct),&scope.timerintct_correction) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgTgct),&scope.timerintct_goto) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgTfct),&scope.timerintct_follow) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgFrHalfstepsize),&scope.fr_halfstepsize) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgFrCorrectionspeed),&scope.fr_correctionspeed) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgFrGotospeed),&scope.fr_gotospeed) == false){ FrmAlert(alertID_variableerror); } if(strToDouble((const char *)FldGetTextPtr(fieldptr_cfgFrFollowspeed),&scope.fr_followspeed) == false){ FrmAlert(alertID_variableerror); } scope.hs_az360 = 1296000; scope.hs_az270 = 972000; scope.hs_az180 = 648000; scope.hs_az90 = 324000; if(scope.az_halfstepsize > 0){ scope.hs_az360 = 1296000.0 / scope.az_halfstepsize; scope.hs_az270 = 972000.0 / scope.az_halfstepsize; scope.hs_az180 = 648000.0 / scope.az_halfstepsize; scope.hs_az90 = 324000.0 / scope.az_halfstepsize; } scope.hs_alt180 = 648000; scope.hs_alt90 = 324000; scope.hs_altlb = 0; scope.hs_altub = 324000; if(scope.alt_halfstepsize > 0){ scope.hs_alt180 = 648000.0 / scope.alt_halfstepsize; scope.hs_alt90 = 324000.0 / scope.alt_halfstepsize; if(scope.alt_horizontlimit > 0 ){ v = scope.alt_horizontlimit * 3600; scope.hs_altlb = v / scope.alt_halfstepsize; } if(scope.alt_zenitlimit > 0 ){ v = scope.alt_zenitlimit * 3600; scope.hs_altub = v / scope.alt_halfstepsize; } } scope.hs_fr360 = 1296000; scope.hs_fr270 = 972000; scope.hs_fr180 = 648000; scope.hs_fr90 = 324000; if(scope.fr_halfstepsize > 0){ scope.hs_fr360 = 1296000.0 / scope.fr_halfstepsize; scope.hs_fr270 = 972000.0 / scope.fr_halfstepsize; scope.hs_fr180 = 648000.0 / scope.fr_halfstepsize; scope.hs_fr90 = 324000.0 / scope.fr_halfstepsize; } scope.northpole = 0; scope.southpole = 648000.; if(scope.latitude != 0){ scope.northpole = scope.latitude * 3600.; scope.southpole = scope.northpole + 648000.; } scope.hs_northpole = 0; scope.hs_southpole = 648000; scope.hs_latitude = 0; if(scope.latitude != 0 ){ scope.hs_latitude = scope.latitude * 3600.; if(scope.alt_halfstepsize > 0 ){ scope.hs_latitude = scope.hs_latitude / scope.alt_halfstepsize; scope.hs_northpole = scope.hs_latitude; scope.hs_southpole = 648000. / scope.alt_halfstepsize + scope.hs_northpole; } } FldSetTextHandle(fieldptr_cfgAltHalfstepsize, NULL); FldSetTextHandle(fieldptr_cfgAltHorizontlimit, NULL); FldSetTextHandle(fieldptr_cfgAltZenitlimit, NULL); FldSetTextHandle(fieldptr_cfgAltCorrectionspeed, NULL); FldSetTextHandle(fieldptr_cfgAltGotospeed, NULL); FldSetTextHandle(fieldptr_cfgAltFollowspeed, NULL); FldSetTextHandle(fieldptr_cfgAltEncodersize, NULL); FldSetTextHandle(fieldptr_cfgAzHalfstepsize, NULL); FldSetTextHandle(fieldptr_cfgAzCorrectionspeed, NULL); FldSetTextHandle(fieldptr_cfgAzGotospeed, NULL); FldSetTextHandle(fieldptr_cfgAzFollowspeed, NULL); FldSetTextHandle(fieldptr_cfgAzEncodersize, NULL); FldSetTextHandle(fieldptr_cfgLatitude, NULL); FldSetTextHandle(fieldptr_cfgLongitude, NULL); FldSetTextHandle(fieldptr_cfgUtcAdjust, NULL); FldSetTextHandle(fieldptr_cfgTcct, NULL); FldSetTextHandle(fieldptr_cfgTgct, NULL); FldSetTextHandle(fieldptr_cfgTfct, NULL); FldSetTextHandle(fieldptr_cfgFrHalfstepsize, NULL); FldSetTextHandle(fieldptr_cfgFrCorrectionspeed, NULL); FldSetTextHandle(fieldptr_cfgFrGotospeed, NULL); FldSetTextHandle(fieldptr_cfgFrFollowspeed, NULL); releaseCfgRecords(); FrmGotoForm(formID_MainMenu); } break; default: return false; } return true; } static void releaseCfgRecords(void) { DmReleaseRecord(eldobDB,0,true); DmReleaseRecord(eldobDB,1,true); DmReleaseRecord(eldobDB,2,true); DmReleaseRecord(eldobDB,3,true); DmReleaseRecord(eldobDB,4,true); DmReleaseRecord(eldobDB,5,true); DmReleaseRecord(eldobDB,6,true); DmReleaseRecord(eldobDB,7,true); DmReleaseRecord(eldobDB,8,true); DmReleaseRecord(eldobDB,9,true); DmReleaseRecord(eldobDB,10,true); DmReleaseRecord(eldobDB,11,true); DmReleaseRecord(eldobDB,12,true); DmReleaseRecord(eldobDB,13,true); DmReleaseRecord(eldobDB,14,true); DmReleaseRecord(eldobDB,15,true); DmReleaseRecord(eldobDB,16,true); DmReleaseRecord(eldobDB,17,true); DmReleaseRecord(eldobDB,18,true); DmReleaseRecord(eldobDB,19,true); DmReleaseRecord(eldobDB,20,true); DmReleaseRecord(eldobDB,21,true); }