Beispiel #1
0
            internal static AotaReturnValue GetAOTAResult()
            {
                AotaReturnValue result = null;

                ShieldedCall(() => result        = ReadAOTAResult());
                ShieldedCall(() => result.IsMiss = m_AotaInstance.IsMiss);
                ShieldedCall(() => result.AreResultsAvailable = m_AotaInstance.ResultsAreAvailable);
                ShieldedCall(() => result.AOTAVersion         = m_AotaInstance.AOTA_Version);

                return(result);
            }
Beispiel #2
0
            internal static AotaReturnValue ReadAOTAResult()
            {
                var rv = new AotaReturnValue();

                if (m_AotaInstance != null)
                {
                    object cameraObj = m_AotaInstance.Camera;
                    object event1Obj = m_AotaInstance.ResultsForEvent1;
                    object event2Obj = m_AotaInstance.ResultsForEvent2;
                    object event3Obj = m_AotaInstance.ResultsForEvent3;
                    object event4Obj = m_AotaInstance.ResultsForEvent4;
                    object event5Obj = m_AotaInstance.ResultsForEvent5;

                    if (cameraObj != null)
                    {
                        ReflectionCopy(cameraObj, ref rv.CameraResult);
                    }

                    rv.EventResults = new EventResults[5];

                    if (event1Obj != null)
                    {
                        ReflectionCopy(event1Obj, ref rv.EventResults[0]);
                    }
                    if (event2Obj != null)
                    {
                        ReflectionCopy(event2Obj, ref rv.EventResults[1]);
                    }
                    if (event3Obj != null)
                    {
                        ReflectionCopy(event3Obj, ref rv.EventResults[2]);
                    }
                    if (event4Obj != null)
                    {
                        ReflectionCopy(event4Obj, ref rv.EventResults[3]);
                    }
                    if (event5Obj != null)
                    {
                        ReflectionCopy(event5Obj, ref rv.EventResults[4]);
                    }
                }

                return(rv);
            }
Beispiel #3
0
            internal static AotaReturnValue ReadAOTAResult()
            {
                var rv = new AotaReturnValue();

                if (m_AotaInstance != null)
                {
                    object cameraObj = AOTA_ResultsCamera.GetValue(m_AotaInstance, new object[] { });
                    object event1Obj = AOTA_ResultsForEvent1.GetValue(m_AotaInstance, new object[] { });
                    object event2Obj = AOTA_ResultsForEvent2.GetValue(m_AotaInstance, new object[] { });
                    object event3Obj = AOTA_ResultsForEvent3.GetValue(m_AotaInstance, new object[] { });
                    object event4Obj = AOTA_ResultsForEvent4.GetValue(m_AotaInstance, new object[] { });
                    object event5Obj = AOTA_ResultsForEvent5.GetValue(m_AotaInstance, new object[] { });

                    if (cameraObj != null)
                    {
                        ReflectionCopy(cameraObj, ref rv.CameraResult);
                    }

                    rv.EventResults = new EventResults[5];

                    if (event1Obj != null)
                    {
                        ReflectionCopy(event1Obj, ref rv.EventResults[0]);
                    }
                    if (event2Obj != null)
                    {
                        ReflectionCopy(event2Obj, ref rv.EventResults[1]);
                    }
                    if (event3Obj != null)
                    {
                        ReflectionCopy(event3Obj, ref rv.EventResults[2]);
                    }
                    if (event4Obj != null)
                    {
                        ReflectionCopy(event4Obj, ref rv.EventResults[3]);
                    }
                    if (event5Obj != null)
                    {
                        ReflectionCopy(event5Obj, ref rv.EventResults[4]);
                    }
                }

                return(rv);
            }
Beispiel #4
0
            internal static AotaReturnValue ReadAOTAResult()
            {
                var rv = new AotaReturnValue();

                if (m_AotaInstance != null)
                {
                    object cameraObj = m_AotaInstance.Camera;
                    object event1Obj = m_AotaInstance.ResultsForEvent1;
                    object event2Obj = m_AotaInstance.ResultsForEvent2;
                    object event3Obj = m_AotaInstance.ResultsForEvent3;
                    object event4Obj = m_AotaInstance.ResultsForEvent4;
                    object event5Obj = m_AotaInstance.ResultsForEvent5;

                    if (cameraObj != null)
                        ReflectionCopy(cameraObj, ref rv.CameraResult);

                    rv.EventResults = new EventResults[5];

                    if (event1Obj != null) ReflectionCopy(event1Obj, ref rv.EventResults[0]);
                    if (event2Obj != null) ReflectionCopy(event2Obj, ref rv.EventResults[1]);
                    if (event3Obj != null) ReflectionCopy(event3Obj, ref rv.EventResults[2]);
                    if (event4Obj != null) ReflectionCopy(event4Obj, ref rv.EventResults[3]);
                    if (event5Obj != null) ReflectionCopy(event5Obj, ref rv.EventResults[4]);
                }

                return rv;
            }
Beispiel #5
0
            internal static AotaReturnValue RunAOTA(ILightCurveDataProvider dataProvider, IWin32Window parentWindow)
            {
                try
                {
                    if (m_AotaInstance == null)
                    {
                        m_AotaInstance = Activator.CreateInstance(TYPE_AOTA_ExternalAccess);
                    }

                    AOTA_InitialiseAOTA.Invoke(m_AotaInstance, new object[] { dataProvider.FileName });

                    ISingleMeasurement[] measurements = dataProvider.GetTargetMeasurements();

                    bool hasReliableTimeBase = dataProvider.HasReliableTimeBase;

                    float[] data     = measurements.Select(x => x.Measurement).ToArray();
                    float[] frameIds = measurements.Select(x => (float)x.CurrFrameNo).ToArray();

                    if (AOTA_Set_TargetData_BackgroundAlreadySubtracted != null)
                    {
                        float[] dataBg = measurements.Select(x => x.Background).ToArray();
                        AOTA_Set_TargetData_BackgroundAlreadySubtracted.Invoke(m_AotaInstance, new object[] { data, dataBg });
                    }
                    else
                    {
                        AOTA_Set_TargetData.Invoke(m_AotaInstance, new object[] { data });
                    }

                    AOTA_Set_FrameID.Invoke(m_AotaInstance, new object[] { frameIds });

                    DateTime[] timestamps = measurements.Select(x => x.Timestamp).ToArray();

                    hasReliableTimeBase = hasReliableTimeBase &&
                                          timestamps[0].Date != DateTime.MinValue &&
                                          timestamps[measurements.Length - 1].Date != DateTime.MinValue &&
                                          timestamps[0].Date.Ticks < timestamps[measurements.Length - 1].Ticks;

                    double[] secondsFromUTMidnight;
                    long     startFrameStartDayTicks;

                    if (hasReliableTimeBase)
                    {
                        startFrameStartDayTicks = timestamps[0].Date.Ticks;
                        secondsFromUTMidnight   = timestamps.Select(x => (Math.Truncate(new TimeSpan(x.Ticks - startFrameStartDayTicks).TotalSeconds * 10000) / 10000.0)).ToArray();
                    }
                    else
                    {
                        startFrameStartDayTicks = timestamps.FirstOrDefault(x => x != DateTime.MinValue).Date.Ticks;
                        secondsFromUTMidnight   = new double[timestamps.Length];
                        for (int i = 0; i < timestamps.Length; i++)
                        {
                            if (timestamps[i] != DateTime.MinValue)
                            {
                                secondsFromUTMidnight[i] = Math.Truncate(new TimeSpan(timestamps[i].Ticks - startFrameStartDayTicks).TotalSeconds * 10000) / 10000.0;
                            }
                            else
                            {
                                secondsFromUTMidnight[i] = 0;
                            }
                        }
                    }

                    bool cameraCorrectionsHaveBeenApplied = dataProvider.CameraCorrectionsHaveBeenApplied && dataProvider.HasEmbeddedTimeStamps;

                    if (AOTA_Set_TimeBaseEx != null)
                    {
                        AOTA_Set_TimeBaseEx.Invoke(m_AotaInstance, new object[] { secondsFromUTMidnight, cameraCorrectionsHaveBeenApplied });
                    }
                    else if (AOTA_Set_TimeBase != null)
                    {
                        AOTA_Set_TimeBase.Invoke(m_AotaInstance, new object[] { secondsFromUTMidnight });
                    }

                    if (cameraCorrectionsHaveBeenApplied)
                    {
                        string cameraName = dataProvider.VideoCameraName;
                        if (!string.IsNullOrEmpty(cameraName))
                        {
                            AOTA_Set_VideoCamera.Invoke(m_AotaInstance, new object[] { cameraName });
                        }
                    }

                    // Now go and set any comparison stars
                    for (int i = 0; i < dataProvider.NumberOfMeasuredComparisonObjects; i++)
                    {
                        ISingleMeasurement[] compMeasurements = dataProvider.GetComparisonObjectMeasurements(i);

                        if (compMeasurements != null)
                        {
                            float[] compData = compMeasurements.Select(x => x.Measurement).ToArray();

                            if (i == 0)
                            {
                                AOTA_Set_Comp1Data.Invoke(m_AotaInstance, new object[] { compData });
                            }
                            else if (i == 1)
                            {
                                AOTA_Set_Comp2Data.Invoke(m_AotaInstance, new object[] { compData });
                            }
                            else if (i == 2)
                            {
                                AOTA_Set_Comp3Data.Invoke(m_AotaInstance, new object[] { compData });
                            }
                        }
                    }

                    int firstFrameIndex     = 0;// (int)frameIds[0];
                    int framesInIntegration = 1;

                    AOTA_RunAOTAEx2.Invoke(m_AotaInstance, new object[] { null /*parentWindow*/, firstFrameIndex, framesInIntegration });

                    AotaReturnValue result = ReadAOTAResult();
                    result.IsMiss = (bool)AOTA_IsMiss.GetValue(m_AotaInstance, new object[] { });
                    result.AreResultsAvailable = (bool)AOTA_ResultsAreAvailable.GetValue(m_AotaInstance, new object[] { });
                    result.AOTAVersion         = (string)AOTA_Version.GetValue(m_AotaInstance, new object[] { });

                    return(result);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                    MessageBox.Show(ex is TargetInvocationException ? ex.InnerException.Message : ex.Message, "AOTA Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                return(null);
            }
            internal static AotaReturnValue ReadAOTAResult()
            {
                var rv = new AotaReturnValue();

                if (m_AotaInstance != null)
                {
                    object cameraObj = AOTA_ResultsCamera.GetValue(m_AotaInstance, new object[] { });
                    object event1Obj = AOTA_ResultsForEvent1.GetValue(m_AotaInstance, new object[] { });
                    object event2Obj = AOTA_ResultsForEvent2.GetValue(m_AotaInstance, new object[] { });
                    object event3Obj = AOTA_ResultsForEvent3.GetValue(m_AotaInstance, new object[] { });
                    object event4Obj = AOTA_ResultsForEvent4.GetValue(m_AotaInstance, new object[] { });
                    object event5Obj = AOTA_ResultsForEvent5.GetValue(m_AotaInstance, new object[] { });

                    if (cameraObj != null)
                        ReflectionCopy(cameraObj, ref rv.CameraResult);

                    rv.EventResults = new EventResults[5];

                    if (event1Obj != null) ReflectionCopy(event1Obj, ref rv.EventResults[0]);
                    if (event2Obj != null) ReflectionCopy(event2Obj, ref rv.EventResults[1]);
                    if (event3Obj != null) ReflectionCopy(event3Obj, ref rv.EventResults[2]);
                    if (event4Obj != null) ReflectionCopy(event4Obj, ref rv.EventResults[3]);
                    if (event5Obj != null) ReflectionCopy(event5Obj, ref rv.EventResults[4]);
                }

                return rv;
            }