예제 #1
0
        public StraightPhotocellConveyor(StraightPhotocellConveyorInfo info) : base(info)
        {
            try
            {
                straightInfo            = info;
                releaseTimer.OnElapsed += ReleaseTimer_OnElapsed;

                constructDevice          = new ConstructDevice(string.Empty);
                LineReleasePhotocellName = straightInfo.LineReleasePhotocellName;
                DeviceInfo deviceInfo = DeviceInfos.Find(i => i.name == LineReleasePhotocellName);
                if (deviceInfo == null)
                {
                    CasePhotocellInfo photocellInfo = new CasePhotocellInfo();
                    photocellInfo.name         = "LineRelease";
                    photocellInfo.distanceFrom = PositionPoint.End;
                    photocellInfo.distance     = 0.125f;
                    photocellInfo.type         = constructDevice.DeviceTypes["Add Photocell"].Item1; //Item1 is the device type ...obviously!
                    DeviceInfos.Add(photocellInfo);
                }
                constructDevice.InsertDevices(this as IConstructDevice);

                SetLineReleasePhotocell();
                LineReleaseEvents(true);
            }
            catch (Exception ex)
            {
                Core.Environment.Log.Write(ex.Message);
            }
        }
예제 #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="_LogFileName">Log file name</param>
 public ScannerControl(string _LogFileName)
 {
     DeviceManager = new DeviceManager();
     DeviceInfoCollection = DeviceManager.DeviceInfos  ;
     objScannerPowerManager = new ScannerPowerManager(_LogFileName);
     scnMngrLog = new ScnMngrLog(_LogFileName);
 }
예제 #3
0
        public override DeviceBase Clone()
        {
            var deviceBase = new DeviceGroup
            {
                id          = Guid.NewGuid(),
                index       = index,
                ip          = ip,
                name        = name,
                state       = state,
                timeOut     = timeOut,
                refreshTime = refreshTime,
                DeviceInfos = new Collection <DeviceInfo>()
            };

            DeviceInfos.ForEach(m =>
            {
                var element = m.Clone() as DeviceInfo;
                if (element != null)
                {
                    element.parentId    = deviceBase.id;
                    element.DeviceGroup = deviceBase;
                }
                deviceBase.DeviceInfos.Add(element);
            });
            return(deviceBase);
        }
예제 #4
0
        public async Task <SignInToken> CreateAsync(
            string userGuid,
            string deviceId,
            DeviceInfos deviceInfos,
            string deviceVersion,
            string ipAddress,
            TimeSpan expireTimeSpan,
            string lastUser,
            TransactionContext?transactionContext)
        {
            SignInToken token = new SignInToken
            {
                UserGuid      = userGuid,
                RefreshToken  = SecurityUtil.CreateUniqueToken(),
                ExpireAt      = DateTimeOffset.UtcNow + expireTimeSpan,
                DeviceId      = deviceId,
                DeviceVersion = deviceVersion,
                DeviceIp      = ipAddress,

                DeviceName      = deviceInfos.Name,
                DeviceModel     = deviceInfos.Model,
                DeviceOSVersion = deviceInfos.OSVersion,
                DevicePlatform  = deviceInfos.Platform,
                DeviceIdiom     = deviceInfos.Idiom,
                DeviceType      = deviceInfos.Type
            };

            await AddAsync(token, lastUser, transactionContext).ConfigureAwait(false);

            return(token);
        }
예제 #5
0
        public PalletStraight(PalletStraightInfo info) : base(info)
        {
            try
            {
                palletStraightInfo      = info;
                ReleaseTimer.OnElapsed += ReleaseTimer_OnElapsed;

                ConstructDevice          = new ConstructDevice(string.Empty);
                LineReleasePhotocellName = palletStraightInfo.LineReleasePhotocellName;
                DeviceInfo deviceInfo = DeviceInfos.Find(i => i.name == LineReleasePhotocellName);
                if (deviceInfo == null)
                {
                    PalletPhotocellInfo photocellInfo = new PalletPhotocellInfo();
                    photocellInfo.name         = "LineRelease";
                    photocellInfo.distanceFrom = PositionPoint.End;
                    photocellInfo.distance     = 0.125f;
                    photocellInfo.type         = ConstructDevice.DeviceTypes["Add Photocell"].Item1; //Item1 is the device type ...obviously!
                    DeviceInfos.Add(photocellInfo);
                }
                ConstructDevice.InsertDevices(this as IConstructDevice);

                SetLineReleasePhotocell();
                LineReleaseEvents(true);

                if (ControlType == ControlTypes.Local)
                {
                    OnLoadArrived += Photocell_OnLoadArrived;
                }
            }
            catch (Exception ex)
            {
                Core.Environment.Log.Write(ex.Message);
            }
        }
예제 #6
0
 /// <summary>
 /// Constructor. 
 /// </summary>
 public ScannerControl()
 {
     //System.Diagnostics.Debug.WriteLine(@"DeviceManager = new DeviceManager();");
     DeviceManager = new DeviceManager();
     DeviceInfoCollection = DeviceManager.DeviceInfos  ;
     objScannerPowerManager = new ScannerPowerManager();
     scnMngrLog = new ScnMngrLog();
 }
예제 #7
0
        /// <summary>
        /// Creates a meta file from the current page.
        /// </summary>
        private void miMetaFile_Click(object sender, EventArgs e)
        {
            int page = this.pagePreview.Page;

            // Reuse the renderer from the preview
            DocumentRenderer renderer = this.pagePreview.Renderer;
            PageInfo         info     = renderer.FormattedDocument.GetPageInfo(page);

            // Create an image
            float dx, dy;

            if (info.Orientation == PdfSharp.PageOrientation.Portrait)
            {
                dx = (float)(info.Width.Inch * 72);
                dy = (float)(info.Height.Inch * 72);
            }
            else
            {
                dx = (float)(info.Height.Inch * 72);
                dy = (float)(info.Width.Inch * 72);
            }

            // Create a graphics object as reference
            Graphics graphicsDisplay = CreateGraphics();
            IntPtr   hdc             = graphicsDisplay.GetHdc();

            // There is a little difference between the display resolution (i.g. 96 DPI) and the real physical solution of the display.
            // This must be taken into account...
            DeviceInfos devInfo = DeviceInfos.GetInfos(hdc);

            // Create the metafile
            Metafile metafile = new Metafile("test.emf", hdc,
                                             new RectangleF(0, 0, devInfo.ScaleX * dx, devInfo.ScaleY * dy), MetafileFrameUnit.Point);

            graphicsDisplay.ReleaseHdc(hdc);
            graphicsDisplay.Dispose();

            // Create a Graphics object for the metafile and scale it for drawing with 72 dpi
            Graphics graphics = Graphics.FromImage(metafile);

            graphics.Clear(System.Drawing.Color.White);
            //graphics.PageUnit = GraphicsUnit.Point; ???
            graphics.ScaleTransform(graphics.DpiX / 72, graphics.DpiY / 72);

            // Check if size is correct
            graphics.DrawLine(Pens.Red, 0, 0, dx, dy);

            // Create an XGraphics object and render the page
            XGraphics gfx = XGraphics.FromGraphics(graphics, new XSize(info.Width.Point, info.Height.Point));

            renderer.RenderPage(gfx, page);
            gfx.Dispose();

            metafile.Dispose();

            Process.Start("test.emf");
        }
예제 #8
0
 private void HandleAllThingsData(List <DeviceInfo> deviceInfos)
 {
     foreach (DeviceInfo info in deviceInfos)
     {
         //TODO updating device information could be useful someday
         //so we could just override all and update the ui?
         if (!DeviceInfos.ContainsKey(info.Uid))
         {
             DeviceInfos.Add(info.Uid, info);
         }
     }
 }
예제 #9
0
        /// <summary>
        /// 执法记录仪设备信息
        /// </summary>
        /// <param name="value"></param>
        private void AnalyzeDeviceInfos(string value)
        {
            App.Current.Dispatcher.Invoke(new Action(() =>
            {
                DeviceInfos deviceInfos = XmlUnityConvert.XmlDeserialize <DeviceInfos>(value);

                if (deviceInfos != null && deviceInfos.DeviveInfoList != null)
                {
                    DeviceInfoHelper.DeviceInfoAddOrUpdate(deviceInfos);
                }
            }));
        }
        // from https://stackoverflow.com/questions/6397457/get-wia-scanner-features

        public static DeviceInfo FindFirstScanner(DeviceManager manager)
        {
            DeviceInfos infos = manager.DeviceInfos;

            foreach (DeviceInfo info in infos)
            {
                if (info.Type == WiaDeviceType.ScannerDeviceType)
                {
                    return(info);
                }
            }
            return(null);
        }
예제 #11
0
        /// <summary>
        /// Gets the device informations for the given thing id.
        /// First the cached devices data is queried. If no device info for the given uid was found, a web request is executed to get the latest device data.
        /// </summary>
        /// <param name="thingId">thing id</param>
        /// <param name="handleDeviceInfo">the callback method</param>
        public void GetDeviceInfo(string thingId, Action <DeviceInfo> handleDeviceInfo)
        {
            DeviceInfo outValue = null;

            if (!DeviceInfos.TryGetValue(thingId, out outValue))
            {
                StartCoroutine(RequestAllThings(thingId, handleDeviceInfo));
            }
            else
            {
                handleDeviceInfo(outValue);
            }
        }
예제 #12
0
        private void chooseScanner()
        {
            DeviceManager deviceManager = new DeviceManager();
            DeviceInfos   devices       = deviceManager.DeviceInfos;

            for (int i = 1; i <= devices.Count; i++)
            {
                DeviceInfo device = devices[i];

                if (device.Type == WiaDeviceType.ScannerDeviceType && device.Properties["Name"].get_Value() == comboBox1.SelectedItem.ToString())
                {
                    scanner = device;
                    break;
                }
            }
        }
예제 #13
0
        internal PlatformInfo(int index)
        {
            Index = index;

            // get a platform
            uint count = 0;

            OpenCL.clGetPlatformIDs(0, null, &count).CheckError();
            var   platforms = (void **)Marshal.AllocCoTaskMem((int)(count * IntPtr.Size));
            void *platform;

            try
            {
                OpenCL.clGetPlatformIDs(count, platforms, &count).CheckError();
                platform = platforms[index];
            }
            finally
            {
                Marshal.FreeCoTaskMem(new IntPtr(platforms));
            }

            // get platform infos
            foreach (cl_platform_info info in Enum.GetValues(typeof(cl_platform_info)))
            {
                var size = new IntPtr();
                OpenCL.clGetPlatformInfo(platform, info, IntPtr.Zero, null, &size).CheckError();
                byte[] value = new byte[(int)size];
                fixed(byte *valuePointer = value)
                {
                    OpenCL.clGetPlatformInfo(platform, info, size, valuePointer, null).CheckError();
                    infos.Add(Enum.GetName(typeof(cl_platform_info), info), value);
                }
            }

            // get devices
            var deviceIdStatus = OpenCL.clGetDeviceIDs(platform, cl_device_type.CL_DEVICE_TYPE_ALL, 0, null, &count);

            IsDeviceInfoObtainable = !deviceIdStatus.HasError();
            if (IsDeviceInfoObtainable)
            {
                // create device infos
                for (int i = 0; i < count; i++)
                {
                    DeviceInfos.Add(new DeviceInfo(platform, i));
                }
            }
        }
예제 #14
0
 /// <summary>
 /// 执法记录仪信息更新或者添加
 /// </summary>
 /// <param name="deviceInfos"></param>
 public static void DeviceInfoAddOrUpdate(DeviceInfos deviceInfos)
 {
     foreach (var item in deviceInfos.DeviveInfoList)
     {
         DeviveInfo deviveInfo = GatherViewModel.DeviveInfoList.Find(p => p.DeviceCode.Equals(item.DeviceCode));
         if (deviveInfo == null)
         {
             // 添加
             GatherViewModel.DeviveInfoList.AddItem(item);
         }
         else
         {
             // 更新
             item.ValueCloneToObject(deviveInfo);
         }
     }
 }
예제 #15
0
        private void InstantiateExisitingDevices()
        {
            if (initializedExisitingDevices)
            {
                return;
            }

            initializedExisitingDevices = true;

            if (WorldAnchorManager.IsInitialized)
            {
                foreach (string anchorId in WorldAnchorManager.Instance.AnchorStore.GetAllIds())
                {
                    DeviceInfo info = null;
                    DeviceInfos.TryGetValue(anchorId, out info);
                    if (info == null)
                    {
                        Debug.LogErrorFormat("device with anchor id '{0}' not found\n removing from AnchorManager...", anchorId);
                        if (WorldAnchorManager.IsInitialized)
                        {
                            WorldAnchorManager.Instance.RemoveAnchor(anchorId);
                        }
                    }
                    else
                    {
                        DeviceSpawner.Instance.SpawnDevice(anchorId, e =>
                        {
                            if (e != null)
                            {
                                Debug.LogFormat("spawned exisiting device with id '{0}'", anchorId);
                            }
                            else
                            {
                                Debug.LogErrorFormat("failed to spawn exisiting device with anchor id '{0}'\n removing from AnchorManager...", anchorId);
                                if (WorldAnchorManager.IsInitialized)
                                {
                                    WorldAnchorManager.Instance.RemoveAnchor(anchorId);
                                }
                            }
                        });
                    }
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Requests all things data from th SAL. If thingUid and callback action added, the callback is called with the device data.
        /// </summary>
        private IEnumerator RequestAllThings(string thingUid = null, Action <DeviceInfo> handleDeviceInfo = null)
        {
            var request = new AllThingsRequest(openhabUri, HandleAllThingsData);

            yield return(request.ExecuteRequest());

            if (thingUid != null)
            {
                DeviceInfo outInfo = null;
                if (!DeviceInfos.TryGetValue(thingUid, out outInfo))
                {
                    Debug.LogErrorFormat("device info not found for uid '{0}'", thingUid);
                }
                handleDeviceInfo?.Invoke(outInfo);
            }

            //instantiate devices, which have an anchor stored on the hololens
            InstantiateExisitingDevices();
        }
예제 #17
0
        private void button1_Click(object sender, EventArgs e)
        {
            DeviceManager deviceManager = new DeviceManager();
            DeviceInfos   devices       = deviceManager.DeviceInfos;

            for (int i = 1; i <= devices.Count; i++)
            {
                DeviceInfo device = devices[i];

                if (device.Type == WiaDeviceType.ScannerDeviceType)
                {
                    comboBox1.Items.Add(device.Properties["Name"].get_Value());
                }
            }

            if (comboBox1.Items.Count > 0)
            {
                comboBox1.SelectedIndex = 0;
            }
        }
예제 #18
0
        public void connect_Device()
        {
            // CloseScanner();
            //Thread.Sleep(1000);
            //string deviceName = "FG_ZF10";
            DeviceIdentity selectedDI = new DeviceIdentity(); //Get selected Frame-Grabber

            selectedDI = DeviceIdentity.FG_ZF10;              //Get selected Frame-Grabber
            //DeviceIdentity selectedDI = (DeviceIdentity)xamlListBoxFG.SelectedItem; //Get selected Frame-Grabber
            //this.SelectedDeviceIdentity = selectedDI;

            DeviceInformations[] dinfos = FPScanner.GetAttachedDevices(selectedDI); //Get all Fingerprint Scanners
            DeviceInformations   dinfo  = dinfos.First();
            DeviceInfos          di     = new DeviceInfos(dinfo.index, dinfo.name);

            FingerPrintScanner = FPScanner.GetFPScanner(selectedDI, di.Index);

            //_fpScanner = FingerPrintScanner;
            ////use any assembly versions

            //RedirectAssembly("Dermalog.Imaging.Capturing");
            //RedirectAssembly("Dermalog.AFIS.FourprintSegmentation");
            //RedirectAssembly("Dermalog.AFIS.TwoPprintSegmentation");

            //RedirectAssembly("Dermalog.Afis.NistQualityCheck");
            //RedirectAssembly("Dermalog.AFIS.FingerCode3");



            //_afis = new LocalAFIS();
            //// DisplayMessage("Loading user database");
            // // lbStorage.Text = "Storage: " + _afis.StoragePath;
            // //toolTip1.SetToolTip(lbStorage, _afis.StoragePath);


            // //lbStorage.ToolTip = _afis.StoragePath;

            // UpdateUserList();
            //EnableGUI(false);
            //Thread.Sleep(500);
        }