public static NotificationParameters Deserialise(Stream stream)
 {
     NotificationParameters result = new NotificationParameters();
     result.MinimumPeriod = IPCHelper.ReadInt32Nullable(stream);
     result.MaximumPeriod = IPCHelper.ReadInt32Nullable(stream);
     result.GreaterThan = IPCHelper.ReadDoubleNullable(stream);
     result.LessThan = IPCHelper.ReadDoubleNullable(stream);
     result.Step = IPCHelper.ReadDoubleNullable(stream);
     return result;
 }
        public static NotificationParameters Deserialise(Stream stream)
        {
            NotificationParameters result = new NotificationParameters();

            result.MinimumPeriod = IPCHelper.ReadInt32Nullable(stream);
            result.MaximumPeriod = IPCHelper.ReadInt32Nullable(stream);
            result.GreaterThan   = IPCHelper.ReadDoubleNullable(stream);
            result.LessThan      = IPCHelper.ReadDoubleNullable(stream);
            result.Step          = IPCHelper.ReadDoubleNullable(stream);
            return(result);
        }
Exemplo n.º 3
0
 public bool SetNotificationParameters(Guid clientID, Guid objectDefinitionID, string instanceID, Guid propertyDefinitionID, NotificationParameters notificationParameters)
 {
     bool result = false;
     try
     {
         LWM2MClient client = BusinessLogicFactory.Clients.GetClient(clientID);
         if (client != null)
         {
             ObjectDefinitionLookups lookups = BusinessLogicFactory.Clients.GetLookups();
             ObjectDefinition objectDefinition = lookups.GetObjectDefinition(objectDefinitionID);
             if (objectDefinition != null)
             {
                 int objectID;
                 if (int.TryParse(objectDefinition.ObjectID, out objectID))
                 {
                     Model.ObjectType objectType = client.SupportedTypes.GetObjectType(objectID);
                     if (objectType != null)
                     {
                         PropertyDefinition propertyDefinition = objectDefinition.GetProperty(propertyDefinitionID);
                         if (propertyDefinition != null)
                         {
                             Request request = client.NewPutRequest(objectType, instanceID, propertyDefinition.PropertyID, -1, null);
                             if (notificationParameters.MinimumPeriod.HasValue)
                                 request.AddUriQuery(string.Concat("pmin=",notificationParameters.MinimumPeriod.Value.ToString()));
                             if (notificationParameters.MaximumPeriod.HasValue)
                                 request.AddUriQuery(string.Concat("pmax=", notificationParameters.MaximumPeriod.Value.ToString()));
                             if (notificationParameters.GreaterThan.HasValue)
                                 request.AddUriQuery(string.Concat("gt=", notificationParameters.GreaterThan.Value.ToString("0.0")));
                             if (notificationParameters.LessThan.HasValue)
                                 request.AddUriQuery(string.Concat("lt=", notificationParameters.LessThan.Value.ToString("0.0")));
                             if (notificationParameters.Step.HasValue)
                                 request.AddUriQuery(string.Concat("stp=", notificationParameters.Step.Value.ToString("0.0")));
                             Response response = client.SendRequest(request).WaitForResponse(LWM2MClient.REQUEST_TIMEOUT);
                             if (response == null)
                             {
                                 throw new TimeoutException();
                             }
                             else
                             {
                                 if (response.StatusCode == StatusCode.Changed)
                                 {
                                     result = true;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ApplicationEventLog.WriteEntry("Flow", ex.ToString(), System.Diagnostics.EventLogEntryType.Error);
     }
     return result;
 }
Exemplo n.º 4
0
 public bool SetNotificationParameters(Client client, Guid objectDefinitionID, string instanceID, Guid propertyDefinitionID, NotificationParameters notificationParameters)
 {
     bool setNotificationParameters = false;
     Service.ILWM2MServerService service = GetService(client.Server);
     lock (service)
     {
         setNotificationParameters = service.SetNotificationParameters(client.ClientID, objectDefinitionID, instanceID, propertyDefinitionID, notificationParameters);
     }
     return setNotificationParameters;
 }
Exemplo n.º 5
0
 public bool SetNotificationParameters(Guid clientID, Guid objectDefinitionID, string instanceID, Guid propertyMetadataID, NotificationParameters notificationParameters)
 {
     bool result = false;
     IPCRequest request = new IPCRequest();
     request.Method = "SetNotificationParameters";
     request.AddToPayload(clientID);
     request.AddToPayload(objectDefinitionID);
     request.AddToPayload(instanceID);
     request.AddToPayload(propertyMetadataID);
     notificationParameters.Serialise(request.Payload);
     SendRequest(request);
     if (_ResponseBytes.Length > 0)
     {
         result = _ResponseBytes[0] != 0x00;
     }
     return result;
 }