4 Replies Latest reply on Oct 11, 2017 10:28 AM by carlesc RSS
    khayes Explorer

    DATETIME property changing when it shouldn't

    Hi,

     

    I have a DATETIME property named 'Born' which records the time at which a remote thing is created on the server. I create the things via a service I wrote, which monitors for unbound devices and then creates an instance from a template I created. Immediately after the thing is created I set this property to the current time. However, I have noticed that this property updates to a later time periodically, even though I don't have any other service which sets this parameter. At first I thought there might be some old service that was being called that assigned a new time value to it. To check this I exported all my templates to an xml file on my pc and then searched for occurrences of the property 'Born'. Aside from the definition of the property in the template it only occurred in one other place, my create service.

     

    var unboundPrinterTable = Resources["DeviceFunctions"].GetUnboundIdentifiers(maxNum);

    var numPrinters = unboundPrinterTable.rows.length;


    for (var x = 0; x < numPrinters; x++)

    {

         var newPrinter = unboundPrinterTable.rows[x];

       

        thingObj = Things[newPrinter.name] ;

       

         //check to make sure it doesn't exist already

        if(thingObj)

        {

            logger.debug(newPrinter.name+" exist - abort creation!");

        }

        else

        {

              //Create the printer thing here

            var newName = newPrinter.name ;

            try

            {

                var thingParams = {

                    name: newName /* STRING */,

                    description: "auto generated XXXX Remote Printer thing created by SystemMonitor" /* STRING */,

                    thingTemplateName: "XXXRemotePrinterTemplate" /* THINGTEMPLATENAME */,

                    tags: "Applications:LinxCloud v1.0" /* TAGS */

                };

     

     

                // no return

                Resources["EntityServices"].CreateThing(thingParams);

     

     

                var newThing = Things[newName] ;

     

     

                newThing.EnableThing();

                newThing.RestartThing();

     

     

                //var ident = {identifier: params.name /* STRING */};

                var ident = {identifier: newName /* STRING */};

                newThing.SetIdentifier(ident);

     

     

                newThing.DisplayName = newName ;

                var now = new Date();

                newThing.Born = now ;

     

     

                //set up remote bindings to parameters on the edge server

                newThing.CreateRemoteBindings();

                newThing.RestartThing();

            }

            catch(err)

            {

                logger.error("Create new printer fail - err = "+err);

            }

     

    Although most of my things were created months ago the 'Born' value on those things reads as times from earlier today. does anyone have any idea what might be going on?

    thanks. Also a bit odd that all the devices appear have the same updated time

     

    Thanks

    Kieron