/* All user scripts should derive from the base "Application" class */ require ("Application"); require ("ModelSupport"); /* Applications share the execution thread and the global name * space, so we create a class that contains all of the functions * and variables for the application. This does two things: * 1) creates a private name space for the application, and * 2) allows you to re-load the application to create either * a new unique instance or multiple instances without * damaging an existing running instance. */ class CreateTagWithHierarchy Application { // Defining this globally so tags can be created from anywhere in the script me; } /* Use methods to create functions outside the 'main line'. */ method CreateTagWithHierarchy.writePointWithHierarchy (tag, value) { // Create the point mapping .me.MapPoint(tag); // 'Publish'/Emit the point with a definted Hierarchy .me.Emit(); //Write the specified value to the new point datahub_write(tag,value); } /* Write the 'main line' of the program here. */ method CreateTagWithHierarchy.constructor () { // The ModelEmitter will be used to create the point with a hierarchy .me = new ModelEmitter(); .writePointWithHierarchy("domain:level1.level2.level3.level4.tag1",1); } /* Any code to be run when the program gets shut down. */ method CreateTagWithHierarchy.destructor () { } /* Start the program by instantiating the class. If your * constructor code does not create a persistent reference to * the instance (self), then it will be destroyed by the * garbage collector soon after creation. If you do not want * this to happen, assign the instance to a global variable, or * create a static data member in your class to which you assign * 'self' during the construction process. ApplicationSingleton() * does this for you automatically. */ ApplicationSingleton (CreateTagWithHierarchy);