コード例 #1
0
        public FileItem(DeviceObject deviceObject, ICameraDevice device)
        {
            Device       = device;
            DeviceObject = deviceObject;
            ItemType     = FileItemType.CameraObject;
            FileName     = deviceObject.FileName;
            FileDate     = deviceObject.FileDate;
            IsChecked    = true;
            if (deviceObject.ThumbData != null && deviceObject.ThumbData.Length > 4)
            {
                try
                {
                    var stream = new MemoryStream(deviceObject.ThumbData, 0, deviceObject.ThumbData.Length);

                    using (var bmp = new Bitmap(stream))
                    {
                        Thumbnail = BitmapSourceConvert.ToBitmapSource(bmp);
                    }
                    stream.Close();
                }
                catch (Exception exception)
                {
                    Log.Debug("Error loading device thumb ", exception);
                }
            }
        }
コード例 #2
0
        public static string GetObjectClassName(DeviceObject deviceObject)
        {
            var parentName = deviceObject.Parent != null ? deviceObject.Parent.Name : string.Empty;
            var objectName = deviceObject.Name;

            return(Helpers.ReplaceIllegals(Helpers.ToPascalCase(parentName) + Helpers.ToPascalCase(objectName)));
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // The First Device with 1 Device Object and 1 AnalogInput
            DeviceObject        Dev1 = new DeviceObject(1234, "Device 1", "The First Device", false);
            AnalogInput <float> Temp = new AnalogInput <float>
                                       (
                0,
                "Temperature",
                "Temperature",
                0,
                BacnetUnitsId.UNITS_DEGREES_CELSIUS
                                       );

            Dev1.AddBacnetObject(Temp);

            Temp.internal_PROP_PRESENT_VALUE = 22.6f;

            // The Second Device with 1 Device Object and also 1 AnalogInput
            DeviceObject        Dev2      = new DeviceObject(5678, "Device 2", "The Second Device", false);
            AnalogInput <float> Windspeed = new AnalogInput <float>
                                            (
                1,
                "Windspeed",
                "Wind speed",
                0,
                BacnetUnitsId.UNITS_KILOMETERS_PER_HOUR
                                            );

            Dev2.AddBacnetObject(Windspeed);

            Windspeed.internal_PROP_PRESENT_VALUE = 0.2f;

            // Force the JIT compiler to make some job before network access
            Dev2.Cli2Native();

            // Start the activity for both device
            BacnetActivity BacAc1 = new BacnetActivity();

            BacAc1.StartActivity(Dev1);

            BacnetActivity BacAc2 = new BacnetActivity();

            BacAc2.StartActivity(Dev2);

            // Some animation !
            for (; ;)
            {
                Thread.Sleep(1000);
                //  a Ramp on an object
                if (Temp.internal_PROP_PRESENT_VALUE < 30)
                {
                    Temp.internal_PROP_PRESENT_VALUE = Temp.internal_PROP_PRESENT_VALUE + 1;
                }
                else
                {
                    Temp.internal_PROP_PRESENT_VALUE = 10f;
                }
            }
        }
コード例 #4
0
        public static CodeProperty CreateFrom(DeviceObject deviceObject)
        {
            var codeProperty = new CodeProperty
            {
                Name = Helpers.ToPascalCase(deviceObject.Name),
                Type = CodeClass.GetObjectClassName(deviceObject)
            };

            return(codeProperty);
        }
コード例 #5
0
        public override AsyncObservableCollection <DeviceObject> GetObjects(object storageId, bool loadThumbs)
        {
            AsyncObservableCollection <DeviceObject> res = new AsyncObservableCollection <DeviceObject>();
            MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetObjectHandles, 0xFFFFFFFF);

            if (response.Data == null)
            {
                Log.Debug("Get object error :" + response.ErrorCode.ToString("X"));
                ErrorCodes.GetException(response.ErrorCode);
                return(res);
            }
            int objCount = BitConverter.ToInt32(response.Data, 0);

            for (int i = 0; i < objCount; i++)
            {
                DeviceObject deviceObject = new DeviceObject();
                uint         handle       = BitConverter.ToUInt32(response.Data, 4 * i + 4);
                deviceObject.Handle = handle;
                MTPDataResponse objectdata = ExecuteReadDataEx(CONST_CMD_GetObjectInfo, handle);
                if (objectdata.Data != null)
                {
                    uint objFormat = BitConverter.ToUInt16(objectdata.Data, 4);
                    if (objFormat == 0x3000 || objFormat == 0x3801 || objFormat == 0x3800)
                    {
                        deviceObject.FileName = Encoding.Unicode.GetString(objectdata.Data, 53, 12 * 2);
                        if (deviceObject.FileName.Contains("\0"))
                        {
                            deviceObject.FileName = deviceObject.FileName.Split('\0')[0];
                        }
                        try
                        {
                            string datesrt = Encoding.Unicode.GetString(objectdata.Data, 53 + (12 * 2) + 3, 30);
                            //datesrt = datesrt.Replace("T", "");
                            DateTime date = DateTime.MinValue;
                            if (DateTime.TryParseExact(datesrt, "yyyyMMddTHHmmss", CultureInfo.InvariantCulture,
                                                       DateTimeStyles.None, out date))
                            {
                                deviceObject.FileDate = date;
                            }
                        }
                        catch (Exception)
                        {
                        }

                        if (loadThumbs)
                        {
                            MTPDataResponse thumbdata = ExecuteReadDataEx(CONST_CMD_GetThumb, handle);
                            deviceObject.ThumbData = thumbdata.Data;
                        }
                        res.Add(deviceObject);
                    }
                }
            }
            return(res);
        }
コード例 #6
0
 //Receive Compass data
 public static void ReceiveCompass(DeviceObject bsnDevice)
 {
     Debug.Log("ENTROU NO RECEBER Compass");
     BluetoothLEHardwareInterface.SubscribeCharacteristicWithDeviceAddress(bsnDevice.Address, FullBSNUUID(_serviceReadUUID), FullBSNUUID(_readCompassUUID), (deviceAddress, notification) =>
     {
     }, (deviceAddress2, characteristic, data) =>
     {
         //TODO RETORNAR BYTES ( data )
     });
     Debug.Log("DEPOIS DO READ");
 }
コード例 #7
0
 /// <summary>
 /// Creates an instance of the DeviceHandler class.
 /// This is neccessary to call methods!
 /// </summary>
 /// <param name="device">The device you want to call the methods on.</param>
 /// <returns>An deviceHandler instance.</returns>
 public DeviceHandler GetDeviceHandler(DeviceObject device, bool useJdownloaderApi = false)
 {
     if (IsConnected)
     {
         //TODO: Make it possible to directly connect to the jdownloader client. If it's not working use the relay server.
         //var tmp = _apiHandler.CallAction<DefaultReturnObject>(device, "/device/getDirectConnectionInfos",
         //    null, LoginObject, true);
         return(new DeviceHandler(device, _apiHandler, LoginObject, useJdownloaderApi));
     }
     return(null);
 }
コード例 #8
0
ファイル: Utils.cs プロジェクト: Kununa/My.Jdownloader.Api
        public static async Task <T?> CallAction <T>(DeviceObject device, LoginObject loginObject, string action, object?param, bool eventListener = false)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device), "The device can't be null.");
            }
            if (string.IsNullOrEmpty(device.Id))
            {
                throw new ArgumentException("The id of the device is empty. Please call again the GetDevices Method and try again.", nameof(device));
            }

            var query            = $"/t_{HttpUtility.UrlEncode(loginObject.SessionToken)}_{HttpUtility.UrlEncode(device.Id)}{action}";
            var callActionObject = new CallActionObject
            {
                ApiVer    = 1,
                Params    = param,
                RequestId = GetUniqueRid(),
                Url       = action
            };

            var url           = ApiUrl + query;
            var json          = JsonConvert.SerializeObject(callActionObject);
            var encryptedJson = await Encrypt(json, loginObject.DeviceEncryptionToken);

            var encryptedResponse = await PostMethod(url, encryptedJson, eventListener);

            if (encryptedResponse == null)
            {
                throw new Exception("Server response is empty");
            }

            var decryptedResponse = await Decrypt(encryptedResponse, loginObject.DeviceEncryptionToken);

            if (decryptedResponse == null)
            {
                throw new Exception("Can't decrypt message");
            }

            //special case as event responses are completly differerent
            if (decryptedResponse.Contains("subscriptionid"))
            {
                var direct = JsonConvert.DeserializeObject <T>(decryptedResponse);
                if (direct != null)
                {
                    return(direct);
                }
            }

            var res = JsonConvert.DeserializeObject <ApiObjects.DefaultReturnObject>(decryptedResponse);

            if (res?.Data == null)
            {
                return(default);
コード例 #9
0
 public FileItem(DeviceObject deviceObject, ICameraDevice device)
 {
     Device       = device;
     DeviceObject = deviceObject;
     ItemType     = FileItemType.CameraObject;
     FileName     = deviceObject.FileName;
     Name         = FileName;
     FileDate     = deviceObject.FileDate;
     IsChecked    = true;
     IsLiked      = false;
     IsUnLiked    = false;
     ThumbData    = deviceObject.ThumbData;
 }
コード例 #10
0
        public override AsyncObservableCollection <DeviceObject> GetObjects(object storageId, bool loadThumbs)
        {
            var res = new AsyncObservableCollection <DeviceObject>();

            SendCommand(1283, "\\/var\\/www\\/DCIM\\/100MEDIA/");
            _listingEvent.Reset();
            SendCommand(1282, " -D -S");
            _listingEvent.WaitOne(2500);
            dynamic   resp   = JsonConvert.DeserializeObject(_lastData);
            WebClient client = new WebClient();

            foreach (JObject o in resp.listing)
            {
                var    k    = o.ToObject <Dictionary <string, string> >();
                string v    = k.First().Value;
                var    file = new DeviceObject();
                file.FileName = k.First().Key;
                if (file.FileName.ToLower().Contains("thm"))
                {
                    continue;
                }
                file.Handle = file.FileName;
                try
                {
                    if (loadThumbs)
                    {
                        if (file.FileName.Contains(".jpg"))
                        {
                            file.ThumbData =
                                client.DownloadData(string.Format("http://{0}/DCIM/100MEDIA/{1}?type=thumb", Protocol.Ip,
                                                                  file.FileName));
                        }
                        if (file.FileName.Contains(".mp4"))
                        {
                            file.ThumbData =
                                client.DownloadData(string.Format("http://{0}/DCIM/100MEDIA/{1}?type=thumb", Protocol.Ip,
                                                                  file.FileName.Replace("mp4", "THM")));
                        }
                    }
                    if (v.Contains("|"))
                    {
                        file.FileDate = DateTime.ParseExact(v.Split('|')[1], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                    }
                }
                catch (Exception)
                {
                }
                res.Add(file);
            }
            return(res);
        }
コード例 #11
0
        //public override event PhotoCapturedEventHandler PhotoCaptured;

        public override bool DeleteObject(DeviceObject deviceObject)
        {
            string id = (string)((object[])(deviceObject.Handle))[1];

            for (int j = 1; j <= Device.Items.Count; j++)
            {
                if (Device.Items[j].ItemID == id)
                {
                    Device.Items.Remove(j);
                    break;
                }
            }
            return(true);
        }
コード例 #12
0
        public T CallAction <T>(DeviceObject device, string action, object param, LoginObject loginObject,
                                bool decryptResponse = false)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            if (string.IsNullOrEmpty(device.Id))
            {
                throw new ArgumentException(
                          "The id of the device is empty. Please call again the GetDevices Method and try again.");
            }

            string query =
                $"/t_{HttpUtility.UrlEncode(loginObject.SessionToken)}_{HttpUtility.UrlEncode(device.Id)}{action}";
            CallActionObject callActionObject = new CallActionObject
            {
                ApiVer    = 1,
                Params    = param,
                RequestId = GetUniqueRid(),
                Url       = action
            };

            //Regex _regex = new Regex("http\\:\\/\\/(192.168.*)\\:37733");
            //var match = _regex.Match(_apiUrl);
            //if (match.Success)
            //{
            //    _apiUrl = _apiUrl.Replace(match.Groups[0].Value, "89.163.144.231");
            //}
            string url = _apiUrl + query;
            //url = url.Replace("172.23.0.8", "89.163.144.231");
            string json = JsonConvert.SerializeObject(callActionObject);

            json = Encrypt(json, loginObject.DeviceEncryptionToken);
            string response = PostMethod(url,
                                         json, loginObject.DeviceEncryptionToken);

            if (response != null || !response.Contains(callActionObject.RequestId.ToString()))
            {
                if (decryptResponse)
                {
                    string tmp = Decrypt(response, loginObject.DeviceEncryptionToken);
                    return((T)JsonConvert.DeserializeObject(tmp, typeof(T)));
                }
                throw new InvalidRequestIdException("The 'RequestId' differs from the 'Requestid' from the query.");
            }
            return((T)JsonConvert.DeserializeObject(response, typeof(T)));
        }
コード例 #13
0
 public void Init(DeviceObject device)
 {
     this.device = device;
     if (deviceName != null)
     {
         deviceName.text = device.Name;
     }
     if (deviceAddress != null)
     {
         deviceAddress.text = device.Address;
     }
     if (deviceImage != null)
     {
         deviceImage = device.Image;
     }
 }
コード例 #14
0
        public static CodeClass CreateFrom(DeviceObject deviceObject)
        {
            var codeClass = new CodeClass
            {
                ClassName = GetObjectClassName(deviceObject),
                FileName  = GetObjectClassName(deviceObject) + ".Generated.cs"
            };

            var deviceProperties = deviceObject.Members.Where(x => x is DeviceProperty || x is DeviceObject).ToList();

            codeClass.Functions        = deviceObject.Members.Where(x => x is DeviceFunction).Select(x => CodeFunction.CreateFrom((DeviceFunction)x)).ToList();
            codeClass.ScalarProperties = deviceProperties.Where(x => x.Type != DataType.Object).Select(x => CodeProperty.CreateFrom((DeviceProperty)x)).ToList();
            codeClass.ObjectProperties = deviceProperties.Where(x => x.Type == DataType.Object).Select(x => CodeProperty.CreateFrom((DeviceObject)x)).ToList();

            return(codeClass);
        }
コード例 #15
0
    /// <summary>
    /// Set the Tags as Text of the last label created.
    /// </summary>
    public void FinaliseLabel(AnalysisRootObject analysisObject)
    {
        if (analysisObject.predictions != null)
        {
            lastLabelPlacedText = lastLabelPlaced.GetComponent <TextMesh>();
            // Sort the predictions to locate the highest one
            List <Prediction> sortedPredictions = new List <Prediction>();
            sortedPredictions = analysisObject.predictions.OrderBy(p => p.probability).ToList();
            Prediction bestPrediction = new Prediction();
            bestPrediction = sortedPredictions[sortedPredictions.Count - 1];

            if (bestPrediction.probability > probabilityThreshold)
            {
                quadRenderer = quad.GetComponent <Renderer>() as Renderer;
                Bounds quadBounds = quadRenderer.bounds;

                // Position the label as close as possible to the Bounding Box of the prediction
                // At this point it will not consider depth
                lastLabelPlaced.transform.parent        = quad.transform;
                lastLabelPlaced.transform.localPosition = CalculateBoundingBoxPosition(quadBounds, bestPrediction.boundingBox);

                string results = FetchDynamo();

                DeviceObject device = DeviceObject.CreateFromJSON(results);

                // Set the tag text
                lastLabelPlacedText.text = bestPrediction.tagName + "\n customer_id: " + device.customer_id + "\n name: " + device.name + "\n desc: " + device.desc + "\n price: " + device.price + "\n serial: " + device.sn + "\n location: " + device.location;

                // Cast a ray from the user's head to the currently placed label, it should hit the object detected by the Service.
                // At that point it will reposition the label where the ray HL sensor collides with the object,
                // (using the HL spatial tracking)
                Debug.Log("Repositioning Label");
                Vector3    headPosition = Camera.main.transform.position;
                RaycastHit objHitInfo;
                Vector3    objDirection = lastLabelPlaced.position;
                if (Physics.Raycast(headPosition, objDirection, out objHitInfo, 30.0f, SpatialMapping.PhysicsRaycastMask))
                {
                    lastLabelPlaced.position = objHitInfo.point;
                }
            }
        }
        // Reset the color of the cursor
        cursor.GetComponent <Renderer>().material.color = Color.green;

        // Stop the analysis process
        ImageCapture.Instance.ResetImageCapture();
    }
コード例 #16
0
 public override bool DeleteObject(DeviceObject deviceObject)
 {
     try
     {
         string url   = ((string)deviceObject.Handle);
         var    array = new JArray {
             url
         };
         var s = CreateJson("camera.delete", new JProperty("fileUrls", array));
         GetExecute(s);
     }
     catch (Exception ex)
     {
         Log.Error("Unable to set property ", ex);
     }
     return(true);
 }
コード例 #17
0
    public void OnButtonClick(int buttonID)
    {
        if (buttonID >= 0 && buttonID < 4)
        {
            DeviceObject device                   = FoundDeviceListScript.DeviceAddressList[buttonID];
            Text         button                   = Buttons[buttonID];
            string       subscribedService        = Services[buttonID];
            string       subscribedCharacteristic = Characteristics[buttonID];

            if (device != null && button != null)
            {
                if (button.text.Contains("connected"))
                {
                    if (!string.IsNullOrEmpty(subscribedService) && !string.IsNullOrEmpty(subscribedCharacteristic))
                    {
                        BluetoothLEHardwareInterface.UnSubscribeCharacteristic(device.Address, subscribedService, subscribedCharacteristic, (characteristic) => {
                            Services[buttonID]        = null;
                            Characteristics[buttonID] = null;

                            BluetoothLEHardwareInterface.DisconnectPeripheral(device.Address, (disconnectAddress) => {
                                button.text = device.Name;
                            });
                        });
                    }
                    else
                    {
                        BluetoothLEHardwareInterface.DisconnectPeripheral(device.Address, (disconnectAddress) => {
                            button.text = device.Name;
                        });
                    }
                }
                else
                {
                    BluetoothLEHardwareInterface.ConnectToPeripheral(device.Address, (address) => {
                    }, null, (address, service, characteristic) => {
                        if (string.IsNullOrEmpty(Services[buttonID]) && string.IsNullOrEmpty(Characteristics[buttonID]))
                        {
                            Services[buttonID]        = FullUUID(service);
                            Characteristics[buttonID] = FullUUID(characteristic);
                            button.text = device.Name + " connected";
                        }
                    }, null);
                }
            }
        }
    }
コード例 #18
0
        public static void StartActivity(DeviceObject _device)
        {
            deviceId = _device.PROP_OBJECT_IDENTIFIER.Instance;
            device   = _device;

            using (var loggerFactory = LoggerFactory.Create(b =>
            {
                b.AddConsole(c =>
                {
                    c.TimestampFormat = "[yyyy-MM-dd HH:mm:ss] ";
                });
            }))
            {
                // Bacnet on UDP/IP/Ethernet
                bacnet_client = new BacnetClient(new BacnetIpUdpProtocolTransport(0xBAC0, loggerFactory: loggerFactory), loggerFactory: loggerFactory);
            }

            bacnet_client.OnIam += new BacnetClient.IamHandler(handler_OnIam);
            bacnet_client.OnReadPropertyRequest         += new BacnetClient.ReadPropertyRequestHandler(handler_OnReadPropertyRequest);
            bacnet_client.OnReadPropertyMultipleRequest += new BacnetClient.ReadPropertyMultipleRequestHandler(handler_OnReadPropertyMultipleRequest);
            bacnet_client.OnWritePropertyRequest        += new BacnetClient.WritePropertyRequestHandler(handler_OnWritePropertyRequest);
            bacnet_client.OnSubscribeCOV           += new BacnetClient.SubscribeCOVRequestHandler(handler_OnSubscribeCOV);
            bacnet_client.OnSubscribeCOVProperty   += new BacnetClient.SubscribeCOVPropertyRequestHandler(handler_OnSubscribeCOVProperty);
            bacnet_client.OnReadRange              += new BacnetClient.ReadRangeHandler(handler_OnReadRange);
            bacnet_client.OnAtomicWriteFileRequest += new BacnetClient.AtomicWriteFileRequestHandler(handler_OnAtomicWriteFileRequest);
            bacnet_client.OnAtomicReadFileRequest  += new BacnetClient.AtomicReadFileRequestHandler(handler_OnAtomicReadFileRequest);
            // A sample to shows CreateObject & DeleteObject
            bacnet_client.OnCreateObjectRequest      += new BacnetClient.CreateObjectRequestHandler(handler_OnCreateObjectRequest);
            device.m_PROP_PROTOCOL_SERVICES_SUPPORTED = device.m_PROP_PROTOCOL_SERVICES_SUPPORTED.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_CREATE_OBJECT, true);
            bacnet_client.OnDeleteObjectRequest      += new BacnetClient.DeleteObjectRequestHandler(handler_OnDeleteObjectRequest);
            device.m_PROP_PROTOCOL_SERVICES_SUPPORTED = device.m_PROP_PROTOCOL_SERVICES_SUPPORTED.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_DELETE_OBJECT, true);

            BaCSharpObject.OnExternalCOVNotify += new BaCSharpObject.WriteNotificationCallbackHandler(handler_OnCOVManagementNotify);

            bacnet_client.Start();    // go
            // Send Iam
            bacnet_client.Iam(deviceId, new BacnetSegmentations());
            bacnet_client.OnWhoIs += new BacnetClient.WhoIsHandler(handler_OnWhoIs);

            if ((_device.FindBacnetObjectType(BacnetObjectTypes.OBJECT_NOTIFICATION_CLASS)) || (_device.FindBacnetObjectType(BacnetObjectTypes.OBJECT_SCHEDULE)))
            {
                bacnet_client.WhoIs();                          // Send WhoIs : needed BY Notification & Schedule for deviceId<->IP endpoint
                device.SetIpEndpoint(bacnet_client);            // Register the endpoint for IP Notification usage with IP:Port
            }
        }
コード例 #19
0
    public void OnSubscribeClick(int buttonID)
    {
        if (buttonID >= 0 && buttonID < 4)
        {
            DeviceObject device                   = FoundDeviceListScript.DeviceAddressList[buttonID];
            string       subscribedService        = Services[buttonID];
            string       subscribedCharacteristic = Characteristics[buttonID];

            if (!string.IsNullOrEmpty(subscribedService) && !string.IsNullOrEmpty(subscribedCharacteristic))
            {
                BluetoothLEHardwareInterface.Log("subscribing to: " + subscribedService + ", " + subscribedCharacteristic);

                BluetoothLEHardwareInterface.SubscribeCharacteristic(device.Address, subscribedService, subscribedCharacteristic, null, (characteristic, bytes) => {
                    BluetoothLEHardwareInterface.Log("received data: " + characteristic);
                });
            }
        }
    }
コード例 #20
0
        public void StartActivity(DeviceObject _device)
        {
            deviceId = _device.PROP_OBJECT_IDENTIFIER.instance;
            device   = _device;

            // Bacnet on UDP/IP/Ethernet
            bacnet_client = new BacnetClient(new BacnetIpUdpProtocolTransport(0xBAC0, false));

            bacnet_client.OnIam += new BacnetClient.IamHandler(handler_OnIam);
            bacnet_client.OnReadPropertyRequest         += new BacnetClient.ReadPropertyRequestHandler(handler_OnReadPropertyRequest);
            bacnet_client.OnReadPropertyMultipleRequest += new BacnetClient.ReadPropertyMultipleRequestHandler(handler_OnReadPropertyMultipleRequest);
            bacnet_client.OnWritePropertyRequest        += new BacnetClient.WritePropertyRequestHandler(handler_OnWritePropertyRequest);
            bacnet_client.OnSubscribeCOV         += new BacnetClient.SubscribeCOVRequestHandler(handler_OnSubscribeCOV);
            bacnet_client.OnSubscribeCOVProperty += new BacnetClient.SubscribeCOVPropertyRequestHandler(handler_OnSubscribeCOVProperty);
            bacnet_client.OnReadRange            += new BacnetClient.ReadRangeHandler(handler_OnReadRange);
            // A sample to shows CreateObject & DeleteObject
            bacnet_client.OnCreateObjectRequest += new BacnetClient.CreateObjectRequestHandler(handler_OnCreateObjectRequest);
            device.m_PROP_PROTOCOL_SERVICES_SUPPORTED.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_CREATE_OBJECT, true);
            bacnet_client.OnDeleteObjectRequest += new BacnetClient.DeleteObjectRequestHandler(handler_OnDeleteObjectRequest);
            device.m_PROP_PROTOCOL_SERVICES_SUPPORTED.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_DELETE_OBJECT, true);

            BaCSharpObject.OnExternalCOVNotify += new BaCSharpObject.WriteNotificationCallbackHandler(handler_OnCOVManagementNotify);

            try
            {
                bacnet_client.Start();    // go
                // Send Iam
                bacnet_client.Iam(deviceId, BacnetSegmentations.SEGMENTATION_BOTH, 61440);
                bacnet_client.OnWhoIs += new BacnetClient.WhoIsHandler(handler_OnWhoIs);

                if ((_device.FindBacnetObjectType(BacnetObjectTypes.OBJECT_NOTIFICATION_CLASS)) || (_device.FindBacnetObjectType(BacnetObjectTypes.OBJECT_SCHEDULE)))
                {
                    bacnet_client.WhoIs();                          // Send WhoIs : needed BY Notification & Schedule for deviceId<->IP endpoint
                    device.SetIpEndpoint(bacnet_client);            // Register the endpoint for IP Notification usage with IP:Port
                }
            }
            catch
            {
                if (Environment.UserInteractive)
                {
                    Console.WriteLine("\nSocket Error, Udp Port already in used in exclusive mode ?");
                }
            }
        }
コード例 #21
0
 public static void ConnectBSN()
 {
     Debug.Log("entrando conect");
     foreach (DeviceObject deviceBiox in FoundDeviceList.DeviceAddressList)
     {
         Debug.Log("entrando device");
         //Buttons[buttonID++].text = device.Name
         if (deviceBiox.Name.Contains("Biox") || deviceBiox.Name.Contains("BIOX") || deviceBiox.Name.Contains("bsn") || deviceBiox.Name.Contains("BSN"))
         {
             bsnDevice = deviceBiox;
             Debug.Log(bsnDevice.Name);
             BluetoothLEHardwareInterface.ConnectToPeripheral(bsnDevice.Address, (address) =>
             {
             }, null, (address, service, characteristic) =>
             {
                 Debug.Log("xDDAdress: " + address + " Service: " + service + " Characteristic: " + characteristic);
             }, null);
         }
     }
 }
コード例 #22
0
 //Start Bluetooth Low Energy and search BSN devices
 public static bool FindBSN()
 {
     Debug.Log("TENTANDO ESCANEAR");
     FoundDeviceList.DeviceAddressList = new List <DeviceObject>();
     BluetoothLEHardwareInterface.Initialize(true, false, () =>
     {
         BluetoothLEHardwareInterface.ScanForPeripheralsWithServices(null, (address, name) =>
         {
             Debug.Log("ADRESS = " + address + " NAME = " + name);
             if (name.Contains("Biox") || name.Contains("BIOX") || name.Contains("bsn") || name.Contains("BSN"))
             {
                 bsnDevice = new DeviceObject(address, name);
                 FoundDeviceList.DeviceAddressList.Add(bsnDevice);
             }
         }, null);
     }, (error) =>
     {
     });
     Debug.Log("FINALIZOU ESCANEAR");
     return(true);
     //Debug.Log(">>>>>>" + FoundDeviceList.DeviceAddressList.Count);
 }
コード例 #23
0
        /// <summary>
        /// 设置对象属性
        /// </summary>
        private void SetObjectPro()
        {
            if (this.panel1.m_pCurrentObject == null)
            {
                return;
            }
            this.panel1.InvalidateCurrentObject();

            ObjectPro    objdialog = new ObjectPro();
            DeviceObject m_temp    = (DeviceObject)this.panel1.m_pCurrentObject;

            objdialog.m_pro    = m_temp.m_pro;
            objdialog.obj_id   = m_temp.equid;
            objdialog.obj_name = m_temp.equName;
            objdialog.m_obj    = m_temp;
            if (objdialog.ShowDialog() == DialogResult.OK)
            {
                m_temp.m_pro   = objdialog.m_pro;
                m_temp.equid   = objdialog.obj_id;
                m_temp.equName = objdialog.obj_name;
            }
            this.panel1.DrawCurrentObject();
        }
コード例 #24
0
        internal DeviceHandler(DeviceObject device, JDownloaderApiHandler apiHandler, LoginObject loginObject, bool useJdownloaderApi = false)
        {
            _device      = device;
            _apiHandler  = apiHandler;
            _loginObject = loginObject;

            Accounts           = new Accounts(_apiHandler, _device);
            AccountsV2         = new AccountsV2(_apiHandler, _device);
            Captcha            = new Captcha(_apiHandler, _device);
            CaptchaForward     = new CaptchaForward(_apiHandler, _device);
            Config             = new Config(_apiHandler, _device);
            Dialogs            = new Dialogs(_apiHandler, _device);
            DownloadController = new DownloadController(_apiHandler, _device);
            DownloadsV2        = new DownloadsV2(_apiHandler, _device);
            Extensions         = new Extensions(_apiHandler, _device);
            Extraction         = new Extraction(_apiHandler, _device);
            LinkCrawler        = new LinkCrawler(_apiHandler, _device);
            LinkgrabberV2      = new LinkGrabberV2(_apiHandler, _device);
            Update             = new Update(_apiHandler, _device);
            Jd     = new Jd(_apiHandler, _device);
            System = new Namespaces.System(_apiHandler, _device);
            DirectConnect(useJdownloaderApi);
        }
コード例 #25
0
    public void OnSubscribeClick(int buttonID)
    {
        if (buttonID >= 0 && buttonID < 4)
        {
            DeviceObject device                   = FoundDeviceListScript.DeviceAddressList[buttonID];
            string       subscribedService        = Services[buttonID];
            string       subscribedCharacteristic = Characteristics[buttonID];

            if (Connected[buttonID])
            {
                BluetoothLEHardwareInterface.Log("subscribing to: " + subscribedService + ", " + subscribedCharacteristic);

                BluetoothLEHardwareInterface.SubscribeCharacteristic(device.Address, subscribedService, subscribedCharacteristic, null, (characteristic, bytes) =>
                {
                    string s = ASCIIEncoding.UTF8.GetString(bytes);
                    //int ID = s[0];
                    //ID -= 49;
                    Text button = ReceivedData[buttonID];
                    button.text = s;
                    BluetoothLEHardwareInterface.Log("received data: " + characteristic);
                });
            }
        }
    }
コード例 #26
0
 internal Extraction(JDownloaderApiHandler apiHandler, DeviceObject device)
 {
     ApiHandler = apiHandler;
     Device     = device;
 }
コード例 #27
0
        void InitBacnetDictionary()
        {
            uint deviceId;

            if (UInt32.TryParse(BacnetDeviceId, out deviceId) == false)
            {
                deviceId = 12345; // default value
            }
            device = new DeviceObject(deviceId, "Weather2 to Bacnet ", "Weather2 data", false);

            if ((UserAccessKey != null) && (Latitude != null) && (Longitude != null))
            {
                Temp = new AnalogInput <float>
                       (
                    0,
                    "Temperature",
                    "Temperature",
                    0,
                    BacnetUnitsId.UNITS_DEGREES_CELSIUS
                       );

                // 24h trendlog
                TrendTemp = new TrendLog(0, "Temperature Trend", "Temperature Trend", 6 * 24, BacnetTrendLogValueType.TL_TYPE_SIGN);

                Windspeed = new AnalogInput <float>
                            (
                    1,
                    "Windspeed",
                    "Wind speed",
                    0,
                    BacnetUnitsId.UNITS_KILOMETERS_PER_HOUR
                            );
                Humidity = new AnalogInput <float>
                           (
                    2,
                    "Humidity",
                    "Humidity",
                    0,
                    BacnetUnitsId.UNITS_PERCENT
                           );
                Pressure = new AnalogInput <float>
                           (
                    3,
                    "Pressure",
                    "Pressure",
                    0,
                    BacnetUnitsId.UNITS_HECTOPASCALS
                           );

                DewPoint = new AnalogInput <float>
                           (
                    4,
                    "DewPoint",
                    "Dew Point",
                    0,
                    BacnetUnitsId.UNITS_DEGREES_CELSIUS
                           );

                VaporPressure = new AnalogInput <float>
                                (
                    5,
                    "VaporPressure",
                    "Equilibrium Vapor Pressure",
                    0,
                    BacnetUnitsId.UNITS_HECTOPASCALS
                                );

                Windsdir = new CharacterString
                               (0, "Winddir", "Wind Direction", "Not available", false);

                WeatherDescr = new CharacterString
                                   (1, "WeatherDescr", "Weather Description", "Not available", false);

                SunRise        = new BacnetDateTime(0, "Sunrise", "Sun up time");
                SunSet         = new BacnetDateTime(1, "Sunset", "Sun down time");
                Updatetime     = new BacnetDateTime(2, "Updatetime", "Date & Time of the current values");
                NextUpdatetime = new BacnetDateTime(3, "NextUpdatetime", "Date & Time of the next request");

                device.AddBacnetObject(Temp);
                device.AddBacnetObject(TrendTemp);
                device.AddBacnetObject(Windspeed);
                device.AddBacnetObject(Humidity);
                device.AddBacnetObject(Pressure);
                device.AddBacnetObject(DewPoint);
                device.AddBacnetObject(VaporPressure);
                device.AddBacnetObject(Windsdir);
                device.AddBacnetObject(WeatherDescr);
                device.AddBacnetObject(SunRise);
                device.AddBacnetObject(SunSet);
                device.AddBacnetObject(Updatetime);
                device.AddBacnetObject(NextUpdatetime);
                device.AddBacnetObject(new NotificationClass(0, "Notification", "Notification"));
            }
            else
            {
                device.m_PROP_SYSTEM_STATUS = BacnetDeviceStatus.NON_OPERATIONAL;
            }

            // Force the JIT compiler to make some job before network access
            device.Cli2Native();
            BacnetActivity.StartActivity(device);
        }
コード例 #28
0
 internal Config(JDownloaderApiHandler apiHandler, DeviceObject device)
 {
     ApiHandler = apiHandler;
     Device     = device;
 }
コード例 #29
0
 public AccountsV2(DeviceObject device, LoginObject loginObject) : base(device, loginObject, "accountsV2")
 {
 }
コード例 #30
0
 public virtual bool DeleteObject(DeviceObject deviceObject)
 {
     throw new NotImplementedException();
 }