internal static void CalcEncoderGotoTargets(double tRa, double tDec, ref double RaEnc, ref double DecEnc) { eqmodvector.Coordt tmpcoord = new eqmodvector.Coordt(); double tPier = 0; double tha = EQMath.RangeHA(tRa - EQMath.EQnow_lst(EQMath.gLongitude * EQMath.DEG_RAD)); if (tha < 0) { if (EQMath.gHemisphere == 0) { tPier = 1; } else { tPier = 0; } tRa = EQMath.Range24(tRa - 12); } else { if (EQMath.gHemisphere == 0) { tPier = 0; } else { tPier = 1; } } //Compute for Target RA/DEC Encoder RaEnc = EQMath.Get_RAEncoderfromRA(tRa, 0, EQMath.gLongitude, EQMath.gRAEncoder_Zero_pos, EQMath.gTot_RA, EQMath.gHemisphere); DecEnc = EQMath.Get_DECEncoderfromDEC(tDec, tPier, EQMath.gDECEncoder_Zero_pos, EQMath.gTot_DEC, EQMath.gHemisphere); if (Alignment.gThreeStarEnable) { // Transform target using model switch (Common.gAlignmentMode) { case 2: // n-star+nearest tmpcoord = EQMath.DeltaSyncReverse_Matrix_Map(RaEnc - EQMath.gRASync01, DecEnc - EQMath.gDECSync01); break; case 1: // n-star tmpcoord = EQMath.Delta_Matrix_Map(RaEnc - EQMath.gRASync01, DecEnc - EQMath.gDECSync01); break; default: // nearest tmpcoord = EQMath.Delta_Matrix_Map(RaEnc - EQMath.gRASync01, DecEnc - EQMath.gDECSync01); if (tmpcoord.f == 0) { tmpcoord = EQMath.DeltaSyncReverse_Matrix_Map(RaEnc - EQMath.gRASync01, DecEnc - EQMath.gDECSync01); } break; } RaEnc = tmpcoord.x; DecEnc = tmpcoord.Y; } }
internal static void CalcEncoderTargets() { object HC = null; double targetRAEncoder = 0; double targetDECEncoder = 0; double currentRAEncoder = 0; double currentDECEncoder = 0; eqmodvector.Coordt tmpcoord = new eqmodvector.Coordt(); double tRa = 0; double tha = 0; double tPier = 0; try { EQMath.gSlewStatus = false; //stop the motors PEC.PEC_StopTracking(); EQMath.eqres = UpgradeSolution1Support.PInvoke.SafeNative.eqcontrl.EQ_MotorStop(2); // eqres = EQ_MotorStop(0) // eqres = EQ_MotorStop(1) // 'Wait for motor stop , Need to add timeout routines here // Do // eqres = EQ_GetMotorStatus(0) // If (eqres = EQ_NOTINITIALIZED) Or (eqres = EQ_COMNOTOPEN) Or (eqres = EQ_COMTIMEOUT) Then GoTo SL01 // Loop While (eqres And EQ_MOTORBUSY) <> 0 // //SL01: // Do // eqres = EQ_GetMotorStatus(1) // If (eqres = EQ_NOTINITIALIZED) Or (eqres = EQ_COMNOTOPEN) Or (eqres = EQ_COMTIMEOUT) Then GoTo SL02 // Loop While (eqres And EQ_MOTORBUSY) <> 0 // //SL02: // read current currentRAEncoder = Common.EQGetMotorValues(0); currentDECEncoder = Common.EQGetMotorValues(1); tha = EQMath.RangeHA(gTargetRA - EQMath.EQnow_lst(EQMath.gLongitude * EQMath.DEG_RAD)); if (tha < 0) { if (gCWUP) { if (EQMath.gHemisphere == 0) { tPier = 0; } else { tPier = 1; } tRa = gTargetRA; } else { if (EQMath.gHemisphere == 0) { tPier = 1; } else { tPier = 0; } tRa = EQMath.Range24(gTargetRA - 12); } } else { if (gCWUP) { if (EQMath.gHemisphere == 0) { tPier = 1; } else { tPier = 0; } tRa = EQMath.Range24(gTargetRA - 12); } else { if (EQMath.gHemisphere == 0) { tPier = 0; } else { tPier = 1; } tRa = gTargetRA; } } //Compute for Target RA/DEC Encoder targetRAEncoder = EQMath.Get_RAEncoderfromRA(tRa, 0, EQMath.gLongitude, EQMath.gRAEncoder_Zero_pos, EQMath.gTot_RA, EQMath.gHemisphere); targetDECEncoder = EQMath.Get_DECEncoderfromDEC(gTargetDec, tPier, EQMath.gDECEncoder_Zero_pos, EQMath.gTot_DEC, EQMath.gHemisphere); if (gCWUP) { //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message("Goto: CW-UP slew requested"); // if RA limits are active //UPGRADE_TODO: (1067) Member ChkEnableLimits is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 if (Convert.ToDouble(HC.ChkEnableLimits.value) == 1 && EQMath.gRA_Limit_East != 0 && EQMath.gRA_Limit_West != 0) { // check that the target position is within limits if (EQMath.gHemisphere == 0) { if (targetRAEncoder < EQMath.gRA_Limit_East || targetRAEncoder > EQMath.gRA_Limit_West) { // target position is outside limits gCWUP = false; } } else { if (targetRAEncoder > EQMath.gRA_Limit_East || targetRAEncoder < EQMath.gRA_Limit_West) { // target position is outside limits gCWUP = false; } } // if target position is outside limits if (!gCWUP) { //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message("Goto: RA Limits prevent CW-UP slew"); //then abandon Counter Weights up Slew and recalculate for a standard slew. if (tha < 0) { if (EQMath.gHemisphere == 0) { tPier = 1; } else { tPier = 0; } tRa = EQMath.Range24(gTargetRA - 12); } else { if (EQMath.gHemisphere == 0) { tPier = 0; } else { tPier = 1; } tRa = gTargetRA; } targetRAEncoder = EQMath.Get_RAEncoderfromRA(tRa, 0, EQMath.gLongitude, EQMath.gRAEncoder_Zero_pos, EQMath.gTot_RA, EQMath.gHemisphere); targetDECEncoder = EQMath.Get_DECEncoderfromDEC(gTargetDec, tPier, EQMath.gDECEncoder_Zero_pos, EQMath.gTot_DEC, EQMath.gHemisphere); } } } if (!Alignment.gThreeStarEnable) { Alignment.gSelectStar = 0; currentRAEncoder = EQMath.Delta_RA_Map(currentRAEncoder); currentDECEncoder = EQMath.Delta_DEC_Map(currentDECEncoder); } else { // Transform target using model switch (Common.gAlignmentMode) { case 2: // n-star+nearest tmpcoord = EQMath.DeltaSyncReverse_Matrix_Map(targetRAEncoder - EQMath.gRASync01, targetDECEncoder - EQMath.gDECSync01); break; case 1: // n-star tmpcoord = EQMath.Delta_Matrix_Map(targetRAEncoder - EQMath.gRASync01, targetDECEncoder - EQMath.gDECSync01); break; default: // nearest tmpcoord = EQMath.Delta_Matrix_Map(targetRAEncoder - EQMath.gRASync01, targetDECEncoder - EQMath.gDECSync01); if (tmpcoord.f == 0) { tmpcoord = EQMath.DeltaSyncReverse_Matrix_Map(targetRAEncoder - EQMath.gRASync01, targetDECEncoder - EQMath.gDECSync01); } break; } targetRAEncoder = tmpcoord.x; targetDECEncoder = tmpcoord.Y; } //Execute the actual slew gGotoParams.RA_targetencoder = targetRAEncoder; gGotoParams.RA_currentencoder = currentRAEncoder; gGotoParams.DEC_targetencoder = targetDECEncoder; gGotoParams.DEC_currentencoder = currentDECEncoder; //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message("Goto: " + EQMath.FmtSexa(gTargetRA, false) + " " + EQMath.FmtSexa(gTargetDec, true)); // HC.Add_Message "Goto: RaEnc=" & CStr(currentRAEncoder) & " Target=" & CStr(targetRAEncoder) // HC.Add_Message "Goto: DecEnc=" & CStr(currentDECEncoder) & " Target=" & CStr(targetDECEncoder) } catch { } }