예제 #1
0
        public static IntegerResources Deserialise(TlvReader reader)
        {
            IntegerResources result = null;

            if (reader.TlvRecord == null)
            {
                reader.Read();
            }
            if (reader.TlvRecord != null)
            {
                if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.MultipleResources)
                {
                    result = new IntegerResources(reader.TlvRecord.Identifier.ToString());
                    if (reader.TlvRecord.Value != null)
                    {
                        using (TlvReader childReader = new TlvReader(reader.TlvRecord.Value))
                        {
                            while (childReader.Read())
                            {
                                if (childReader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ResourceInstance)
                                {
                                    IntegerResource childResource = new IntegerResource(childReader.TlvRecord.Identifier.ToString());
                                    childResource.Value = childReader.TlvRecord.ValueAsInt64();
                                    result.Add(childResource);
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
예제 #2
0
 public static IntegerResources Deserialise(TlvReader reader)
 {
     IntegerResources result = null;
     if (reader.TlvRecord == null)
         reader.Read();
     if (reader.TlvRecord != null)
     {
         if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.MultipleResources)
         {
             result = new IntegerResources(reader.TlvRecord.Identifier.ToString());
             if (reader.TlvRecord.Value != null)
             {
                 using (TlvReader childReader = new TlvReader(reader.TlvRecord.Value))
                 {
                     while (childReader.Read())
                     {
                         if (childReader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ResourceInstance)
                         {
                             IntegerResource childResource = new IntegerResource(childReader.TlvRecord.Identifier.ToString());
                             childResource.Value = childReader.TlvRecord.ValueAsInt64();
                             result.Add(childResource);
                         }
                     }
                 }
             }
         }
     }
     return result;
 }
예제 #3
0
        public override bool Deserialise(TlvReader reader)
        {
            bool result = false;

            while (reader.Read())
            {
                if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
                {
                    switch ((ResourceID)reader.TlvRecord.Identifier)
                    {
                    case ResourceID.ObjectID:
                        this.ObjectID = reader.TlvRecord.ValueAsInt64();
                        result        = true;
                        break;

                    case ResourceID.ObjectInstanceID:
                        this.ObjectInstanceID = reader.TlvRecord.ValueAsInt64();
                        result = true;
                        break;

                    case ResourceID.ACLs:
                        this.ACLs = IntegerResources.Deserialise(reader);
                        result    = true;
                        break;

                    case ResourceID.AccessControlOwner:
                        this.AccessControlOwner = reader.TlvRecord.ValueAsInt64();
                        result = true;
                        break;

                    default:
                        break;
                    }
                }
            }
            return(result);
        }
예제 #4
0
        public void LoadDefaultResources()
        {
            DeviceResources deviceResources = new DeviceResources();
            IntegerResources availablePowerSources = new IntegerResources(string.Empty);
            availablePowerSources.Add(new IntegerResource("0") { Value = 1 });
            availablePowerSources.Add(new IntegerResource("1") { Value = 5 });

            IntegerResources powerSourceVoltage = new IntegerResources(string.Empty);
            powerSourceVoltage.Add(new IntegerResource("0") { Value = 3800 });
            powerSourceVoltage.Add(new IntegerResource("1") { Value = 5000 });

            IntegerResources powerSourceCurrent = new IntegerResources(string.Empty);
            powerSourceCurrent.Add(new IntegerResource("0") { Value = 3800 });
            powerSourceCurrent.Add(new IntegerResource("1") { Value = 5000 });

            IntegerResources errorCode = new IntegerResources(string.Empty);
            errorCode.Add(new IntegerResource("0") { Value = 0 });

            deviceResources.Add(new DeviceResource() { Manufacturer = "Open Mobile Alliance", ModelNumber = "Lightweight M2M Client", SerialNumber = "345000123", FirmwareVersion = "1.0", AvailablePowerSources = availablePowerSources, PowerSourceVoltages = powerSourceVoltage, PowerSourceCurrents = powerSourceCurrent, BatteryLevel = 100, MemoryFree = 15, ErrorCodes = errorCode, CurrentTime = DateTime.UtcNow, UTCOffset = "+12:00", SupportedBindingandModes = "U" });

            ConnectivityMonitoringResources connectivityMonitoringResources = new ConnectivityMonitoringResources();
            IntegerResources availableNetworkBearer = new IntegerResources(string.Empty);
            availableNetworkBearer.Add(new IntegerResource("0") { Value = 0 });

            StringResources ipAddresses = new StringResources(string.Empty);
            ipAddresses.Add(new StringResource("0") { Value = "192.168.148.18" });

            StringResources routerIPAddresse = new StringResources(string.Empty);
            routerIPAddresse.Add(new StringResource("0") { Value = "192.168.148.1" });

            StringResources apn = new StringResources(string.Empty);
            apn.Add(new StringResource("0") { Value = "internet" });

            connectivityMonitoringResources.Add(new ConnectivityMonitoringResource() { NetworkBearer = 0, AvailableNetworkBearers = availableNetworkBearer, RadioSignalStrength = 92, LinkQuality = 2, IPAddresses = ipAddresses, RouterIPAddresses = routerIPAddresse, LinkUtilization = 5, APNs = apn });
            this.AddResources(deviceResources);
            this.AddResources(connectivityMonitoringResources);
            this.AddResources(new FirmwareUpdateResources());
            FlowObjectResources flowObjectResources = new FlowObjectResources();
            FlowObjectResource flowObjectResource = new FlowObjectResource() { DeviceType = "EVOKE Flow", TenantID = 1 };
            flowObjectResource.Updated +=  new EventHandler(FlowObject_Updated);
            flowObjectResources.Add(flowObjectResource);

            this.AddResources(flowObjectResources);
            this.AddResources(new FlowAccessResources());

            FlowCommandResources flowCommandResources = new FlowCommandResources();
            EventHandler<ChildCreatedEventArgs> handler = (s, e) =>
            {
                FlowCommandResource flowCommandResource = e.Resource as FlowCommandResource;
                if (flowCommandResource != null)
                {
                    flowCommandResource.Updated += new EventHandler(FlowCommand_Updated);
                    FlowCommand_Updated(flowCommandResource, null);
                }
            };
            flowCommandResources.ChildCreated += handler;
            this.AddResources(flowCommandResources);

            LocationResources locationResources = new LocationResources();
            locationResources.Add(new LocationResource() { Latitude = "-41.0", Longitude = "174.0", Altitude = "150", Uncertainty = "1.0", Velocity = new byte[] { 0, 45, 0, 0 }, Timestamp = DateTime.UtcNow });
            this.AddResources(locationResources);

            DeviceCapabilityResources deviceCapabilityResources = new DeviceCapabilityResources();
            deviceCapabilityResources.Add(new DeviceCapabilityResource("0") { Attached = true, Enabled = true, Group = 0, Description = "Temp", Property = "2;3" });
            deviceCapabilityResources.Add(new DeviceCapabilityResource("1") { Attached = true, Enabled = true, Group = 1, Description = "Control", Property = "1;2" });
            deviceCapabilityResources.Add(new DeviceCapabilityResource("2") { Attached = true, Enabled = false, Group = 2, Description = "Bluetooth", Property = "0" });
            deviceCapabilityResources.Add(new DeviceCapabilityResource("3") { Attached = false, Enabled = false, Group = 2, Description = "WiFi", Property = "2" });

            this.AddResources(deviceCapabilityResources);
        }
        public override bool Deserialise(TlvReader reader)
        {
            bool result = false;

            while (reader.Read())
            {
                if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
                {
                    if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
                    {
                        this.Name = reader.TlvRecord.Identifier.ToString();
                    }
                    reader = new TlvReader(reader.TlvRecord.Value);
                }
                else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
                {
                    switch ((ResourceID)reader.TlvRecord.Identifier)
                    {
                    case ResourceID.NetworkBearer:
                        this.NetworkBearer = reader.TlvRecord.ValueAsInt64();
                        result             = true;
                        break;

                    case ResourceID.AvailableNetworkBearers:
                        this.AvailableNetworkBearers = IntegerResources.Deserialise(reader);
                        result = true;
                        break;

                    case ResourceID.RadioSignalStrength:
                        this.RadioSignalStrength = reader.TlvRecord.ValueAsInt64();
                        result = true;
                        break;

                    case ResourceID.LinkQuality:
                        this.LinkQuality = reader.TlvRecord.ValueAsInt64();
                        result           = true;
                        break;

                    case ResourceID.IPAddresses:
                        this.IPAddresses = StringResources.Deserialise(reader);
                        result           = true;
                        break;

                    case ResourceID.RouterIPAddresses:
                        this.RouterIPAddresses = StringResources.Deserialise(reader);
                        result = true;
                        break;

                    case ResourceID.LinkUtilization:
                        this.LinkUtilization = reader.TlvRecord.ValueAsInt64();
                        result = true;
                        break;

                    case ResourceID.APNs:
                        this.APNs = StringResources.Deserialise(reader);
                        result    = true;
                        break;

                    case ResourceID.CellID:
                        this.CellID = reader.TlvRecord.ValueAsInt64();
                        result      = true;
                        break;

                    case ResourceID.SMNC:
                        this.SMNC = reader.TlvRecord.ValueAsInt64();
                        result    = true;
                        break;

                    case ResourceID.SMCC:
                        this.SMCC = reader.TlvRecord.ValueAsInt64();
                        result    = true;
                        break;

                    default:
                        break;
                    }
                }
            }
            return(result);
        }
예제 #6
0
        public override bool Deserialise(TlvReader reader)
        {
            bool result = false;

            while (reader.Read())
            {
                if (reader.TlvRecord.TypeIdentifier == TTlvTypeIdentifier.ObjectInstance)
                {
                    if (string.Compare(this.Name, reader.TlvRecord.Identifier.ToString()) != 0)
                    {
                        this.Name = reader.TlvRecord.Identifier.ToString();
                    }
                    reader = new TlvReader(reader.TlvRecord.Value);
                }
                else if ((reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.ObjectInstance) && (reader.TlvRecord.TypeIdentifier != TTlvTypeIdentifier.NotSet))
                {
                    switch ((ResourceID)reader.TlvRecord.Identifier)
                    {
                    case ResourceID.Manufacturer:
                        this.Manufacturer = reader.TlvRecord.ValueAsString();
                        result            = true;
                        break;

                    case ResourceID.ModelNumber:
                        this.ModelNumber = reader.TlvRecord.ValueAsString();
                        result           = true;
                        break;

                    case ResourceID.SerialNumber:
                        this.SerialNumber = reader.TlvRecord.ValueAsString();
                        result            = true;
                        break;

                    case ResourceID.FirmwareVersion:
                        this.FirmwareVersion = reader.TlvRecord.ValueAsString();
                        result = true;
                        break;

                    case ResourceID.AvailablePowerSources:
                        this.AvailablePowerSources = IntegerResources.Deserialise(reader);
                        result = true;
                        break;

                    case ResourceID.PowerSourceVoltages:
                        this.PowerSourceVoltages = IntegerResources.Deserialise(reader);
                        result = true;
                        break;

                    case ResourceID.PowerSourceCurrents:
                        this.PowerSourceCurrents = IntegerResources.Deserialise(reader);
                        result = true;
                        break;

                    case ResourceID.BatteryLevel:
                        this.BatteryLevel = reader.TlvRecord.ValueAsInt64();
                        result            = true;
                        break;

                    case ResourceID.MemoryFree:
                        this.MemoryFree = reader.TlvRecord.ValueAsInt64();
                        result          = true;
                        break;

                    case ResourceID.ErrorCodes:
                        this.ErrorCodes = IntegerResources.Deserialise(reader);
                        result          = true;
                        break;

                    case ResourceID.CurrentTime:
                        this.CurrentTime = reader.TlvRecord.ValueAsDateTime();
                        result           = true;
                        break;

                    case ResourceID.UTCOffset:
                        this.UTCOffset = reader.TlvRecord.ValueAsString();
                        result         = true;
                        break;

                    case ResourceID.Timezone:
                        this.Timezone = reader.TlvRecord.ValueAsString();
                        result        = true;
                        break;

                    case ResourceID.SupportedBindingandModes:
                        this.SupportedBindingandModes = reader.TlvRecord.ValueAsString();
                        result = true;
                        break;

                    case ResourceID.DeviceType:
                        this.DeviceType = reader.TlvRecord.ValueAsString();
                        result          = true;
                        break;

                    case ResourceID.HardwareVersion:
                        this.HardwareVersion = reader.TlvRecord.ValueAsString();
                        result = true;
                        break;

                    case ResourceID.SoftwareVersion:
                        this.SoftwareVersion = reader.TlvRecord.ValueAsString();
                        result = true;
                        break;

                    case ResourceID.BatteryStatus:
                        this.BatteryStatus = reader.TlvRecord.ValueAsInt64();
                        result             = true;
                        break;

                    case ResourceID.MemoryTotal:
                        this.MemoryTotal = reader.TlvRecord.ValueAsInt64();
                        result           = true;
                        break;

                    default:
                        break;
                    }
                }
            }
            return(result);
        }