Exemple #1
0
        private void SendEventEmail(IEventItem myEvent)
        {
            ISensorItem mySensor = App.SensorCollection.FindBySensorId(myEvent.SensorId);

            if (mySensor != null)
            {
                string subject = string.Empty;
                if (App.VesselSettings.VesselName.Length > 0)
                {
                    subject = "** Alarm Message from " + App.VesselSettings.VesselName + " ** ";
                }
                else
                {
                    subject = "** Alarm Message ** ";
                }

                SendEmail.Send(App.VesselSettings.ToEmailAddress,
                               App.VesselSettings.VesselName,
                               subject,
                               "A new alarm condition has been detected." +
                               Environment.NewLine +
                               Environment.NewLine +
                               mySensor.Description +
                               Environment.NewLine +
                               //mySensor.AlarmMessage(myEvent.Value, myEvent.EventCode),
                               "",
                               string.Empty);
            }
        }
Exemple #2
0
        async private Task <ISensorItem> CreateVideoSensor(
            SsdpDevice fullDevice,
            string serialNumber,
            IDeviceItem videoCameraDeviceItem)
        {
            ISensorItem sensor = null;

            // We need to do this in the UI thread since it may cause some UI elements to be updated.
            await DispatcherHelper.UIDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
            {
                sensor = new SensorItem(videoCameraDeviceItem.DeviceId)
                {
                    Description  = (fullDevice.FriendlyName ?? string.Empty),
                    IsEnabled    = true,
                    SensorType   = SensorType.VideoCamera,
                    SensorUsage  = SensorUsage.Other,
                    SerialNumber = serialNumber,
                };

                sensor = await App.SensorCollection.BeginAdd(sensor);
            });

            Debug.Assert(null != sensor);

            return(sensor);
        }
        private void BuildGauge(IGaugeItem gaugeItem, Action <ISensorItem> constructor)
        {
            ISensorItem sensor = App.SensorCollection.FindBySensorId(gaugeItem.SensorId);

            if (null != sensor)
            {
                sensor.IsDemoMode = true;
            }

            constructor(sensor);
        }
 /// <summary>
 /// Do not call this function. Call await BeginAdd instead.
 /// </summary>
 /// <param name="sensorItem"></param>
 public void Add(ISensorItem sensorItem)
 {
     throw new NotImplementedException("Use BeginAdd instead");
 }
Exemple #5
0
        async void DeviceLocator_DeviceAvailable(object sender, DeviceAvailableEventArgs e)
        {
            //Device data returned only contains basic device details and location of full device description.
            Debug.WriteLine("UPnP Found: " + e.DiscoveredDevice.Usn + " at " + e.DiscoveredDevice.DescriptionLocation.ToString());

            try
            {
                //Can retrieve the full device description easily though.
                SsdpDevice fullDevice = await e.DiscoveredDevice.GetDeviceInfo();

                Debug.WriteLine("\t Name=" + fullDevice.FriendlyName);
                Debug.WriteLine("");

                // If we don't have a serial number for this device, we need to construct one.
                string serialNumber =
                    fullDevice.Uuid + "|" +
                    fullDevice.ModelDescription + "|" +
                    fullDevice.ModelName + "|" +
                    fullDevice.ModelNumber + "|" +
                    fullDevice.ModelUrl + "|" +
                    fullDevice.PresentationUrl;
                if (null != fullDevice.SerialNumber)
                {
                    serialNumber = fullDevice.SerialNumber;
                }

                ISensorItem videoCameraSensorItem = null;
                IDeviceItem videoCameraDeviceItem = await App.DeviceCollection.BeginFindBySerialNumber(serialNumber);

                if (null == videoCameraDeviceItem)
                {
                    // No device was found to contain this camera. Build the device and the sensor.
                    videoCameraDeviceItem = await this.CreateVideoDevice(fullDevice, serialNumber);

                    Debug.Assert(null != videoCameraDeviceItem);
                    videoCameraSensorItem = await this.CreateVideoSensor(fullDevice, serialNumber, videoCameraDeviceItem);

                    Debug.Assert(null != videoCameraSensorItem);
                }
                else if ((null != fullDevice.PresentationUrl) &&
                         (videoCameraDeviceItem.IPAddress != fullDevice.PresentationUrl.ToString()))
                {
                    // The IP address of the camera changed. We need to refresh the device.
                    await App.DeviceCollection.BeginDelete(videoCameraDeviceItem);

                    videoCameraDeviceItem = await this.CreateVideoDevice(fullDevice, serialNumber);

                    Debug.Assert(null != videoCameraDeviceItem);
                    videoCameraSensorItem = await this.CreateVideoSensor(fullDevice, serialNumber, videoCameraDeviceItem);

                    Debug.Assert(null != videoCameraSensorItem);
                }
                else if (videoCameraDeviceItem.Sensors.Count == 0)
                {
                    // We have a device to hold the camera, but no camera sensor. We need to build the sensor.
                    videoCameraSensorItem = await this.CreateVideoSensor(fullDevice, serialNumber, videoCameraDeviceItem);

                    Debug.Assert(null != videoCameraSensorItem);
                }
                else
                {
                    videoCameraDeviceItem.IsOnline = true;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\t Unable to get device info. " + ex.Message);
            }
        }