Beispiel #1
0
        public bool StartScanning(string uniqueName, DistanceUnit unit, string scriptText)
        {
            ScanDocument scanDoc = GetScanDocument(uniqueName, unit);

            if (scanDoc != null)
            {
                try
                {
                    scanDoc.Scripts.Clear();
                    scanDoc.Scripts.Add(new ScanningScriptChunk("userScript", scriptText));
                    scanDoc.StartScanning();
                    return(true);
                }
                catch (DeviceNotConnectedException)
                {
                    MessageBox.Show("Device is not connected. Please connect to the device before start making", "错误");
                    return(false);
                }
                catch (DeviceCommunicationFailureException exp1)
                {
                    MessageBox.Show("Communication failure occurred.\nMessage: " + exp1.DeviceMessage, "错误");
                    return(false);
                }
                catch (DeviceFailureException exp2)
                {
                    MessageBox.Show("Device failed to start marking.\nMessage: " + exp2.DeviceMessage, "错误");
                    return(false);
                }
            }

            return(false);
        }
Beispiel #2
0
        private ScanDocument GetScanDocument(string uniqueName, DistanceUnit unit)
        {
            if (!_scanDocs.ContainsKey(uniqueName))
            {
                try
                {
                    ScanDocument scanDoc = _scanDevMgr.CreateScanDocument(uniqueName, unit);

                    scanDoc.DocumentScanningStatusChanged += ScanDocument_ScanningStatusChanged;
                    scanDoc.ScriptMessageReceived         += ScanDocument_ScriptMessageReceived;

                    _scanDocs.Add(uniqueName, scanDoc);

                    return(scanDoc);
                }

                catch (DeviceNotFoundException)
                {
                    _scanDocs.Remove(uniqueName);
                    MessageBox.Show("Device could not be found", "错误");
                    return(null);
                }
                catch (DeviceAlreadyInUseException)
                {
                    _scanDocs.Remove(uniqueName);
                    MessageBox.Show("Device already in use", "错误");
                    return(null);
                }
            }
            else
            {
                return(_scanDocs[uniqueName]);
            }
        }
Beispiel #3
0
        public bool SetLaserPowerPercentage(string deviceName, float power)
        {
            try
            {
                ScanDocument scanDocument = null;
                DistanceUnit distanceUnit = DistanceUnit.Millimeters;
                scanDocument = _scanDevMgr.CreateScanDocument(deviceName, distanceUnit);

                scanDocument.PreviewInfo.Enabled = false;
                DistanceUnit scanningUnits     = DistanceUnit.Millimeters;
                DistanceUnit imageDistanceUnit = scanningUnits;


                VectorImage vectorImage = scanDocument.CreateVectorImage("vectorImage1", imageDistanceUnit);
                vectorImage.VariablePolyDelayEnabled = true;
                vectorImage.SetLaserPowerPercentage(power);
            }
            catch (Exception ex)
            {
                //Database.Access.Instance.Insert(new LogItem("通信", ex.Message.ToString()));
                return(false);
            }
            return(true);
        }