Exemplo n.º 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?
        }
Exemplo n.º 2
0
 void data_Progress(NikonObject sender,
                    eNkMAIDCommand ulCommand,
                    UInt32 ulParam,
                    IntPtr refComplete,
                    UInt32 ulDone,
                    UInt32 ulTotal)
 {
     Scheduler.Callback(new ProgressDelegate(OnProgress), this, (eNkMAIDDataObjType)sender.Id, (int)ulDone, (int)ulTotal);
 }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
 //
 // Call Entry Point
 //
 void CallEntryPointSync(
     eNkMAIDCommand ulCommand,
     UInt32 ulParam,
     eNkMAIDDataType ulDataType,
     IntPtr data)
 {
     CallEntryPoint(
         ulCommand,
         ulParam,
         ulDataType,
         data,
         IntPtr.Zero,
         IntPtr.Zero);
 }
Exemplo n.º 7
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);
     }
 }
Exemplo n.º 8
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);
            }
        }
Exemplo n.º 9
0
 void data_Progress(NikonObject sender,
     eNkMAIDCommand ulCommand,
     UInt32 ulParam,
     IntPtr refComplete,
     UInt32 ulDone,
     UInt32 ulTotal)
 {
     Scheduler.Callback(new ProgressDelegate(OnProgress), this, (eNkMAIDDataObjType)sender.Id, (int)ulDone, (int)ulTotal);
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
 //
 // Progress Callback
 //
 void ProgressProc(
     eNkMAIDCommand ulCommand,
     UInt32 ulParam,
     IntPtr refComplete,
     UInt32 ulDone,
     UInt32 ulTotal)
 {
     if (Progress != null)
     {
         Progress(
             this,
             ulCommand,
             ulParam,
             refComplete,
             ulDone,
             ulTotal);
     }
 }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
 //
 // Call Entry Point
 //
 void CallEntryPointSync(
     eNkMAIDCommand ulCommand,
     UInt32 ulParam,
     eNkMAIDDataType ulDataType,
     Int32 data)
 {
     CallEntryPoint(
         ulCommand,
         ulParam,
         ulDataType,
         data,
         IntPtr.Zero,
         IntPtr.Zero);
 }
Exemplo n.º 14
0
        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?
        }
Exemplo n.º 15
0
        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);
            }
        }
Exemplo n.º 16
0
 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);
     }
 }