internal MarshalByRefLightCurveDataProvider(ILightCurveDataProvider localProvider)
        {
            m_DelegatedLocalProvider = localProvider;

            FileName = localProvider.FileName;
            NumberOfMeasuredComparisonObjects = localProvider.NumberOfMeasuredComparisonObjects;
            CameraCorrectionsHaveBeenApplied = localProvider.CameraCorrectionsHaveBeenApplied;
            HasEmbeddedTimeStamps = localProvider.HasEmbeddedTimeStamps;
            VideoCameraName = localProvider.VideoCameraName;
            VideoSystem = localProvider.VideoSystem;
            NumberIntegratedFrames = localProvider.NumberIntegratedFrames;
            MinFrameNumber = localProvider.MinFrameNumber;
            MaxFrameNumber = localProvider.MaxFrameNumber;
            m_TangraDrawingSettings = localProvider.GetTangraDrawingSettings();

            CurrentlySelectedFrameNumber = localProvider.CurrentlySelectedFrameNumber;
            HasReliableTimeBase = localProvider.HasReliableTimeBase;
            m_TargetMeasurements = localProvider.GetTargetMeasurements();
            if (NumberOfMeasuredComparisonObjects > 0)
                m_Comp1Measurements = localProvider.GetComparisonObjectMeasurements(0);
            if (NumberOfMeasuredComparisonObjects > 1)
                m_Comp2Measurements = localProvider.GetComparisonObjectMeasurements(1);
            if (NumberOfMeasuredComparisonObjects > 2)
                m_Comp3Measurements = localProvider.GetComparisonObjectMeasurements(2);
            localProvider.GetIntegrationRateAndFirstFrame(out m_IntegrationRate, out m_FirstIntegratingFrame);
        }
Example #2
0
 internal void SetLightCurveDataProvider(ILightCurveDataProvider provider)
 {
     m_lcDataProvider = provider;
 }
Example #3
0
            internal static bool RunAOTA(ILightCurveDataProvider dataProvider, IWin32Window parentWindow, IAOTAClientCallbacks clientCallbacks)
            {
                try
                {
                    if (m_AotaInstance == null)
                        m_AotaInstance = Activator.CreateInstance(TYPE_AOTA_ExternalAccess) as Occult.SDK.IAOTAExternalAccess;

                    ShieldedCall(() => m_AotaInstance.InitialiseAOTA(dataProvider.FileName, clientCallbacks));

                    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();

                    float[] dataBg = measurements.Select(x => x.Background).ToArray();
                    ShieldedCall(() => m_AotaInstance.Set_TargetData_BackgroundAlreadySubtracted(data, dataBg));

                    ShieldedCall(() => m_AotaInstance.Set_FrameID(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;

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

                    startFrameStartDayTicks = hasReliableTimeBase ? timestamps[0].Date.Ticks : timestamps.FirstOrDefault(x => x != DateTime.MinValue).Date.Ticks;
                    secondsFromUTMidnight = new double[timestamps.Length];
                    for (int i = 0; i < timestamps.Length; i++)
                    {
                        if (!measurements[i].IsCorrectedForInstrumentalDelay && cameraCorrectionsHaveBeenApplied)
                            // Individual frames for which instrumental delays hasn't been applied even that instrumental delay is applied for the file, are marked as blank
                            secondsFromUTMidnight[i] = 0;
                        else if (timestamps[i] != DateTime.MinValue)
                            secondsFromUTMidnight[i] = Math.Truncate(new TimeSpan(timestamps[i].Ticks - startFrameStartDayTicks).TotalSeconds * 10000) / 10000.0;
                        else
                            secondsFromUTMidnight[i] = 0;
                    }

                    ShieldedCall(() => m_AotaInstance.Set_TimeBase(secondsFromUTMidnight, cameraCorrectionsHaveBeenApplied));

                    if (cameraCorrectionsHaveBeenApplied)
                    {
                        string cameraName = dataProvider.VideoCameraName;
                        if (!string.IsNullOrEmpty(cameraName))
                            ShieldedCall(() => m_AotaInstance.Set_VideoCamera(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)
                                ShieldedCall(() => m_AotaInstance.Set_Comp1Data(compData));
                            else if (i == 1)
                                ShieldedCall(() => m_AotaInstance.Set_Comp2Data(compData));
                            else if (i == 2)
                                ShieldedCall(() => m_AotaInstance.Set_Comp3Data(compData));
                        }
                    }

                     ShieldedCall(() => m_AotaInstance.Camera = new Occult.SDK.Camera()
                        {
                            CameraType = dataProvider.VideoCameraName,
                            VideoSystem = dataProvider.VideoSystem,
                            FramesIntegrated = dataProvider.NumberIntegratedFrames
                        });

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

                    ShieldedCall(() => m_AotaInstance.RunAOTA(null, firstFrameIndex, framesInIntegration, false));

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

                return false;
            }
Example #4
0
 internal void SetLightCurveDataProvider(ILightCurveDataProvider provider)
 {
     m_LocalLightCurveDataProvider = provider;
     m_DelegatedLightCurveDataProvider = null;
 }
            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;
            }