Exemple #1
0
        void CallEntryPointAsync(
            eNkMAIDCommand ulCommand,
            UInt32 ulParam,
            eNkMAIDDataType ulDataType,
            IntPtr data)
        {
            Context context;

            context.Complete = false;
            context.Result   = eNkMAIDResult.kNkMAIDResult_NoError;

            IntPtr pfnComplete = Marshal.GetFunctionPointerForDelegate(_completionProc);
            IntPtr pfnRef      = new IntPtr(&context);


            CallEntryPoint(
                ulCommand,
                ulParam,
                ulDataType,
                data,
                pfnComplete,
                pfnRef);

            while (!context.Complete)
            {
                Async();
            }

            // Note: Is it OK to ignore context.Result?
        }
Exemple #2
0
 //
 // CapSet
 //
 internal void CapSet(eNkMAIDCapability capability, eNkMAIDDataType type, IntPtr data)
 {
     CapSet(
         capability,
         type,
         data.ToInt32());
 }
Exemple #3
0
 //
 // CapGetArray
 //
 internal void CapGetArray(eNkMAIDCapability capability, eNkMAIDDataType type, IntPtr data)
 {
     CallEntryPointAsync(
         eNkMAIDCommand.kNkMAIDCommand_CapGetArray,
         (uint)capability,
         type,
         data.ToInt32());
 }
Exemple #4
0
 //
 // CapGetDefault
 //
 internal void CapGetDefault(eNkMAIDCapability capability, eNkMAIDDataType type, IntPtr data)
 {
     CallEntryPointAsync(
         eNkMAIDCommand.kNkMAIDCommand_CapGetDefault,
         (uint)capability,
         type,
         data);
 }
Exemple #5
0
 //
 // CapStart
 //
 internal void CapStart(eNkMAIDCapability cap, eNkMAIDDataType dataType, IntPtr data)
 {
     CallEntryPointAsync(
         eNkMAIDCommand.kNkMAIDCommand_CapStart,
         (uint)cap,
         dataType,
         data);
 }
Exemple #6
0
 internal void CapSet(eNkMAIDCapability capability, eNkMAIDDataType type, Int32 data)
 {
     CallEntryPointAsync(
         eNkMAIDCommand.kNkMAIDCommand_CapSet,
         (uint)capability,
         type,
         data);
 }
Exemple #7
0
        void CallEntryPoint(
            IntPtr pObject,
            eNkMAIDCommand ulCommand,
            UInt32 ulParam,
            eNkMAIDDataType ulDataType,
            IntPtr data,
            IntPtr pfnComplete,
            IntPtr refComplete)
        {
            Debug.Assert(_md3 != null);

            Console.WriteLine("CallEntryPoint: {0}", ulCommand.ToString());

            try
            {
                eNkMAIDResult result = _md3.EntryPoint(
                    pObject,
                    ulCommand,
                    ulParam,
                    ulDataType,
                    data,
                    pfnComplete,
                    refComplete);

                switch (result)
                {
                // Note: Ignore these return values
                case eNkMAIDResult.kNkMAIDResult_NoError:
                case eNkMAIDResult.kNkMAIDResult_Pending:
                case eNkMAIDResult.kNkMAIDResult_OrphanedChildren:
                    break;

                default:
                    Console.WriteLine("===>NikonException {0},{1},{2},{3},{4}", result, ulCommand, ulParam, ulDataType, data);

                    /*
                     * throw new NikonException(
                     *  result,
                     *  ulCommand,
                     *  ulParam,
                     *  ulDataType,
                     *  data);
                     */
                    break;
                }
            }
            catch (System.AccessViolationException ex)
            {
                Console.WriteLine("===> {0}", ex.Message);
            }
        }
Exemple #8
0
        void CompletionProc(
            IntPtr pObject,
            eNkMAIDCommand ulCommand,
            UInt32 ulParam,
            eNkMAIDDataType ulDataType,
            IntPtr data,
            IntPtr refComplete,
            eNkMAIDResult nResult)
        {
            Context *context = (Context *)refComplete.ToPointer();

            context->Complete = true;
            context->Result   = nResult;
        }
Exemple #9
0
 //
 // Call Entry Point
 //
 void CallEntryPointSync(
     eNkMAIDCommand ulCommand,
     UInt32 ulParam,
     eNkMAIDDataType ulDataType,
     IntPtr data)
 {
     CallEntryPoint(
         ulCommand,
         ulParam,
         ulDataType,
         data,
         IntPtr.Zero,
         IntPtr.Zero);
 }
Exemple #10
0
 public NikonException(eNkMAIDResult errorCode, eNkMAIDCommand errorCommand, UInt32 errorParam, eNkMAIDDataType errorDataType, IntPtr errorData)
     : base(string.Format("[{0}] ({1}, {2}, {3}, {4})",
                          errorCode.ToString(),
                          errorCommand.ToString(),
                          errorParam.ToString(),
                          errorDataType.ToString(),
                          errorData.ToString()))
 {
     _errorCode     = errorCode;
     _errorCommand  = errorCommand;
     _errorParam    = errorParam;
     _errorDataType = errorDataType;
     _errorData     = errorData;
 }
Exemple #11
0
 void CallEntryPoint(
     eNkMAIDCommand ulCommand,
     UInt32 ulParam,
     eNkMAIDDataType ulDataType,
     IntPtr data,
     IntPtr pfnComplete,
     IntPtr refComplete)
 {
     fixed(NkMAIDObject *p = &_object)
     {
         CallEntryPoint(
             new IntPtr(p),
             ulCommand,
             ulParam,
             ulDataType,
             data,
             pfnComplete,
             refComplete);
     }
 }
Exemple #12
0
        void CallEntryPoint(
            IntPtr pObject,
            eNkMAIDCommand ulCommand,
            UInt32 ulParam,
            eNkMAIDDataType ulDataType,
            IntPtr data,
            IntPtr pfnComplete,
            IntPtr refComplete)
        {
            Debug.Assert(_md3 != null);

            eNkMAIDResult result = _md3.EntryPoint(
                pObject,
                ulCommand,
                ulParam,
                ulDataType,
                data,
                pfnComplete,
                refComplete);

            switch (result)
            {
            // Note: Ignore these return values
            case eNkMAIDResult.kNkMAIDResult_NoError:
            case eNkMAIDResult.kNkMAIDResult_Pending:
            case eNkMAIDResult.kNkMAIDResult_OrphanedChildren:
                break;

            default:
                throw new NikonException(
                          result,
                          ulCommand,
                          ulParam,
                          ulDataType,
                          data);
            }
        }
 void CallEntryPoint(
     eNkMAIDCommand ulCommand,
     UInt32 ulParam,
     eNkMAIDDataType ulDataType,
     Int32 data,
     IntPtr pfnComplete,
     IntPtr refComplete)
 {
     fixed (NkMAIDObject* p = &_object)
     {
         CallEntryPoint(
             new IntPtr(p),
             ulCommand,
             ulParam,
             ulDataType,
             data,
             pfnComplete,
             refComplete);
     }
 }
        void CallEntryPointAsync(
            eNkMAIDCommand ulCommand,
            UInt32 ulParam,
            eNkMAIDDataType ulDataType,
            Int32 data)
        {
            Context context;
            context.Complete = false;
            context.Result = eNkMAIDResult.kNkMAIDResult_NoError;

            CallEntryPoint(
                ulCommand,
                ulParam,
                ulDataType,
                data,
                Marshal.GetFunctionPointerForDelegate(_completionProc),
                new IntPtr(&context));

            while (!context.Complete)
            {
                Async();
            }

            // Note: Is it OK to ignore context.Result?
        }
 internal void CapSet(eNkMAIDCapability capability, eNkMAIDDataType type, Int32 data)
 {
     CallEntryPointAsync(
         eNkMAIDCommand.kNkMAIDCommand_CapSet,
         (uint)capability,
         type,
         data);
 }
 //
 // CapSet
 //
 internal void CapSet(eNkMAIDCapability capability, eNkMAIDDataType type, IntPtr data)
 {
     CapSet(
         capability,
         type,
         data.ToInt32());
 }
 //
 // CapGetDefault
 //
 internal void CapGetDefault(eNkMAIDCapability capability, eNkMAIDDataType type, IntPtr data)
 {
     CallEntryPointAsync(
         eNkMAIDCommand.kNkMAIDCommand_CapGetDefault,
         (uint)capability,
         type,
         data.ToInt32());
 }
 public NikonException(eNkMAIDResult errorCode, eNkMAIDCommand errorCommand, UInt32 errorParam, eNkMAIDDataType errorDataType, Int32 errorData)
     : base(string.Format("[{0}] ({1}, {2}, {3}, {4})",
         errorCode.ToString(),
         errorCommand.ToString(),
         errorParam.ToString(),
         errorDataType.ToString(),
         errorData.ToString()))
 {
     _errorCode = errorCode;
     _errorCommand = errorCommand;
     _errorParam = errorParam;
     _errorDataType = errorDataType;
     _errorData = errorData;
 }
 void CompletionProc(
     IntPtr pObject,
     eNkMAIDCommand ulCommand,
     UInt32 ulParam,
     eNkMAIDDataType ulDataType,
     Int32 data,
     IntPtr refComplete,
     eNkMAIDResult nResult)
 {
     Context* context = (Context*)refComplete.ToPointer();
     context->Complete = true;
     context->Result = nResult;
 }
 //
 // Call Entry Point
 //
 void CallEntryPointSync(
     eNkMAIDCommand ulCommand,
     UInt32 ulParam,
     eNkMAIDDataType ulDataType,
     Int32 data)
 {
     CallEntryPoint(
         ulCommand,
         ulParam,
         ulDataType,
         data,
         IntPtr.Zero,
         IntPtr.Zero);
 }
Exemple #21
0
 public void Start(eNkMAIDCapability cap, eNkMAIDDataType dataType, IntPtr data)
 {
     _scheduler.Invoke(new StartCapabilityDelegate(_object.CapStart), cap, dataType, data);
 }
Exemple #22
0
 public void Start(eNkMAIDCapability cap, eNkMAIDDataType dataType, Int32 data)
 {
     _scheduler.Invoke(new StartCapabilityDelegate(_object.CapStart), cap, dataType, data);
 }
 //
 // CapStart
 //
 internal void CapStart(eNkMAIDCapability cap, eNkMAIDDataType dataType, int data)
 {
     CallEntryPointAsync(
         eNkMAIDCommand.kNkMAIDCommand_CapStart,
         (uint)cap,
         dataType,
         data);
 }
        void CallEntryPoint(
            IntPtr pObject,
            eNkMAIDCommand ulCommand,
            UInt32 ulParam,
            eNkMAIDDataType ulDataType,
            Int32 data,
            IntPtr pfnComplete,
            IntPtr refComplete)
        {
            Debug.Assert(_md3 != null);

            eNkMAIDResult result = _md3.EntryPoint(
                pObject,
                ulCommand,
                ulParam,
                ulDataType,
                data,
                pfnComplete,
                refComplete);

            switch (result)
            {
                // Note: Ignore these return values
                case eNkMAIDResult.kNkMAIDResult_NoError:
                case eNkMAIDResult.kNkMAIDResult_Pending:
                case eNkMAIDResult.kNkMAIDResult_OrphanedChildren:
                    break;

                default:
                    throw new NikonException(
                        result,
                        ulCommand,
                        ulParam,
                        ulDataType,
                        data);
            }
        }