Beispiel #1
0
        public bool open(short[] scannerTypesArray, out string status)
        {
            int zStatus;

            LogWrapper.logInfo(string.Format("Open()"));
            if (_IsOpen)
            {
                LogWrapper.logWarning(string.Format("Open() Zebra Scanner is already open"));
                status = "OK";
                return(true);
            }
            int appHandle = 0;

            try {
                short sizeOfScannerTypesArray = 1;
                scannerTypesArray[0] = SCANNER_TYPES_ALL;
                zStatus = STATUS_FAIL;
                _CoreScanner.Open(appHandle, scannerTypesArray, sizeOfScannerTypesArray, out zStatus);
                if (STATUS_SUCCESS == zStatus)
                {
                    _IsOpen = true;
                    if (RegisterForEvents(out status) == false)
                    {
                        LogWrapper.logError(string.Format("RegisterForEvents() FAILED: {0}", status));
                        _IsOpen = false;
                        return(false);
                    }
                    status = "OK";
                    return(true);
                }
                else
                {
                    status = decodeStatusMessage(zStatus);
                    LogWrapper.logError(string.Format("_CoreScanner.Open() FAILED: {0}", status));
                    return(false);
                }
            } catch (Exception ex) {
                status = ex.Message;
                LogWrapper.logError(string.Format("Open() FAILED: {0}", status));
                return(false);
            }
        }
Beispiel #2
0
        void formLoad(object sender, EventArgs ea)
        {
            string status;

#if USE_COLT3
            _scanner = new Colt3.ZebraScanner.ZScanner();
#else
            _scanner = new ZebraWrapper();
#endif
            if (_scanner.Initialize(
                    OnZebraPlugAndPlayEventDelegate,
                    OnZebraBarcodeEventDelegate,
                    test1,
                    test2,
                    OnZebraScannerNotificationEventDelegate, OnZebraDisplayMessageDelegate,
                    out status) == false)
            {
                LogWrapper.logError(CL.makeSig(MethodBase.GetCurrentMethod()) + " " + status);
                return;
            }
            LogWrapper.log(MethodBase.GetCurrentMethod(), "scanner initialized....");
            short[] scannerTypeArray = new short[10];
#if USE_COLT3
            if (_scanner.Open(scannerTypeArray, out status) == false)
            {
                LogWrapper.logError(CL.makeSig(MethodBase.GetCurrentMethod()) + " " + status);
                return;
            }
#else
            //_scanner.Open ()
            if (_scanner.open(scannerTypeArray, out status) == false)
            {
                LogWrapper.logError(CL.makeSig(MethodBase.GetCurrentMethod()) + " " + status);
                return;
            }
#endif
            LogWrapper.log(MethodBase.GetCurrentMethod(), "scanner opened OK");
        }