Skip to content

Instantly share code, notes, and snippets.

@paragontechgroup
Created November 8, 2011 16:09
Show Gist options
  • Save paragontechgroup/1348208 to your computer and use it in GitHub Desktop.
Save paragontechgroup/1348208 to your computer and use it in GitHub Desktop.
Command Fusion Global Tokens
// 1) Created global token (in global token manager) called "ProcessorPort" with default value 8020 and checked persist.
// 2) Created system called "Localhost" to 127.0.0.1
// 3) Created setup page with text input field with serial join 9999 with command "setPort" in "Send Value Actions > command"
// 4) Created command in "Localhost" system called "setPort" with following Javascript:
CF.setToken(CF.GlobalTokensJoin, "[ProcessorPort]", "[@s9999]");
// 5) Made button on setup page called "What is my port" with code:
CF.getJoin(CF.GlobalTokensJoin, function(j, v, tokens) { var guiPort = tokens["[ProcessorPort]"]; CF.setJoins([{join: "s590", value: guiPort}]); });
// This grabs the global token "[ProcessorPort]" and displays it in serial join s590 for testing. All works like a champ until I restart guiDesigner. I'd assume that from a fresh start and navigating to the setup page and pressing the "What is my port" button that the set persistent global token value would be displayed. Also, even from a fresh start pressing the "What is my port" button does not display the peristent global token "[ProcessorPort]" value, I'd think it would at least display 8020 since that was set as the default.
// Also just tested an init.js fle in the script manager with the intention to prepopulate the port input field with the port defined in the global persistent tokens. This seems to have no effect:
// Initialize GUI
CF.userMain = function() {
// iViewer initialization is now complete and the CF environment is fully available
// Read the global context that we need
restoreContext();
};
function restoreContext() {
// Read the contents of the ProcessorPort token
CF.GetJoin(CF.GlobalTokensJoin, function(join, value, tokens) {
var contextStr = tokens["ProcessorPort"];
if (contextStr != null && contextStr.length > 0) {
CF.setJoins([{join: "s9999", value: contextStr}]);
}
});
}
@fpillet
Copy link

fpillet commented Nov 11, 2011

There seems to be an issue with CF.setSystemProperties() where it won't really take the change if you only change the port when accessing the control system using a direct IP address. Thanks for nailing this.

I noted your comments on IRC regarding the fact that setting a different IP address in the GUI, then updating it using CF.setSystemProperties() fails to connect. I'll figure out what's wrong and fix it in a couple days ( and will add proper logging of the address it's trying to connect to in the Script system log for good measure).

Florent

@paragontechgroup
Copy link
Author

paragontechgroup commented Nov 11, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment