Ejemplo n.º 1
0
 public void Execute(Client client, Imagination.Model.Object lwm2mObject, List <Model.Property> properties)
 {
     foreach (Model.Property item in properties)
     {
         DataAccessFactory.Servers.Execute(client, lwm2mObject.ObjectDefinitionID, lwm2mObject.InstanceID, item);
     }
 }
Ejemplo n.º 2
0
 public Imagination.Model.Object GetObject(Client client, Guid objectDefinitionID, string instanceID)
 {
     Imagination.Model.Object    result  = null;
     Service.ILWM2MServerService service = GetService(client.Server);
     lock (service)
     {
         result = service.GetObject(client.ClientID, objectDefinitionID, instanceID);
     }
     return(result);
 }
Ejemplo n.º 3
0
 public void SaveObject(Client client, Imagination.Model.Object lwm2mObject, Model.TObjectState state)
 {
     Service.ILWM2MServerService service = GetService(client.Server);
     lock (service)
     {
         string instanceID = service.SaveObject(client.ClientID, lwm2mObject, state);
         if (!string.IsNullOrEmpty(instanceID))
         {
             lwm2mObject.InstanceID = instanceID;
         }
     }
 }
Ejemplo n.º 4
0
        public Imagination.Model.Object GetObject(Guid clientID, Guid objectDefinitionID, string instanceID)
        {
            Imagination.Model.Object result = null;
            IPCRequest request = new IPCRequest();

            request.Method = "GetObject";
            request.AddToPayload(clientID);
            request.AddToPayload(objectDefinitionID);
            request.AddToPayload(instanceID);
            SendRequest(request);
            if (_ResponseBytes.Length > 0)
            {
                result = Imagination.Model.Object.Deserialise(new MemoryStream(_ResponseBytes));
            }
            return(result);
        }
Ejemplo n.º 5
0
        public string SaveObject(Guid clientID, Imagination.Model.Object item, Model.TObjectState state)
        {
            string     result  = null;
            IPCRequest request = new IPCRequest();

            request.Method = "SaveObject";
            request.AddToPayload(clientID);
            item.Serialise(request.Payload);
            request.AddToPayload((int)state);
            SendRequest(request);
            if (_ResponseBytes.Length > 0)
            {
                CheckError();
                result = Encoding.UTF8.GetString(_ResponseBytes, 4, _ResponseBytes.Length - 4);
            }
            return(result);
        }
Ejemplo n.º 6
0
        public async void SetStringResource()
        {
            // Arrange
            string expectedValue    = "Imagination Technologies 123";
            string objectTypeID     = "3";
            string objectInstanceID = "0";
            string resourceID       = "0";

            await _HttpClientFixture.Login();

            ObjectInstance matchedObjectInstance = await _HttpClientFixture.GetObjectInstanceModel(_TestClient.ClientID, objectTypeID, objectInstanceID);

            Assert.NotNull(matchedObjectInstance);

            Imagination.Model.PropertyDefinition propertyDefinition = _HttpClientFixture.GetResourceDefinition(matchedObjectInstance.ObjectDefinition, resourceID);
            Assert.NotNull(propertyDefinition);

            Imagination.Model.Object   objectModel   = new Imagination.Model.Object();
            Imagination.Model.Property propertyToSet = new Imagination.Model.Property();
            propertyToSet.PropertyDefinitionID = propertyDefinition.PropertyDefinitionID;
            propertyToSet.PropertyID           = propertyDefinition.PropertyID;
            propertyToSet.Value = new Imagination.Model.PropertyValue(expectedValue);
            objectModel.Properties.Add(propertyToSet);

            ObjectInstance objectInstanceToSet = new ObjectInstance(matchedObjectInstance.ObjectDefinition, objectModel);

            Link selfLink = matchedObjectInstance.GetLink("self");

            Assert.NotNull(selfLink);

            HttpResponseMessage response = await _HttpClientFixture.SetClientObject(selfLink.href, objectInstanceToSet);

            Assert.True(response.IsSuccessStatusCode);

            // Act
            IResource resource = _TestClient.GetResource($"{objectTypeID}/{objectInstanceID}/{resourceID}");

            Assert.NotNull(resource);
            string actualValue = (resource as LWM2MResource).ToString();

            // Assert
            Assert.Equal(expectedValue, actualValue);
        }
Ejemplo n.º 7
0
 public void SaveObject(Client client, Imagination.Model.Object lwm2mObject, Model.TObjectState state)
 {
     DataAccessFactory.Servers.SaveObject(client, lwm2mObject, state);
 }