/* All user scripts should derive from the base "Application" class */ require ("Application"); /* Get the Gamma library functions and methods for ODBC and/or * Windows programming. Uncomment either or both. */ //require ("WindowsSupport"); //require ("ODBCSupport"); /* 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 MyBridge Application { } /* Use methods to create functions outside the 'main line'. */ method MyBridge.CopyValue (input, output) { local info = PointMetadata(input); datahub_write(string(output), info.value, nil, info.quality, info.timestamp); } method MyBridge.InitializeCopy (input, output) { local code; datahub_command(format("(create %s 1)", stringc(input)), 1); datahub_command(format("(create %s 1)", stringc(output)), 1); code = `(@self).CopyValue(#@input, #@output); .OnChange (input, code); try { if (!undefined_p(eval(input))) eval(code); } catch { princ ("Error during copy initialization: ", input, ": ", _last_error_, "\n"); } } /* Write the 'main line' of the program here. */ method MyBridge.constructor () { .InitializeCopy (#$default:input1, #$default:output1); .InitializeCopy (#$default:input2, #$default:output2); } /* Any code to be run when the program gets shut down. */ method MyBridge.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 (MyBridge);