예제 #1
0
        /// <summary>
        /// Sets Paperless Print Mode to ON or OFF on the device
        /// </summary>
        /// <param name="paperlessModeOn"></param>
        /// <returns></returns>
        private bool SetPaperlessPrintMode(string ipAddress, string adminPassword)
        {
            JobMediaMode mode    = PaperlessModeOn ? JobMediaMode.Paperless : JobMediaMode.Paper;
            bool         success = false;

            try
            {
                using (var device = DeviceFactory.Create(ipAddress, adminPassword))
                {
                    try
                    {
                        IDeviceSettingsManager manager = DeviceSettingsManagerFactory.Create(device);
                        success = manager.SetJobMediaMode(mode);
                    }
                    catch (DeviceFactoryCoreException)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(success);
        }
예제 #2
0
        public override unsafe void Initialize(Size data, IOutputOwner output)
        {
            using var factory = DeviceFactory.Create();
            foreach (var device in factory)
            {
                Console.WriteLine(device);
            }

            _device = GraphicsDevice.Create(FeatureLevel.GraphicsLevel11_0, null);

            var desc = new OutputConfiguration
            {
                BackBufferFormat = BackBufferFormat.R8G8B8A8UnsignedNormalized,
                BackBufferCount  = 3,
                SyncInterval     = 0
            };

            _output = Output.Create(desc, _device, output);

            _settings = new PipelineSettings
            {
                Msaa        = MsaaDesc.None,
                Resolution  = _output.Resolution,
                AspectRatio = _output.AspectRatio
            };


            _renderer   = new BasicSceneRenderer(_device);
            _msaaPass   = new MsaaPass();
            _outputPass = new TonemapPass(_output);

            _graph = new RenderGraph(_device, _output.Configuration.BackBufferCount);
        }
예제 #3
0
        /// <summary>
        /// Creates an <see cref="IDevice"/> object for the specified <see cref="IDeviceInfo"/> object.
        /// </summary>
        /// <param name="deviceInfo">The device information from Asset Inventory.</param>
        /// <returns></returns>
        public static IDevice Create(Framework.Assets.IDeviceInfo deviceInfo)
        {
            if (deviceInfo == null)
            {
                throw new ArgumentNullException(nameof(deviceInfo));
            }

            DeviceConstructionParameterCollection parameters = new DeviceConstructionParameterCollection()
            {
                new DeviceAddressParameter(deviceInfo.Address),
                new DeviceAdminPasswordParameter(deviceInfo.AdminPassword)
            };

            if (string.IsNullOrEmpty(deviceInfo.Address2))
            {
                LogDebug($"Creating DAT controller for device at {deviceInfo.Address}.  Admin password: '******'");
            }
            else
            {
                parameters.Add(new JediDebugAddressParameter(deviceInfo.Address2));
                LogDebug($"Creating DAT controller for device at {deviceInfo.Address} with debug LAN {deviceInfo.Address2}.  Admin password: '******'");
            }

            return(DeviceFactory.Create(parameters));
        }
예제 #4
0
        private void CheckAndWaitForDeviceReboot(Framework.Assets.IDeviceInfo printdeviceinfo)
        {
            int maxRetries = 20;
            var device     = DeviceFactory.Create(printdeviceinfo.Address, printdeviceinfo.AdminPassword);

            if (Retry.UntilTrue(() => HasDeviceRebooted(device), maxRetries / 2, TimeSpan.FromSeconds(10)))
            {
                UpdateStatus("Device has rebooted...");
                if (Retry.UntilTrue(() => IsDeviceRunning(device), maxRetries, TimeSpan.FromSeconds(10)))
                {
                    UpdateStatus("Device is in Running status...");
                    if (Retry.UntilTrue(() => IsJetDirectUp(device), maxRetries / 4, TimeSpan.FromSeconds(10)))
                    {
                        UpdateStatus("JetDirect Initialised...");
                    }

                    if (Retry.UntilTrue(() => IsWebServicesUp(device), (maxRetries / 4), TimeSpan.FromSeconds(10)))
                    {
                        UpdateStatus("Device is in Ready state.");
                    }
                }
            }
            else
            {
                UpdateStatus("Device has not rebooted.");
            }
        }
예제 #5
0
        /// <summary>
        /// Entry point into the WS* process.
        /// Endpoint: address book, email, FIM, ...
        /// Resource URL: urn:hp:imaging:con:service:email:EmailService
        ///
        /// The call to WSTranferClient.Get will return an XML string of data.36030
        /// </summary>
        /// <param name="endPoint">string</param>
        /// <param name="resourceUri">string</param>
        /// <returns>XElement</returns>
        public XElement GetEndPointLog(string endPoint, string resourceUri)
        {
            XElement xeDeviceData = null;

            JediDevice jedi = DeviceFactory.Create(IPAddress, Password) as JediDevice;

            if (jedi != null)
            {
                try
                {
                    xeDeviceData = jedi.WebServices.GetDeviceTicket(endPoint, resourceUri);
                }
                catch (DeviceCommunicationException dce)
                {
                    if (dce.InnerException != null)
                    {
                        if (!dce.InnerException.GetType().Equals(typeof(System.ServiceModel.EndpointNotFoundException)) && !dce.InnerException.GetType().Equals(typeof(System.ServiceModel.ProtocolException)))
                        {
                            throw;
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to communicate with IP Address " + IPAddress + "\n\r" + dce.Message);
                    }
                }
                catch (EntryPointNotFoundException nf)
                {
                    throw new Exception("Unable to communicate with IP Address " + IPAddress + "\n\r" + nf.Message);
                }
            }
            return(xeDeviceData);
        }
예제 #6
0
        public static void Main(string[] args)
        {
            var d = new DeviceA("asdfsdf");

            DeviceFactory.Create(d, "asdfsdf");

            Console.ReadKey();
        }
예제 #7
0
        public static void SetPaperlessMode(IPAddress ipaddress, bool paperlessModeOn)
        {
            JobMediaMode mode = paperlessModeOn ? JobMediaMode.Paperless : JobMediaMode.Paper;

            using (IDevice device = DeviceFactory.Create(ipaddress, "!QAZ2wsx"))
            {
                IDeviceSettingsManager manager = DeviceSettingsManagerFactory.Create(device);
                manager.SetJobMediaMode(mode);
            }
            Console.WriteLine(string.Format("Paperless mode was turned {0}.", paperlessModeOn ? "on" : "off"));
        }
예제 #8
0
        void locator_DeviceStatusUpdate(object sender, DiscoveredEventArgs e)
        {
            SimpleHttpClient client  = new SimpleHttpClient();
            DeviceFactory    factory = new DeviceFactory(client);
            var device = factory.Create(new Uri(e.Device.Location));

            if (device == null)
            {
                return;
            }
            devicesList.Add(device);
            foundDevices.Enqueue(device);
        }
예제 #9
0
파일: Program.cs 프로젝트: ejbaling/HomeApi
        static void Main(string[] args)
        {
            device = DeviceFactory.Create <Arduino>();
            // device = DeviceFactory.Create<RaspberryPi>();

            SetTimer();

            Console.WriteLine("\nPress the Enter key to exit the application...\n");
            Console.WriteLine("The application started at {0:HH:mm:ss.fff}", DateTime.Now);
            CheckHumidity();
            Console.ReadLine();
            timer.Stop();
            timer.Dispose();

            Console.WriteLine("Terminating the application...");
        }
예제 #10
0
        private void AuthenticateOmni(string deviceIP, string userName)
        {
            IDevice device = DeviceFactory.Create(deviceIP, "!QAZ2wsx");
            //AuthenticationCredential credential = new AuthenticationCredential(userName, "1qaz2wsx", "etl.boi.rd.hpicorp.net");
            AuthenticationCredential credential = new AuthenticationCredential("03000");

            JediOmniPreparationManager prepMgr = new JediOmniPreparationManager(((JediOmniDevice)device));
            JediOmniLaunchHelper       helper  = new JediOmniLaunchHelper((JediOmniDevice)device);

            // Set up the device for Authentication
            prepMgr.Reset();
            helper.PressSignInButton();

            IAuthenticator authenticator = AuthenticatorFactory.Create(device, credential, AuthenticationProvider.Auto);

            authenticator.Authenticate();
        }
예제 #11
0
        public static void SetPaperlessMode(string address, string adminPassword, bool paperlessModeOn)
        {
            JobMediaMode mode = paperlessModeOn ? JobMediaMode.Paperless : JobMediaMode.Paper;

            IPAddress ipaddress;

            if (IPAddress.TryParse(address, out ipaddress))
            {
                using (IDevice device = DeviceFactory.Create(ipaddress, adminPassword))
                {
                    IDeviceSettingsManager manager = DeviceSettingsManagerFactory.Create(device);
                    manager.SetJobMediaMode(mode);
                }
                MessageBox.Show(string.Format("Paperless mode was turned {0}.", paperlessModeOn ? "on" : "off"));
            }
            else
            {
                MessageBox.Show("IP address was invalid.");
            }
        }
예제 #12
0
        public IDeviceGroup Create(DeviceGroupConfig deviceGroupConfig)
        {
            var deviceGroup = ServiceLocator.GetInstance <IDeviceGroup>();

            deviceGroup.Name = deviceGroupConfig.Name;

            foreach (var deviceConfig in deviceGroupConfig.DeviceConfigCollection)
            {
                var device = DeviceFactory.Create(deviceConfig);
                deviceGroup.Devices.Add(device);
            }

            foreach (var subDeviceGroupConfig in deviceGroupConfig.GroupConfigCollection)
            {
                var subDeviceGroup = Create(subDeviceGroupConfig);
                deviceGroup.DeviceGroups.Add(subDeviceGroup);
                subDeviceGroup.Parent = deviceGroup;
            }

            return(deviceGroup);
        }
예제 #13
0
        private static async Task MainAsync()
        {
            var options = new DeviceOptions
            {
                MeasurementSecondsInterval = 1m
            };

            var devices = new List <IDevice>();

            for (var i = 0; i < 1000; i++)
            {
                devices.Add(DeviceFactory.Create(options));
            }

            // set event handler
            foreach (var device in devices.AsParallel())
            {
                device.TemperaturaMeasurement += Device_TemperaturaMeasurement;
            }

            var starts = devices.Select(c => c.On());
            await Task.WhenAll(starts);
        }
예제 #14
0
        private void AuthenticateWindjammer(string deviceIP, string userName)
        {
            IDevice device = DeviceFactory.Create(deviceIP, "!QAZ2wsx");
            AuthenticationCredential credential = new AuthenticationCredential(userName, "1qaz2wsx", "etl.boi.rd.hpicorp.net");

            JediWindjammerPreparationManager prepMgr      = new JediWindjammerPreparationManager(((JediWindjammerDevice)device));
            JediWindjammerControlPanel       controlPanel = ((JediWindjammerDevice)device).ControlPanel;

            // Set up the device for Authentication
            //prepMgr.Reset();
            controlPanel.PressWait(JediWindjammerLaunchHelper.SIGNIN_BUTTON, JediWindjammerLaunchHelper.SIGNIN_FORM);

            //IEnumerable<string> controls = controlPanel.GetControls();
            //foreach (string s in controls)
            //{
            //    System.Diagnostics.Debug.WriteLine(s);
            //}


            IAuthenticator authenticator = AuthenticatorFactory.Create(device, credential, AuthenticationProvider.Auto);

            authenticator.Authenticate();
        }
예제 #15
0
        public bool ValidateEngine()
        {
            GetLastError = string.Empty;

            try
            {
                _device = DeviceFactory.Create(IPAddress, Password);
                WakeDevice();
                ReleaseName = _device.GetDeviceInfo().ModelName;
            }
            catch (DeviceCommunicationException dce)
            {
                GetLastError = dce.Message;
            }
            catch (UnknownDeviceTypeException udte)
            {
                GetLastError = udte.Message;
            }
            catch (Exception ex)
            {
                GetLastError = ex.JoinAllErrorMessages();
            }
            return(!IsError);
        }
예제 #16
0
        public ControlPanelUtility(IPAddress address)
        {
            IDevice device = DeviceFactory.Create(address);

            _phoenixNovaDevice = device as PhoenixNovaDevice;
        }
예제 #17
0
        /// <summary>
        /// Execute the task of the DeviceConfiguration activity.
        /// </summary>
        /// <param name="executionData"></param>
        /// <returns></returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _executionData = executionData;
            _activityData  = executionData.GetMetadata <DeviceInspectorActivityData>();
            TimeSpan lockTimeout = TimeSpan.FromMinutes(5);
            TimeSpan holdTimeout = TimeSpan.FromMinutes(5);
            ConcurrentDictionary <string, DataPair <string> > verifiedResults = new ConcurrentDictionary <string, DataPair <string> >();

            if (!_executionData.Assets.OfType <IDeviceInfo>().Any())
            {
                return(new PluginExecutionResult(PluginResult.Failed, "There were no assets retrieved.  If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error"));
            }

            ExecutionServices.SystemTrace.LogDebug("Beginning Update");

            try
            {
                //Parallel.ForEach(_executionData.Assets.OfType<IDeviceInfo>(),asset =>
                foreach (var asset in _executionData.Assets.OfType <IDeviceInfo>())
                {
                    JediDevice device = null;
                    try
                    {
                        try
                        {
                            device = DeviceConstructor.Create(asset) as JediDevice;
                        }
                        catch
                        {
                            device = DeviceFactory.Create(asset.Address) as JediDevice;
                        }

                        // Make sure the device is in a good state
                        var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                        try
                        {
                            devicePrepManager.InitializeDevice(true);
                        }
                        catch (WebInspectorException webInspectorException)
                        {
                            //let's ignore initialise device errors, this might be due to inspection page in use,
                            //since we are not doing any control panel action, this should be ok
                            ExecutionServices.SystemTrace.LogDebug(webInspectorException.Message);
                        }


                        ExecutionServices.SystemTrace.LogDebug(
                            $"Processing {asset.AssetId} on thread {Thread.CurrentThread}");

                        AssetLockToken assetToken = new AssetLockToken(asset, lockTimeout, holdTimeout);

                        ExecutionServices.CriticalSection.Run(assetToken, () =>
                        {
                            ExecutionServices.SystemTrace.LogDebug(
                                $"Performing update on device {asset.AssetId} at address {asset.Address}");
                            var verifiedResult = UpdateDevice(device, asset);
                            verifiedResults.AddOrUpdate(asset.AssetId, verifiedResult, (key, oldvalue) => UpdateDevice(device, asset));
                        });
                    }
                    catch (DeviceCommunicationException deviceCommunicationException)
                    {
                        ExecutionServices.SystemTrace.LogDebug($"Unable to communicate with the device: {deviceCommunicationException.Message}");
                        verifiedResults.AddOrUpdate(asset.AssetId,
                                                    new DataPair <string> {
                            Key = "Device Communication", Value = false
                        },
                                                    (s, pair) => new DataPair <string>()
                        {
                            Key = "Device Communication", Value = false
                        });
                        device?.Dispose();
                    }
                    catch (Exception e)
                    {
                        ExecutionServices.SystemTrace.LogDebug(e);
                        verifiedResults.AddOrUpdate(asset.AssetId,
                                                    new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        },
                                                    (s, pair) => new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        });
                        device?.Dispose();
                    }
                }
            }
            catch
            {
                return(new PluginExecutionResult(PluginResult.Error, "Error during Device Configuration Setup"));
            }

            foreach (var verifiedResult in verifiedResults)
            {
                UpdateStatus($"Device: {verifiedResult.Key} Result: {verifiedResult.Value.Value}, {verifiedResult.Value.Key}");
            }

            if (verifiedResults.Any(x => x.Value.Value == false))
            {
                return(new PluginExecutionResult(PluginResult.Failed));
            }


            return(new PluginExecutionResult(PluginResult.Passed));
        }
        /// <summary>
        /// Execute the task of the DeviceConfiguration activity.
        /// </summary>
        /// <param name="executionData"></param>
        /// <returns></returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            //bool result = false;
            _executionData = executionData;
            _activityData  = executionData.GetMetadata <DeviceConfigurationActivityData>();
            TimeSpan lockTimeout = TimeSpan.FromMinutes(10);
            TimeSpan holdTimeout = TimeSpan.FromMinutes(20);
            ConcurrentDictionary <string, DataPair <string> > results = new ConcurrentDictionary <string, DataPair <string> >();

            if (!_executionData.Assets.OfType <IDeviceInfo>().Any())
            {
                return(new PluginExecutionResult(PluginResult.Failed, "There were no assets retrieved.  If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error"));
            }

            ExecutionServices.SystemTrace.LogDebug("Beginning Update");

            try
            {
                //Parallel.ForEach(_executionData.Assets.OfType<IDeviceInfo>(), asset =>
                foreach (var asset in _executionData.Assets.OfType <IDeviceInfo>())
                {
                    JediDevice device = null;
                    try
                    {
                        //DeviceConfigResultLog log = new DeviceConfigResultLog(_executionData, asset.AssetId);
                        SetDefaultPassword(asset.Address, asset.AdminPassword);

                        try
                        {
                            device = DeviceConstructor.Create(asset) as JediDevice;
                        }
                        catch
                        {
                            device = DeviceFactory.Create(asset.Address) as JediDevice;
                        }

                        // Make sure the device is in a good state
                        var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                        try
                        {
                            devicePrepManager.InitializeDevice(true);
                        }
                        catch (WebInspectorException webInspectorException)
                        {
                            //let's ignore initialise device errors, this might be due to inspection page in use,
                            //since we are not doing any control panel action, this should be ok
                            ExecutionServices.SystemTrace.LogDebug(webInspectorException.Message);
                        }

                        //devicePrepManager.PerformanceLogger = PerformanceLogger;

                        ExecutionServices.SystemTrace.LogDebug(
                            $"Processing {asset.AssetId} on thread {Thread.CurrentThread}");

                        AssetLockToken assetToken = new AssetLockToken(asset, lockTimeout, holdTimeout);

                        ExecutionServices.CriticalSection.Run(assetToken, () =>
                        {
                            ExecutionServices.SystemTrace.LogDebug(
                                $"Performing update on device {asset.AssetId} at address {asset.Address}");
                            var result = UpdateDevice(device, (AssetInfo)asset, _executionData);
                            results.AddOrUpdate(asset.AssetId, result,
                                                (key, oldValue) => UpdateDevice(device, (AssetInfo)asset, _executionData));
                            device?.Dispose();
                        });
                    }
                    catch (DeviceCommunicationException deviceCommunicationException)
                    {
                        ExecutionServices.SystemTrace.LogDebug($"Unable to communicate with the device: {deviceCommunicationException.Message}");
                        results.AddOrUpdate(asset.AssetId,
                                            new DataPair <string> {
                            Key = "Device Communication", Value = false
                        },
                                            (s, pair) => new DataPair <string>()
                        {
                            Key = "Device Communication", Value = false
                        });
                        device?.Dispose();
                    }
                    catch (Exception e)
                    {
                        ExecutionServices.SystemTrace.LogDebug(e);
                        results.AddOrUpdate(asset.AssetId,
                                            new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        },
                                            (s, pair) => new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        });
                        //[Veda]:we had few in use inspection pages error in subsequent plugin/activities, which was as a result of this plugin failing
                        //eg: invalid xml content. disposing the device to avoid those problems
                        device?.Dispose();
                    }
                }//);
            }
            catch
            {
                return(new PluginExecutionResult(PluginResult.Error, "Error during Device Configuration Setup"));
            }

            foreach (var item in results)
            {
                UpdateStatus($"Device {item.Key}: Result: {item.Value.Value}, {item.Value.Key}");
            }

            if (results.Any(x => x.Value.Value == false))
            {
                return(new PluginExecutionResult(PluginResult.Failed));
            }


            return(new PluginExecutionResult(PluginResult.Passed));
        }