internal static bool EQ_NPointAppend(double RightAscension, double Declination, double pLongitude, int pHemisphere) { bool result = false; object oLangDll = null; object HC = null; object StarEditform = null; double tRa = 0; double tPier = 0; double DeltaRa = 0; double DeltaDec = 0; int i = 0; int Count = 0; bool flipped = false; result = true; int curalign = gAlignmentStars_count + 1; // build alignment record int ERa = Common.EQGetMotorValues(0); int EDec = Common.EQGetMotorValues(1); double vRA = RightAscension; double vDEC = Declination; // look at current position and detemrine if flipped double RA_Hours = EQMath.Get_EncoderHours(EQMath.gRAEncoder_Zero_pos, Convert.ToDouble(ERa), EQMath.gTot_RA, EQMath.gHemisphere); if (RA_Hours > 12) { // Yes we're currently flipped! flipped = true; } else { flipped = false; } double tha = EQMath.RangeHA(vRA - EQMath.EQnow_lst(pLongitude * EQMath.DEG_RAD)); if (tha < 0) { if (flipped) { if (EQMath.gHemisphere == 0) { tPier = 0; } else { tPier = 1; } tRa = vRA; } else { if (EQMath.gHemisphere == 0) { tPier = 1; } else { tPier = 0; } tRa = EQMath.Range24(vRA - 12); } } else { if (flipped) { if (EQMath.gHemisphere == 0) { tPier = 1; } else { tPier = 0; } tRa = EQMath.Range24(vRA - 12); } else { if (EQMath.gHemisphere == 0) { tPier = 0; } else { tPier = 1; } tRa = vRA; } } //Compute for Sync RA/DEC Encoder Values AlignmentStars[curalign].OrigTargetDEC = Declination; AlignmentStars[curalign].OrigTargetRA = RightAscension; AlignmentStars[curalign].TargetRA = EQMath.Get_RAEncoderfromRA(tRa, 0, pLongitude, EQMath.gRAEncoder_Zero_pos, EQMath.gTot_RA, pHemisphere); AlignmentStars[curalign].TargetDEC = EQMath.Get_DECEncoderfromDEC(vDEC, tPier, EQMath.gDECEncoder_Zero_pos, EQMath.gTot_DEC, pHemisphere); AlignmentStars[curalign].EncoderRA = ERa; AlignmentStars[curalign].EncoderDEC = EDec; AlignmentStars[curalign].AlignTime = DateTime.Now; DeltaRa = AlignmentStars[curalign].TargetRA - AlignmentStars[curalign].EncoderRA; //' Difference between theoretical position and encode position. DeltaDec = AlignmentStars[curalign].TargetDEC - AlignmentStars[curalign].EncoderDEC; //' Difference between theoretical position and encode position. //UPGRADE_TODO: (1067) Member EncoderTimer is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.EncoderTimer.Enabled = true; if ((Math.Abs(DeltaRa) < EQMath.gEQ_MAXSYNC) && (Math.Abs(DeltaDec) < EQMath.gEQ_MAXSYNC) || Common.gDisableSyncLimit) { // Use this data also for next sync until a three star is achieved EQMath.gRA1Star = DeltaRa; EQMath.gDEC1Star = DeltaDec; if (curalign < 3) { //UPGRADE_TODO: (1067) Member GetLangString is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message(Conversion.Str(curalign) + " " + Convert.ToString(oLangDll.GetLangString(6009))); gAlignmentStars_count++; } else { if (curalign == 3) { gAlignmentStars_count = 3; SendtoMatrix(); } else { // add new point Count = 1; // copy points to temp array int tempForEndVar = curalign - 1; for (i = 1; i <= tempForEndVar; i++) { DeltaRa = Math.Abs(AlignmentStars[i].EncoderRA - ERa); DeltaDec = Math.Abs(AlignmentStars[i].EncoderDEC - EDec); if (DeltaRa > ProximityRa || DeltaDec > ProximityDec) { // point is far enough away from the new point - so keep it AlignmentStars[Count] = AlignmentStars[i]; Count++; } else { // HC.Add_Message ("Old Point too close " & CStr(deltaRA) & " " & CStr(deltadec) & " " & CStr(ProximityDec)) } } AlignmentStars[Count] = AlignmentStars[curalign]; curalign = Count; gAlignmentStars_count = curalign; SendtoMatrix(); //UPGRADE_TODO: (1067) Member RefreshDisplay is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 StarEditform.RefreshDisplay = true; } } } else { // sync is too large! result = false; //UPGRADE_TODO: (1067) Member GetLangString is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message(oLangDll.GetLangString(6004)); //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message("Target RA=" + EQMath.FmtSexa(EQMath.gRA, false)); //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message("Sync RA=" + EQMath.FmtSexa(RightAscension, false)); //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message("Target DEC=" + EQMath.FmtSexa(EQMath.gDec, true)); //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message("Sync DEC=" + EQMath.FmtSexa(Declination, true)); } if (gSaveAPresetOnAppend == 1) { // don't write emtpy list! if (gAlignmentStars_count > 0) { //idx = GetPresetIdx string tempRefParam = ""; SaveAlignmentStars(GetPresetIdx(), ref tempRefParam); } } return(result); }
//UPGRADE_NOTE: (2041) The following line was commented. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2041 //[DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)] //extern public static int GetTickCount(); private void EncoderTimer_Timer() { eqmodvector.Coordt tmpcoord = new eqmodvector.Coordt(); double tRa = 0; double tAlt = 0; double tAz = 0; object tmpRa = null; int tmpDec = 0; //Avoid overruns if (EncoderTimerFlag) { EncoderTimerFlag = false; //UPGRADE_TODO: (1067) Member CheckRASync is not defined in type HC. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 //Read true motor positions tmpRa = Common.EQGetMotorValues(0); tmpDec = Common.EQGetMotorValues(1); EQMath.gEmulRA = Convert.ToDouble(tmpRa); EQMath.gEmulDEC = tmpDec; EQMath.gEmulRA_Init = EQMath.gEmulRA; EQMath.gLast_time = EQMath.EQnow_lst_norange(); EQMath.gEmulOneShot = false; if (!Alignment.gThreeStarEnable) { Alignment.gSelectStar = 0; EQMath.gRA_Encoder = EQMath.Delta_RA_Map(EQMath.gEmulRA); EQMath.gDec_Encoder = EQMath.Delta_DEC_Map(EQMath.gEmulDEC); } else { switch (Common.gAlignmentMode) { case 2: tmpcoord = EQMath.DeltaSync_Matrix_Map(EQMath.gEmulRA, EQMath.gEmulDEC); EQMath.gRA_Encoder = tmpcoord.x; EQMath.gDec_Encoder = tmpcoord.Y; break; case 1: tmpcoord = EQMath.Delta_Matrix_Reverse_Map(EQMath.gEmulRA, EQMath.gEmulDEC); EQMath.gRA_Encoder = tmpcoord.x; EQMath.gDec_Encoder = tmpcoord.Y; break; default: tmpcoord = EQMath.Delta_Matrix_Reverse_Map(EQMath.gEmulRA, EQMath.gEmulDEC); EQMath.gRA_Encoder = tmpcoord.x; EQMath.gDec_Encoder = tmpcoord.Y; if (tmpcoord.f == 0) { tmpcoord = EQMath.DeltaSync_Matrix_Map(EQMath.gEmulRA, EQMath.gEmulDEC); EQMath.gRA_Encoder = tmpcoord.x; EQMath.gDec_Encoder = tmpcoord.Y; } break; } } //Convert RA_Encoder to Hours if ((EQMath.gRA_Encoder < 0x1000000)) { EQMath.gRA_Hours = EQMath.Get_EncoderHours(EQMath.gRAEncoder_Zero_pos, EQMath.gRA_Encoder, EQMath.gTot_RA, EQMath.gHemisphere); } //Convert DEC_Encoder to DEC Degrees EQMath.gDec_DegNoAdjust = EQMath.Get_EncoderDegrees(EQMath.gDECEncoder_Zero_pos, EQMath.gDec_Encoder, EQMath.gTot_DEC, EQMath.gHemisphere); if (EQMath.gDec_Encoder < 0x1000000) { EQMath.gDec_Degrees = EQMath.Range_DEC(EQMath.gDec_DegNoAdjust); } tRa = EQMath.EQnow_lst(EQMath.gLongitude * EQMath.DEG_RAD) + EQMath.gRA_Hours; if (EQMath.gHemisphere == 0) { if ((EQMath.gDec_DegNoAdjust > 90) && (EQMath.gDec_DegNoAdjust <= 270)) { tRa -= 12; } } else { if ((EQMath.gDec_DegNoAdjust <= 90) || (EQMath.gDec_DegNoAdjust > 270)) { tRa += 12; } } tRa = EQMath.Range24(tRa); //assign global RA / Dec EQMath.gRA = tRa; EQMath.gDec = EQMath.gDec_Degrees; EQMath.gha = tRa - EQMath.EQnow_lst(EQMath.gLongitude * EQMath.DEG_RAD); //calc alt/ az poition ((Array)hadec_aa).GetValue(Convert.ToInt32(EQMath.gLatitude * EQMath.DEG_RAD), Convert.ToInt32(EQMath.gha * EQMath.HRS_RAD), Convert.ToInt32(EQMath.gDec_Degrees * EQMath.DEG_RAD), Convert.ToInt32(tAlt), Convert.ToInt32(tAz)); //asign global Alt / Az EQMath.gAlt = tAlt * EQMath.RAD_DEG; // convert to degrees from Radians EQMath.gAz = 360d - (tAz * EQMath.RAD_DEG); // convert to degrees from Radians //Poll the Motor Status while slew is active if (EQMath.gSlewStatus) { EQMath.gRAStatus = UpgradeSolution1Support.PInvoke.SafeNative.eqcontrl.EQ_GetMotorStatus(0); EQMath.gDECStatus = UpgradeSolution1Support.PInvoke.SafeNative.eqcontrl.EQ_GetMotorStatus(1); if (EQMath.gEQparkstatus == 0) { Goto.ManageGoto(); } } //UPGRADE_TODO: (1067) Member Caption is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 AlignmentCountLbl.Caption = Alignment.gAlignmentStars_count.ToString(); do { limit management Limits.Limits_Execute(); } EncoderTimerFlag = true; } }