Esempio n. 1
0
        /// <summary>
        /// Creates the items.
        /// </summary>
        private void CreateItems()
        {
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("Accelerometer/Text")
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("Compass/Text")
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("Gyroscope/Text")
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("Inclinometer/Text")
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("OrientationSensor/Text")
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("NFC/Text")
            });

            CameraItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("BackCamera/Text")
            });
            CameraItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("BackCameraFlash/Text")
            });
            CameraItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("BackCameraAutoFocus/Text")
            });
            CameraItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("FrontCamera/Text")
            });
            CameraItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("FrontCameraFlash/Text")
            });

            // Front camera focus information is not reliable and thus not added
            //CameraItems.Add(new BoolItemModel() { BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("FrontCameraAutoFocus/Text") });

            SensorCoreItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("ActivityMonitor/Text")
            });
            SensorCoreItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("PlaceMonitor/Text")
            });
            SensorCoreItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("StepCounter/Text")
            });
            SensorCoreItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = _resourceLoader.GetString("TrackPointMonitor/Text")
            });

            DeviceTotalMemory        = _resourceLoader.GetString("Waiting/Text");
            MemoryStatus             = _resourceLoader.GetString("Waiting/Text");
            ScreenResolution         = _resourceLoader.GetString("Waiting/Text");
            DeviceName               = _resourceLoader.GetString("Waiting/Text");
            SDCardPresent            = _resourceLoader.GetString("Waiting/Text");
            Theme                    = _resourceLoader.GetString("Waiting/Text");
            VibrationDeviceAvailable = _resourceLoader.GetString("Waiting/Text");
        }
        public void StartClient()
        {
            // Data buffer for incoming data.
            byte[] bytes = new byte[1024];

            // Connect to a remote device.
            try
            {
                // Establish the remote endpoint for the socket.
                // This example uses port 11000 on the local computer.
                IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
                IPAddress   ipAddress  = IPAddress.Parse(txtIP.Text); //ipHostInfo.AddressList[0];
                IPEndPoint  remoteEP   = new IPEndPoint(ipAddress, int.Parse(txtPort.Text));

                // Create a TCP/IP  socket
                Socket sender = new Socket(AddressFamily.InterNetwork,//stop here   //.InterNetwork, //code change here .Address
                                           SocketType.Stream, ProtocolType.Tcp);

                // Connect the socket to the remote endpoint. Catch any errors.
                try
                {
                    sender.Connect(remoteEP);
                    while (isConnect)
                    {
                        Debug.WriteLine("Socket connected to {0}",
                                        sender.RemoteEndPoint.ToString());

                        // Receive the response from the remote device.
                        int bytesRec = sender.Receive(bytes);
                        var received = Encoding.ASCII.GetString(bytes, 0, bytesRec);
                        Debug.WriteLine("Echoed test = {0}", received);
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            try
                            {
                                SensorItem item = JsonConvert.DeserializeObject <SensorItem>(received);
                                Debug.WriteLine(item.Acc.X);

                                SensorItems.Add(item);
                                lblTemp.Text = item.Tem.ToString();
                                gauIndicatorTemperature.Value = item.Tem;
                                if (SensorItems.Count > 5)
                                {
                                    SensorItems.RemoveAt(0);
                                }
                            }
                            catch (Exception e) {
                                Alert(e.ToString());
                            }
                        });



                        Debug.WriteLine("Loop Done");
                    }


                    // Release the socket.
                    sender.Shutdown(SocketShutdown.Both);
                    sender.Close();
                }
                catch (ArgumentNullException ane)
                {
                    Alert(string.Format("ArgumentNullException : {0}", ane.ToString()));
                }
                catch (SocketException se)
                {
                    Alert(string.Format("SocketException : {0}", se.ToString()));
                }
                catch (Exception e)
                {
                    Alert(string.Format("Unexpected exception : {0}", e.ToString()));
                }
            }
            catch (Exception e)
            {
                Alert(string.Format(e.ToString()));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the items.
        /// </summary>
        private void CreateItems()
        {
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.Accelerometer
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.Compass
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.Gyroscope
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.Inclinometer
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.MotionApi
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.OrientationSensor
            });
            SensorItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.NFC
            });

            CameraItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.PrimaryCamera
            });
            CameraItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.PrimaryCameraFlash
            });
            CameraItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.FrontCamera
            });
            CameraItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.FrontCameraFlash
            });

            BatteryAndPowerItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.BatteryStatusInfo
            });
            BatteryAndPowerItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.ConnectedToExternalPowerSupply
            });

            OtherItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.FMRadio
            });
            OtherItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.SDCard
            });
            OtherItems.Add(new BoolItemModel()
            {
                BooleanValue = false, HardwareFeatureText = AppResources.VibrationDevice
            });

            ScreenResolution  = AppResources.Waiting;
            DeviceTotalMemory = AppResources.Waiting;
            MemoryStatus      = AppResources.Waiting;
            Manufacturer      = AppResources.Waiting;
            Operator          = AppResources.Waiting;
            Theme             = AppResources.Waiting;
        }