Esempio n. 1
0
        private void initMirror(DeviceDescription<VioletMirror> description)
        {
            if (description.IsInUse)
            {
                DialogResult result;
                do
                {
                    mirDetectTimer.Stop();
                    result = MessageBox.Show(this, "Your mir:ror is in use by another program - please stop that program and try again.", Globals.errorTitle, MessageBoxButtons.RetryCancel,
                                    MessageBoxIcon.Error);
                    if (result == DialogResult.Cancel && description.IsInUse)
                    {
                        cleanExit();
                    }
                }
                while (result == DialogResult.Retry && description.IsInUse);
                mirDetectTimer.Start();
            }
            // Disposing old instance to ensure it's free
            if (Mirror != null) Mirror.Dispose();
            Mirror = null;

            Mirror = description.Create();
            Mirror.DataRecieved += OnDataRecieved;
            Mirror.TagShown += OnTagShown;
            Mirror.TagHid += OnTagHid;
            Mirror.OrientationChanged += OnOrientationChanged;
            Mirror.DeviceRemoved += OnDeviceRemoved;
            OnOrientationChangedMethod(Mirror.GetOrientation());
            mirDetectTimer.Stop();
            isMirConnected = true;
            updateStatusMarkers();
        }
Esempio n. 2
0
        /// <summary>
        /// Starts input
        /// </summary>
        /// <param name="device">Device object</param>
        /// <param name="ProtocolClass">Class of device to operate with</param>
        /// <param name="DataType">Type of data to input</param>
        /// <param name="InputTask">Data processing task</param>
        /// <param name="ErrorMessage">Error</param>
        /// <returns>Returns true if device was succesfully started and stopped </returns>
        public static bool Launch(DeviceInput device,
                                  ProtocolClassID ProtocolClass,
                                  string PrefferedSerialNumber,
                                  InputDataType DataType,
                                  DeviceInputTask InputTask,
                                  ref string ErrorMessage)
        {
            if (Running == true)
            {
                return(false);
            }

            try
            {
                Running = true;
                if (device == null)
                {
                    ErrorMessage = "Device is null";
                    return(false);
                }


                #region Getting library versions
                //Getting HAL library Version information
                int Version = 0, Release = 0;
                device.GetHALVersion(ref Version, ref Release);
                Console.WriteLine("Mitsar.HAL version: {0}.{1}", Version, Release);
                Console.WriteLine();
                Console.WriteLine("Assemblies_____________");
                Console.WriteLine(GetAssemblyDescription("Mitsar.Essentials"));
                Console.WriteLine(GetAssemblyDescription("Mitsar.HAL"));
                Console.WriteLine();
                #endregion


                #region Getting available hardware and selecting device
                DeviceDescription SelectedDescription = null;

                //Detecting Hardware
                List <DeviceDescription> descriptions = new List <DeviceDescription>();

                Console.WriteLine("Enumerating devices for protocol " + ProtocolClass);
                device.Enumerate(HardwareClassID.EEG, ProtocolClass, ref descriptions);

                //Showing all discovered devices

                if (descriptions != null)
                {
                    Console.WriteLine("Devices found ______________");

                    foreach (DeviceDescription desc in descriptions)
                    {
                        Console.WriteLine(desc.ToString());
                        Console.WriteLine("Driver Name: " + desc.GetDeviceDriverName());
                        Console.WriteLine("Driver SerialNumber: " + desc.DriverSerialNumber);
                        Console.WriteLine("State: " + desc.State.ToString());
                        Console.WriteLine();
                    }
                }
                else
                {
                    ErrorMessage = "No devices found";
                    return(false);
                }

                Console.WriteLine("________________________");
                //Selecting device description
                if (descriptions.Count == 0)
                {
                    ErrorMessage = "Error: No devices found";
                    return(false);
                }
                else
                {
                    if (string.IsNullOrEmpty(PrefferedSerialNumber) == false)
                    {
                        Console.Write("Searching for device with serial number " + PrefferedSerialNumber + "...");

                        //Choosing EEG Device
                        foreach (DeviceDescription desc in descriptions)
                        {
                            if (desc.DriverSerialNumber == PrefferedSerialNumber)
                            {
                                SelectedDescription = desc;
                                break;
                            }
                        }

                        if (SelectedDescription != null)
                        {
                            Console.WriteLine(" found " + SelectedDescription.ToString());
                        }
                        else
                        {
                            Console.WriteLine(" not found");
                        }
                    }


                    if (SelectedDescription == null)
                    {
                        Console.Write("Searching for any device...");
                        //Choosing EEG Device
                        foreach (DeviceDescription desc in descriptions)
                        {
                            if (desc.HardwareClass == HardwareClassID.EEG)
                            {
                                SelectedDescription = desc;
                                break;
                            }
                        }

                        if (SelectedDescription != null)
                        {
                            Console.WriteLine(" found " + SelectedDescription.ToString());
                        }
                        else
                        {
                            Console.WriteLine(" not found");
                        }
                    }

                    if (SelectedDescription == null)
                    {
                        ErrorMessage = "Error: No devices found";
                        return(false);
                    }
                }
                #endregion


                #region Opening, Powering and detecting device version
                //Opening HAL
                Console.Write("Opening...");
                if (device.Open(SelectedDescription) == true)
                {
                    Console.WriteLine("OK");
                }
                else
                {
                    return(false);
                }


                //Powering HAL
                Console.Write("Powering...");
                if (device.PowerOn() == true)
                {
                    Console.WriteLine("OK");
                }
                else
                {
                    return(false);
                }


                //Identifying HAL
                Console.Write("Indentifing...");
                if (device.Identify() == true)
                {
                    Console.WriteLine("OK");
                }
                else
                {
                    return(false);
                }


                if (device.ActiveDeviceDescription.Resource.Version == 0)
                {
                    ErrorMessage = "Error: Unknown version " + device.ActiveDeviceDescription.Resource.ReservedVersion;
                    return(false);
                }

                Console.WriteLine();
                Console.WriteLine("Device vendor: " + device.ActiveDeviceDescription.Resource.Vendor);
                Console.WriteLine("Device version: " + device.ActiveDeviceDescription.Resource.Version);
                Console.WriteLine("Device serial number: " + device.ActiveDeviceDescription.Resource.SerialNumber);
                #endregion


                #region Loading and setting up calibration
                Console.Write("Getting calibration...");
                Resource_MultiChannel mresource       = device.ActiveDeviceDescription.Resource as Resource_MultiChannel;
                //If internal device calibration is supported
                if (mresource.IsROMSupported() == true)
                {//ROM supported - reading from ROM
                    byte[] buf = null;

                    //Reading calibration data from device's memory to buffer
                    if (device.ReadMemory(ref buf) == true)
                    {//if ROM read successfully - transfer to calibration
                        //Decoding buffer to calibtaion data
                        CalibrationProfileIOResult result = CalibrationProfile.ReadFromBuffer(ref device.ActiveDeviceDescription.Calibration, mresource, buf);
                        if (result == CalibrationProfileIOResult.OK) //Translate OK
                        {
                            //After successfull read version and serial must be assigned to CalibrationFile
                            device.ActiveDeviceDescription.Calibration.Parameters.Version          = device.ActiveDeviceDescription.Resource.Version;
                            device.ActiveDeviceDescription.Calibration.Parameters.FullSerialNumber = device.ActiveDeviceDescription.Resource.SerialNumber;
                            //Serial is not validated because received from already validated device resource
                            Console.WriteLine("OK");
                        }
                        else  //ROM translate or check sum error
                        {
                            device.ActiveDeviceDescription.Calibration.Clear();
                        }
                    }//ROM Access error
                    else
                    {
                        device.ActiveDeviceDescription.Calibration.Clear();
                    }
                }//if ROM supported
                else
                {
                    Console.WriteLine(" not supported");
                }

                Console.WriteLine("");
                //else calibration must be read from calibration file eeg.cal
                //CalibrationFile.Read(ref device.ActiveDeviceDescription.Calibration, "eeg.cal");
                #endregion


                #region Configuring device
                //Setting input mode to global input mode. EEG(data) or Impedance
                mresource.DataType = DataType;

                //Test signal mode disabled
                mresource.TestSignal = false;

                //Setting up referent operation mode
                //Getting list of supported referent types
                List <ReferentOperationMode> RefModeList = mresource.GetReferentOperationModeList(false);
                Console.Write("Supported referents: ");
                foreach (ReferentOperationMode refmode in RefModeList)
                {
                    Console.Write(refmode + " ");
                }
                Console.WriteLine();
                //Selecting first supported mode
                //mresource.EmitterFactory.RefMode = ReferentOperationMode.RefElectrode;
                //mresource.EmitterFactory.RefMode = ReferentOperationMode.Joined;
                //RefModeList[0];

                mresource.EmitterFactory.RefMode = RefModeList[0];

                mresource.EmitterFactory.ImpedanceChannelEnabled     = true;
                mresource.EmitterFactory.AccelerometerChannelEnabled = true;


                //Setting up sampling frequency
                //GEtting list of supported sampling frequencies
                List <double> FreqList                = mresource.GetSamplingFrequencyList(false);
                Console.Write("Supported frequencies: ");
                foreach (double freq in FreqList)
                {
                    Console.Write(freq + " ");
                }
                Console.WriteLine();

                //Selecting first frequency in list, generally nominal
                //int SamplingFrequency = (int)mresource.GetNominalSamplingFrequency();
                int SamplingFrequency = (int)FreqList[0];
                mresource.EmitterFactory.SamplingFrequency = SamplingFrequency;

                //Setting other data buffer parameters
                //Getting BYTES PER SAMPLE FROM FIRST ENCOUNTERED DATA CHANNEL
                mresource.DataBuffer.BytesPerTick = mresource.Interface_GetBytesPerSample(UID.NOP);

                mresource.DataBuffer.TicksMin  = 2;
                mresource.DataBuffer.TicksMax  = 100;
                mresource.DataBuffer.TicksSkip = 10;// 10;


                //Enable Front panel LED in Impedace Test mode
                mresource.FrontLedEnabled         = true;
                mresource.FrontLedThesholdEnabled = false;

                //Set edge value, can be changed in any time
                //All impedances above this value will be highligted
                //Only 5, 10, 20, 40 values are indicated
                mresource.FrontLedThesholdValue = 10;

                Console.WriteLine();
                #endregion


                #region Starting data input
                Console.Write("Starting...");
                if (device.Start() == true)
                {
                    Console.WriteLine("OK");
                }
                else
                {
                    return(false);
                }


                Console.WriteLine("Emitters__________________");
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("UID\tIndex\tAlign\tBPS\tHigh\tLow\tNotch\tUnitsPerSample");

                foreach (EmitterDescription emm in mresource.EmitterFactory)
                {
                    sb.Append(emm.UID.ToString());
                    sb.Append("\t");
                    sb.Append(emm.HardwareIndex.ToString());
                    sb.Append("\t");
                    sb.Append(emm.Align.ToString());
                    sb.Append("\t");
                    sb.Append(emm.BytesPerSample.ToString());
                    sb.Append("\t");
                    sb.Append(emm.HardHighPass.ToString());
                    sb.Append("\t");
                    sb.Append(emm.HardLowPass.ToString());
                    sb.Append("\t");
                    sb.Append(emm.HardNotch.ToString());
                    sb.Append("\t");
                    sb.Append(emm.UnitsPerSample.ToString());
                    sb.AppendLine("\t");
                }
                Console.WriteLine(sb.ToString());


                Console.WriteLine("Calibration_____________");
                //sb.Clear();
                foreach (EmitterDescription emm in mresource.EmitterFactory)
                {
                    sb.Append(emm.UID.ToString());
                    sb.Append("\t");

                    if (emm.CalEntryLink != null)
                    {
                        sb.Append(emm.CalEntryLink.ToString());
                        sb.Append("\t");
                    }
                    else
                    {
                        sb.Append(" no calibration");
                    }

                    sb.AppendLine("\t");
                }
                Console.WriteLine(sb.ToString());

                Console.WriteLine("Input parameters_____________");
                Console.WriteLine("Data Type: " + mresource.DataType.ToString());
                Console.WriteLine("Sampling Frequency: " + mresource.EmitterFactory.SamplingFrequency.ToString());

                Console.WriteLine("BytesPerTick: " + mresource.DataBuffer.BytesPerTick.ToString());
                Console.WriteLine("Minimum ticks to transmit: " + mresource.DataBuffer.TicksMin.ToString());
                Console.WriteLine("Maximum ticks to transmit: " + mresource.DataBuffer.TicksMax.ToString());

                Console.WriteLine("Internal number of channels: " + mresource.InputHardwareChannelCountInternal.ToString());
                Console.WriteLine("External number of channels: " + mresource.InputHardwareChannelCountExternal.ToString());
                Console.WriteLine();
                #endregion


                //Start Data asquisition task
                Console.WriteLine("Executing input task...");
                if (InputTask != null)
                {
                    InputTask();
                }


                bool DisplayImpedances = false;

                #region Displaying impedances
                if (DisplayImpedances)
                {
                    Console.WriteLine("----- EmitterFactory -----");
                    foreach (EmitterDescription em in mresource.EmitterFactory)
                    {
                        ///Console.WriteLine(em.UID + "\t RF=" + em.ImpedancePreliminaryValue + "\t R=" + em.ImpedanceResultValue);
                        Console.WriteLine(em.UID + "\t RValue=" + em.ImpedanceResultValue);//;;em.ImpedancePreliminaryValue + "\t R=" + em.ImpedanceResultValue);
                    }

                    Console.WriteLine("----- ImpedanceArray -----");
                    foreach (ImpedanceElement el in mresource.ImpedanceArray)
                    {
                        Console.WriteLine(el.LogicalUID +
                                          // " Name= " + el.Name +
                                          // " Active:" + el.Active +
                                          // " InMontage:" + el.PresentInMontage +
                                          //" REF:" + el.HardwareReferent +
                                          //  " LED:" + el.LedState + " (" + el.LedIndex + ")" +
                                          // " PVal:" + el.PreliminaryValue +
                                          "\t RValue:" + el.ResultValue);
                    }
                }
                #endregion


                #region Displaying power mode
                Console.WriteLine("Power mode: " + device.ActiveDeviceDescription.Resource.PowerMode);
                #endregion

                Console.WriteLine("Complete");
                return(true);
            }
            finally
            {
                //Memorizing error code
                HALErrorCode errorcode = device.HALError.Code;

                Running = false;

                #region Finalising device
                if (device != null)
                {
                    if (device.IsStarted)
                    {
                        Console.Write("Stopping...");
                        if (device.Stop() == true)
                        {
                            Console.WriteLine("OK");
                        }
                    }

                    if (device.IsPowered)
                    {
                        Console.Write("Powering off...");
                        if (device.PowerOff() == true)
                        {
                            Console.WriteLine("OK");
                        }
                    }

                    if (device.IsOpened)
                    {
                        Console.Write("Closing...");
                        if (device.Close() == true)
                        {
                            Console.WriteLine("OK");
                        }
                    }

                    if (errorcode != HALErrorCode.OK)
                    {
                        ErrorMessage = "Error: " + errorcode.ToString();
                    }
                }
                #endregion
            }
        }//Launch
 public static CcuDeviceInfo Create(DeviceDescription deviceDescription)
 {
     return(Mapper.Map <CcuDeviceInfo>(deviceDescription));
 }
 public bool ConfirmNewFrame(DeviceDescription description)
 {
     return(true);
 }
        public void DrawLine(Point source, Point destination, GraphicsContext context, DeviceDescription description)
        {
            var svgContext = _mapper.MapGraphicsContextToSvg(source, context);
            var end        = _mapper.MapPoint(destination, 0d);

            AddChild(new SvgLine
            {
                EndX            = end.X,
                EndY            = end.Y,
                Fill            = svgContext.Fill,
                FillOpacity     = svgContext.Opacity,
                StartX          = svgContext.Coordinate.X,
                StartY          = svgContext.Coordinate.Y,
                Stroke          = svgContext.Pen.Stroke,
                StrokeDashArray = svgContext.Pen.StrokeDashArray,
                StrokeLineCap   = svgContext.Pen.StrokeLineCap,
                StrokeLineJoin  = svgContext.Pen.StrokeLineJoin,
                StrokeWidth     = svgContext.Pen.StrokeWidth
            });
        }
Esempio n. 6
0
 public void DrawRaster(Raster raster, Rectangle destination, double rotation, bool interpolated, GraphicsContext context,
                        DeviceDescription description)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
        //UpdateFSKFrameDecodeStats
        public static string[] EnumeratePlaybackDevices()
        {
            // Get the Windows enumerated Playback devices adding a "-n" tag (-1, -2, etc.)  if any duplicate names
            Microsoft.DirectX.DirectSound.DevicesCollection cllPlaybackDevices = new Microsoft.DirectX.DirectSound.DevicesCollection();
            //DeviceInformation objDI = new DeviceInformation();
            int intCtr = 0;
            int intDupeDeviceCnt = 0;

            string[] strPlaybackDevices = new string[cllPlaybackDevices.Count];
            foreach (DeviceInformation objDI in cllPlaybackDevices) {
            DeviceDescription objDD = new DeviceDescription(objDI);
            strPlaybackDevices[intCtr] = objDD.ToString().Trim();
            intCtr += 1;
            }

            for (int i = 0; i <= strPlaybackDevices.Length - 1; i++) {
            intDupeDeviceCnt = 1;
            for (int j = i + 1; j <= strPlaybackDevices.Length - 1; j++) {
                if (strPlaybackDevices[j] == strPlaybackDevices[i]) {
                    intDupeDeviceCnt += 1;
                    strPlaybackDevices[j] = strPlaybackDevices[i] + "-" + intDupeDeviceCnt.ToString();
                }
            }
            }
            return strPlaybackDevices;
        }
Esempio n. 8
0
 public UsbDevice(DeviceDescription item)
 {
     Description = item;
 }
Esempio n. 9
0
 protected override void InstallDevice(DeviceDescription deviceDescription)
 {
     IOManager.InstallDevice(new EmulatorConsole());
 }
Esempio n. 10
0
        private async Task ProcessKubernetesProvisioningData(KubernetesOutline outline, ProvisioningData provisioningData)
        {
            await Task.Run(async() =>
            {
                string iotFile = await File.ReadAllTextAsync(IoTConnectionFile);
                Dictionary <string, Dictionary <string, string> > iotInfo = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, string> > >(iotFile);

                foreach (var deployment in outline.Deployments)
                {
                    try
                    {
                        var metadata = deployment.metadata;

                        if (metadata != null)
                        {
                            var qualifiers = metadata.name.Split('.');
                            var room       = qualifiers.Last().ToLower();

                            if (provisioningData.ContainsKey(room))
                            {
                                foreach (var container in deployment.spec.template.spec.containers)
                                {
                                    var apiUrlSetting = container.env.FirstOrDefault(e => e.name == DigitalTwinsManagementApiSetting);
                                    if (apiUrlSetting != null)
                                    {
                                        apiUrlSetting.value = DigitalTwinsApiEndpoint;
                                    }

                                    var messageIntervalSetting = container.env.FirstOrDefault(e => e.name == MessageIntervalSetting);
                                    if (messageIntervalSetting != null)
                                    {
                                        messageIntervalSetting.value = MessageInterval > 0 ? MessageInterval.ToString() : MessageIntervalDefault.ToString();
                                    }

                                    var containerImage = FormatContainerImageName(container.image);
                                    container.image    = containerImage;

                                    var typeSetting = container.env.FirstOrDefault(s => s.name == SensorTypeSetting);

                                    if (typeSetting != null)
                                    {
                                        if (iotInfo.ContainsKey(room))
                                        {
                                            Dictionary <string, string> iotConnectionStrings = iotInfo[room];

                                            if (iotConnectionStrings.ContainsKey(typeSetting.value.ToLower()))
                                            {
                                                var iotSetting = container.env.FirstOrDefault(s => s.name == IoTHubConnectionStringSetting);

                                                if (iotSetting != null)
                                                {
                                                    iotSetting.value = iotConnectionStrings[typeSetting.value.ToLower()];
                                                }
                                            }
                                        }

                                        DeviceDescription device = provisioningData[room].FirstOrDefault(d => d.sensors.Any(s => s.dataType.ToLower() == typeSetting.value.ToLower()));
                                        if (device != null)
                                        {
                                            var sasTokenSetting = container.env.FirstOrDefault(e => e.name == SasTokenSetting);
                                            if (sasTokenSetting != null)
                                            {
                                                sasTokenSetting.value = device.SasToken;
                                            }

                                            var hardwareIdSetting = container.env.FirstOrDefault(e => e.name == HardwareIdSetting);
                                            if (hardwareIdSetting != null)
                                            {
                                                hardwareIdSetting.value = device.hardwareId;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            });
        }
Esempio n. 11
0
        private async Task ProcessDockerProvisioningData(DockerOutline outline, ProvisioningData provisioningData)
        {
            await Task.Run(async() =>
            {
                string iotFile = await File.ReadAllTextAsync(IoTConnectionFile);
                Dictionary <string, Dictionary <string, string> > iotInfo = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, string> > >(iotFile);

                foreach (var kvPair in outline.services)
                {
                    var service = kvPair.Value;

                    var containerImage = FormatContainerImageName(service.image);
                    service.image      = containerImage;

                    if (service.environment != null)
                    {
                        var apiUrlSetting = service.environment.FirstOrDefault(e => e.name == DigitalTwinsManagementApiSetting);
                        if (apiUrlSetting != null)
                        {
                            apiUrlSetting.value = DigitalTwinsApiEndpoint;
                        }

                        var messageIntervalSetting = service.environment.FirstOrDefault(e => e.name == MessageIntervalSetting);
                        if (messageIntervalSetting != null)
                        {
                            messageIntervalSetting.value = MessageInterval > 0 ? MessageInterval.ToString() : MessageIntervalDefault.ToString();
                        }

                        var qualifiers = kvPair.Key.Split('.');
                        var name       = qualifiers.Last().ToLower();

                        if (provisioningData.ContainsKey(name))
                        {
                            var serviceType = service.environment.FirstOrDefault(e => e.name == SensorTypeSetting);
                            if (serviceType != null)
                            {
                                if (iotInfo.ContainsKey(name))
                                {
                                    Dictionary <string, string> iotConnectionStrings = iotInfo[name];

                                    if (iotConnectionStrings.ContainsKey(serviceType.value.ToLower()))
                                    {
                                        var iotSetting = service.environment.FirstOrDefault(s => s.name == IoTHubConnectionStringSetting);

                                        if (iotSetting != null)
                                        {
                                            iotSetting.value = iotConnectionStrings[serviceType.value.ToLower()];
                                        }
                                    }
                                }

                                DeviceDescription device = provisioningData[name].FirstOrDefault(d => d.sensors.Any(s => s.dataType.ToLower() == serviceType.value.ToLower()));
                                if (device != null)
                                {
                                    var sasTokenSetting = service.environment.FirstOrDefault(e => e.name == SasTokenSetting);
                                    if (sasTokenSetting != null)
                                    {
                                        sasTokenSetting.value = device.SasToken;
                                    }

                                    var hardwareIdSetting = service.environment.FirstOrDefault(e => e.name == HardwareIdSetting);
                                    if (hardwareIdSetting != null)
                                    {
                                        hardwareIdSetting.value = device.hardwareId;
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Esempio n. 12
0
        /// <summary>
        /// Get Raumfeld DeviceDescription and create new MediaServer
        /// </summary>
        /// <returns></returns>
        //private async Task<MediaServer> loadMediaServerAsync()
        //{
        //    //if ((raumfeldDevices?.Devices?.Count() ?? 0) == 0 || server == null) { return null; }

        //    string uuid = ((Guid)server.Properties["System.Devices.ContainerId"]).ToString().ToLower();
        //    try
        //    {
        //        string serverDescription = raumfeldDevices.Devices.Where(server => server.Udn.Replace("uuid:", "").ToLower() == uuid).Select(server => server.Location).FirstOrDefault();

        //        if (!string.IsNullOrEmpty(serverDescription))
        //        {
        //            Uri serverUri = new Uri(serverDescription);
        //            var httpFilter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
        //            httpFilter.CacheControl.ReadBehavior = Windows.Web.Http.Filters.HttpCacheReadBehavior.NoCache;
        //            using (HttpClient client = new HttpClient())
        //            {
        //                using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, serverUri))
        //                {
        //                    request.Headers.Add("User-Agent", "RaumfeldControl/0.0 RaumfeldProtocol/1");    /* RaumfeldControl/3.6 RaumfeldProtocol/399 Build => https://github.com/masmu/pulseaudio-dlna/issues/227 */
        //                    request.Headers.Add("Accept-Language", "en");
        //                    request.Headers.Add("ContentType", "text/xml; charset=\"utf - 8\"");

        //                    using (HttpResponseMessage response = await client.SendRequestAsync(request))
        //                    {
        //                        if (response.StatusCode == Windows.Web.Http.HttpStatusCode.Ok)
        //                        {
        //                            string xmlString = await response.Content.ReadAsStringAsync();

        //                            XmlDocument xmlDocument = new XmlDocument();
        //                            xmlDocument.LoadXml(xmlString);
        //                            if (xmlDocument != null)
        //                            {
        //                                DeviceDescription deviceDescription = xmlDocument.GetXml().Deserialize<DeviceDescription>();
        //                                MediaServer mediaServer = new MediaServer(deviceDescription, serverUri.Host, serverUri.Port)
        //                                {
        //                                    DeviceType = MediaDeviceType.MediaServer
        //                                };

        //                                await mediaServer.LoadServicesAsync();

        //                                return mediaServer;
        //                            }
        //                        }
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception exception)
        //    {
        //        await UIService.ShowDialogAsync(string.Format("{0} {1}: {2}", UIService.GetResource("Error"), exception.HResult, exception.Message), "LoadMediaServer");
        //        Logger.GetLogger().SaveMessage(exception, "LoadMediaServerAsync");
        //    }
        //    return null;
        //}

        /// <summary>
        /// Get Raumfeld DeviceDescription and create new MediaRenderer
        /// </summary>
        /// <returns></returns>
        //private async Task<MediaRenderer> loadMediaRendererAsync(string rendererDescription, MediaDeviceType mediaDeviceType)
        //{
        //    //if ((raumfeldDevices?.Devices?.Count() ?? 0) == 0 || server == null) { return null; }

        //    try
        //    {
        //        if (!string.IsNullOrEmpty(rendererDescription))
        //        {
        //            Uri serverUri = new Uri(rendererDescription);
        //            var httpFilter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
        //            httpFilter.CacheControl.ReadBehavior = Windows.Web.Http.Filters.HttpCacheReadBehavior.NoCache;
        //            using (HttpClient client = new HttpClient(httpFilter))
        //            {
        //                using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, serverUri))
        //                {
        //                    request.Headers.Add("User-Agent", "RaumfeldControl/0.0 RaumfeldProtocol/1");    /* RaumfeldControl/3.6 RaumfeldProtocol/399 Build => https://github.com/masmu/pulseaudio-dlna/issues/227 */
        //                    request.Headers.Add("Accept-Language", "en");
        //                    request.Headers.Add("ContentType", "text/xml; charset=\"utf - 8\"");

        //                    using (HttpResponseMessage response = await client.SendRequestAsync(request))
        //                    {
        //                        if (response.StatusCode == Windows.Web.Http.HttpStatusCode.Ok)
        //                        {
        //                            string xmlString = await response.Content.ReadAsStringAsync();

        //                            XmlDocument xmlDocument = new XmlDocument();
        //                            xmlDocument.LoadXml(xmlString);
        //                            if (xmlDocument != null)
        //                            {
        //                                DeviceDescription deviceDescription = xmlDocument.GetXml().Deserialize<DeviceDescription>();

        //                                MediaRenderer mediaRenderer = new MediaRenderer(deviceDescription, serverUri.Host, serverUri.Port);
        //                                await mediaRenderer.LoadServicesAsync();

        //                                mediaRenderer.DeviceType = mediaDeviceType;

        //                                return mediaRenderer;
        //                            }
        //                        }
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception exception)
        //    {
        //        await UIService.ShowDialogAsync(string.Format("{0} {1}: {2}", UIService.GetResource("Error"), exception.HResult, exception.Message), "LoadMediaRenderer");
        //        Logger.GetLogger().SaveMessage(exception, "LoadMediaRendererAsync");
        //    }

        //    return null;
        //}

        /// <summary>
        /// Get Raumfeld DeviceDescription and create new MediaRenderer
        /// </summary>
        /// <returns></returns>
        private async Task <MediaDevice> loadMediaDeviceAsync(string rendererDescription, MediaDeviceType mediaDeviceType)
        {
            try
            {
                if (!string.IsNullOrEmpty(rendererDescription))
                {
                    Uri serverUri  = new Uri(rendererDescription);
                    var httpFilter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
                    httpFilter.CacheControl.ReadBehavior = Windows.Web.Http.Filters.HttpCacheReadBehavior.NoCache;
                    using (HttpClient client = new HttpClient(httpFilter))
                    {
                        using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, serverUri))
                        {
                            request.Headers.Add("User-Agent", "RaumfeldControl/0.0 RaumfeldProtocol/1");    /* RaumfeldControl/3.6 RaumfeldProtocol/399 Build => https://github.com/masmu/pulseaudio-dlna/issues/227 */
                            request.Headers.Add("Accept-Language", "en");
                            request.Headers.Add("ContentType", "text/xml; charset=\"utf - 8\"");

                            using (HttpResponseMessage response = await client.SendRequestAsync(request))
                            {
                                if (response.StatusCode == Windows.Web.Http.HttpStatusCode.Ok)
                                {
                                    string xmlString = await response.Content.ReadAsStringAsync();

                                    XmlDocument xmlDocument = new XmlDocument();
                                    xmlDocument.LoadXml(xmlString);
                                    if (xmlDocument != null)
                                    {
                                        DeviceDescription deviceDescription = xmlDocument.GetXml().Deserialize <DeviceDescription>();

                                        if (mediaDeviceType == MediaDeviceType.MediaServer)
                                        {
                                            MediaServer mediaServer = new MediaServer(deviceDescription, serverUri.Host, serverUri.Port)
                                            {
                                                DeviceType = mediaDeviceType
                                            };
                                            await mediaServer.LoadServicesAsync();

                                            return(mediaServer);
                                        }
                                        else
                                        {
                                            MediaRenderer mediaRenderer = new MediaRenderer(deviceDescription, serverUri.Host, serverUri.Port)
                                            {
                                                DeviceType = mediaDeviceType
                                            };
                                            await mediaRenderer.LoadServicesAsync();

                                            mediaRenderer.DeviceType = mediaDeviceType;

                                            return(mediaRenderer);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                await UIService.ShowDialogAsync(string.Format("{0} {1}: {2}", UIService.GetResource("Error"), exception.HResult, exception.Message), "loadMediaDeviceAsync");

                Logger.GetLogger().SaveMessage(exception, "loadMediaDeviceAsync");
            }

            return(null);
        }
 protected internal IconDescription(DeviceDescription device)
     : base(GetRoot (device))
 {
     this.device = device;
 }
 static Root GetRoot(DeviceDescription device)
 {
     if (device == null) throw new ArgumentNullException ("device");
     return device.Root;
 }
Esempio n. 15
0
 protected override void InstallDevice(DeviceDescription deviceDescription)
 {
     IOManager.InstallDevice(new TestDevice());
 }
Esempio n. 16
0
 protected override bool IsCompatible(DeviceDescription deviceDescription)
 {
     return(deviceDescription.Type == "emulator, console");
 }
Esempio n. 17
0
 private MaestroController(DeviceDescription description)
 {
     _device = new UsbDevice(description);
 }
        protected internal IconDescription(DeviceDescription device)
        {
            if (device == null) throw new ArgumentNullException ("device");

            this.device = device;
        }
Esempio n. 19
0
        public void DrawText(string s, Point location, double rotation, double adjustment, GraphicsContext context, DeviceDescription description)
        {
            var svgContext = _mapper.MapGraphicsContextToSvg(location, rotation, context);

            AddChild(new SvgText
            {
                Fill       = svgContext.Pen.Stroke,
                FontFamily = svgContext.Font.Family,
                FontSize   = svgContext.Font.Size,
                FontWeight = svgContext.Font.Weight,
                Text       = s,
                TextAnchor = svgContext.TextAnchor,
                Transforms = new SvgTransformCollection {
                    svgContext.Coordinate.Rotation
                },
                X = createUnitCollection(svgContext.Coordinate.X),
                Y = createUnitCollection(svgContext.Coordinate.Y)
            });
        }
Esempio n. 20
0
 private void DeviceManager_DeviceList_DeviceEditSelected(DeviceDescription device)
 {
     DeviceManager_EditDevice_Open(device);
 }
 public Rectangle GetSize(GraphicsContext context, DeviceDescription description)
 {
     return(description.ClipBounds);
 }
Esempio n. 22
0
 /// <summary>
 /// Adds a device to the Device List
 /// </summary>
 /// <param name="config">The Device to add</param>
 public void AddDevice(DeviceDescription device)
 {
     Devices.Add(device);
     SendDeviceAddedMessage(device);
 }
 public Point?GetLocation(DeviceDescription description)
 {
     throw new NotImplementedException();
 }
Esempio n. 24
0
        /// <summary>
        /// Creates a new instance of IMediaDevice
        /// </summary>
        /// <param name="rendererDescription">URI, where to fetch the MediaDevice desciptions</param>
        /// <param name="mediaDeviceType">MediaDevicetype, e.g. MediaServer</param>
        /// <returns></returns>
        private async Task <IMediaDevice> loadMediaDeviceAsync(string rendererDescription, MediaDeviceType mediaDeviceType)
        {
            try
            {
                if (!string.IsNullOrEmpty(rendererDescription))
                {
                    Uri serverUri  = new Uri(rendererDescription);
                    var httpFilter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
                    httpFilter.CacheControl.ReadBehavior = Windows.Web.Http.Filters.HttpCacheReadBehavior.NoCache;
                    using (HttpClient client = new HttpClient(httpFilter))
                    {
                        using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, serverUri))
                        {
                            request.Headers.Add("User-Agent", "RaumfeldControl/0.0 RaumfeldProtocol/1");    /* RaumfeldControl/3.6 RaumfeldProtocol/399 Build => https://github.com/masmu/pulseaudio-dlna/issues/227 */
                            request.Headers.Add("Accept-Language", "en");
                            request.Headers.Add("ContentType", "text/xml; charset=\"utf - 8\"");

                            using (HttpResponseMessage response = await client.SendRequestAsync(request))
                            {
                                if (response.StatusCode == Windows.Web.Http.HttpStatusCode.Ok)
                                {
                                    string xmlString = await response.Content.ReadAsStringAsync();

                                    XmlDocument xmlDocument = new XmlDocument();
                                    xmlDocument.LoadXml(xmlString);
                                    if (xmlDocument != null)
                                    {
                                        DeviceDescription deviceDescription = xmlDocument.GetXml().Deserialize <DeviceDescription>();
                                        IMediaDevice      device;

                                        if (mediaDeviceType == MediaDeviceType.MediaServer)
                                        {
                                            device = PrismUnityApplication.Current.Container.Resolve <MediaServer>(new ResolverOverride[]
                                            {
                                                new ParameterOverride("deviceDescription", deviceDescription), new ParameterOverride("ipAddress", serverUri.Host), new ParameterOverride("port", serverUri.Port),
                                            });

                                            await device.InitializeAsync();

                                            return(device);
                                        }
                                        else
                                        {
                                            device = PrismUnityApplication.Current.Container.Resolve <MediaRenderer>(new ResolverOverride[]
                                            {
                                                new ParameterOverride("deviceDescription", deviceDescription), new ParameterOverride("ipAddress", serverUri.Host), new ParameterOverride("port", serverUri.Port), new ParameterOverride("deviceType", mediaDeviceType),
                                            });

                                            await device.InitializeAsync();

                                            return(device);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(null);
        }
Esempio n. 25
0
 public RegisterReference(DeviceDescription device, RegisterDescription register)
 {
     this.Register = register;
     this.Device   = device;
 }
 public DeviceDescription GetDescription()
 {
     if (description == null) {
         if (IsDisposed) {
             throw new ObjectDisposedException (ToString (), "The device has gone off the network.");
         }
         description = client.GetDescription (this);
     }
     return description;
 }
Esempio n. 27
0
File: Main.cs Progetto: ptaa32/ARDOP
        public bool StartCodec(ref string strFault)
        {
            bool functionReturnValue = false;
            //Returns true if successful
            Thread.Sleep(100);
            // This delay is necessary for reliable starup following a StopCodec
            lock (objCodecLock) {
            dttLastSoundCardSample = Now;
            bool blnSpectrumSave = MCB.DisplaySpectrum;
            bool blnWaterfallSave = MCB.DisplayWaterfall;
            System.DateTime dttStartWait = Now;
            MCB.DisplayWaterfall = false;
            MCB.DisplaySpectrum = false;
            string[] strCaptureDevices = EnumerateCaptureDevices();
            string[] strPlaybackDevices = EnumeratePlaybackDevices();
            functionReturnValue = false;
            DeviceInformation objDI = new DeviceInformation();
            int intPtr = 0;
            // Playback devices
            try {
                cllPlaybackDevices = null;

                cllPlaybackDevices = new Microsoft.DirectX.DirectSound.DevicesCollection();
                if ((devSelectedPlaybackDevice != null)) {
                    devSelectedPlaybackDevice.Dispose();
                    devSelectedPlaybackDevice = null;
                }

                foreach (DeviceInformation objDI in cllPlaybackDevices) {
                    DeviceDescription objDD = new DeviceDescription(objDI);
                    if (strPlaybackDevices(intPtr) == MCB.PlaybackDevice) {
                        if (MCB.DebugLog)
                            Logs.WriteDebug("[Main.StartCodec] Setting SelectedPlaybackDevice = " + MCB.PlaybackDevice);
                        devSelectedPlaybackDevice = new Device(objDD.info.DriverGuid);
                        functionReturnValue = true;
                        break; // TODO: might not be correct. Was : Exit For
                    }
                    intPtr += 1;
                }
                if (!functionReturnValue) {
                    strFault = "Playback Device setup, Device " + MCB.PlaybackDevice + " not found in Windows enumerated Playback Devices";
                }
            } catch (Exception ex) {
                strFault = Err.Number.ToString + "/" + Err.Description;
                Logs.Exception("[StartCodec], Playback Device setup] Err: " + ex.ToString);
                functionReturnValue = false;
            }
            if (functionReturnValue) {
                // Capture Device
                CaptureBufferDescription dscheckboxd = new CaptureBufferDescription();
                try {
                    functionReturnValue = false;
                    cllCaptureDevices = null;
                    cllCaptureDevices = new CaptureDevicesCollection();
                    intPtr = 0;
                    for (int i = 0; i <= cllCaptureDevices.Count - 1; i++) {
                        if (MCB.CaptureDevice == strCaptureDevices(i)) {
                            objCaptureDeviceGuid = cllCaptureDevices(i).DriverGuid;
                            devCaptureDevice = new Capture(objCaptureDeviceGuid);
                            stcSCFormat.SamplesPerSecond = 12000;
                            // 12000 Hz sample rate
                            stcSCFormat.Channels = 1;
                            stcSCFormat.BitsPerSample = 16;
                            stcSCFormat.BlockAlign = 2;
                            stcSCFormat.AverageBytesPerSecond = 2 * 12000;
                            stcSCFormat.FormatTag = WaveFormatTag.Pcm;
                            objApplicationNotify = null;
                            objCapture = null;
                            // Set the buffer sizes
                            intCaptureBufferSize = intNotifySize * intNumberRecordNotifications;
                            // Create the capture buffer
                            dscheckboxd.BufferBytes = intCaptureBufferSize;
                            stcSCFormat.FormatTag = WaveFormatTag.Pcm;
                            dscheckboxd.Format = stcSCFormat;
                            // Set the format during creatation
                            if ((objCapture != null)) {
                                objCapture.Dispose();
                                objCapture = null;
                            }
                            //objCapture = New CaptureBuffer(dscheckboxd, devCaptureDevice)
                            intNextCaptureOffset = 0;
                            WriteTextToSpectrum("CODEC Start OK", Brushes.LightGreen);
                            while (Now.Subtract(dttStartWait).TotalSeconds < 3) {
                                Application.DoEvents();
                                Thread.Sleep(100);
                            }
                            objCapture = new CaptureBuffer(dscheckboxd, devCaptureDevice);
                            InititializeNotifications();
                            objCapture.Start(true);
                            // start with looping
                            InititializeSpectrum(Color.Black);

                            functionReturnValue = true;
                        }
                    }
                    if (!functionReturnValue) {
                        strFault = "Could not find DirectSound capture device " + MCB.CaptureDevice.ToUpper;
                        //Logs.Exception("[Main.StartCodec] Could not find DirectSound capture device " & MCB.CaptureDevice & " in Windows enumerated Capture Devices")
                    }
                } catch (Exception ex) {
                    strFault = Err.Number.ToString + "/" + Err.Description;
                    functionReturnValue = false;
                    //Logs.Exception("[Main.StartCodec] Err: " & ex.ToString)
                }
            }

            if (functionReturnValue) {
                if (MCB.DebugLog)
                    Logs.WriteDebug("[Main.StartCodec] Successful start of codec");
                objProtocol.ARDOPProtocolState = ProtocolState.DISC;
            } else {
                if (MCB.DebugLog)
                    Logs.WriteDebug("[Main.StartCodec] CODEC Start Failed");
                WriteTextToSpectrum("CODEC Start Failed", Brushes.Red);
                objProtocol.ARDOPProtocolState = ProtocolState.OFFLINE;
                while (Now.Subtract(dttStartWait).TotalSeconds < 3) {
                    Application.DoEvents();
                    Thread.Sleep(100);
                }
                tmrStartCODEC.Interval = 5000;
                tmrStartCODEC.Start();
            }
            InititializeSpectrum(Color.Black);
            MCB.DisplayWaterfall = blnWaterfallSave;
            MCB.DisplaySpectrum = blnSpectrumSave;
            }
            return functionReturnValue;
        }
        internal void Dispose()
        {
            if (IsDisposed) {
                return;
            }

            IsDisposed = true;
            OnDispose (DisposedEventArgs.Empty);

            if (description != null) {
                description.Dispose ();
                description = null;
            }
        }
 public void TryDispose(DeviceDescription device)
 {
 }
Esempio n. 30
0
 public void SetRootDevice(DeviceDescription rootDevice)
 {
     this.rootDevice = rootDevice;
 }
 public DeviceListItem(DeviceDescription device)
 {
     Update(device);
 }
 public ListItem(DeviceDescription device)
 {
     InitializeComponent();
     root.DataContext = this;
     Device           = device;
 }
Esempio n. 33
0
 protected override bool IsCompatible(DeviceDescription deviceDescription)
 {
     return(true);
 }
 public Rectangle OnResized(DeviceDescription description)
 {
     throw new NotImplementedException();
 }
Esempio n. 35
0
        public void DrawPolyline(IEnumerable <Point> points, GraphicsContext context, DeviceDescription description)
        {
            var svgContext = _mapper.MapGraphicsContextToSvg(context);
            var collection = new SvgPointCollection();

            collection.AddRange(points.Select(p => _mapper.MapPoint(p, SvgUnitType.User))
                                .Select(p => new[] { p.X, p.Y })
                                .SelectMany(p => p));

            AddChild(new SvgPolyline
            {
                Fill            = svgContext.Fill,
                FillOpacity     = svgContext.Opacity,
                Points          = collection,
                Stroke          = svgContext.Pen.Stroke,
                StrokeDashArray = svgContext.Pen.StrokeDashArray,
                StrokeLineCap   = svgContext.Pen.StrokeLineCap,
                StrokeLineJoin  = svgContext.Pen.StrokeLineJoin,
                StrokeWidth     = svgContext.Pen.StrokeWidth
            });
        }
 public void OnClosed(DeviceDescription description)
 {
 }
Esempio n. 37
0
 public Raster Capture(DeviceDescription description)
 {
     throw new NotImplementedException();
 }
 public void OnDrawStopped(DeviceDescription description)
 {
 }
Esempio n. 39
0
 public void OnDeactivated(DeviceDescription description)
 {
 }
Esempio n. 40
0
        protected virtual void DeserializeDescriptionPropertyElement(XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException ("reader");

            switch (reader.Name) {
            case "specVersion":
                SpecVersion = Helper.DeserializeSpecVersion (reader.ReadSubtree ());
                break;
            case "URLBase":
                UrlBase = new Uri (reader.ReadString ());
                break;
            case "device":
                using (var device_reader = reader.ReadSubtree ()) {
                    device_reader.Read ();
                    root_device = DeserializeDevice (device_reader);
                    disposer.SetRootDevice (root_device);
                }
                break;
            default: // This is a workaround for Mono bug 334752
                reader.Skip ();
                break;
            }
        }