Hello
After selecting the fixtures and set the context attribute with:
http://localhost:4430/titan/script/2/Pr ... ibuteId=32
I can get the function Id and the function type:
http://[ip]:4430/titan/get/2/Programmer/Editor/Fixtures/ContextAttribute/FunctionId
http://[ip]:4430/titan/get/2/Programmer/Editor/Fixtures/ContextAttribute/FunctionType
But is possible to get the function name? I mean, when the attributes have enum values, like "open", "close", etc... is possible to get this description?
Thanks for your help...
Get fixture attribute function name
Moderator: Moderators
-
- Posts: 7
- Joined: 13 Apr 2024, 14:36
Re: Get fixture attribute function name
It is a little difficult to get the name of the current function, a way that I have found is to make use of the RefreshPotentialAttributeValues function and then read the AttributeAValue or AttributeBValue properties. These are what are used in the numeric entry menu to show softkey options to set attributes on the wheels to, as this is the case they rely on the attributes being on the current bank/group and page (normally this is separate for WebAPI to the UI).
The following code selects the correct bank based on the controlId number and then looks on each page until it finds the required attribute. The way RefreshPotentialAttributeValues is processed varies depending on whether the current function is fixed or has a range, in the case of the former you need to pass in a level one less than the current function ID for it to return the name of that function. I don't know how reliable this code will be but perhaps this gives you a starting point to work from.
The following code selects the correct bank based on the controlId number and then looks on each page until it finds the required attribute. The way RefreshPotentialAttributeValues is processed varies depending on whether the current function is fixed or has a range, in the case of the former you need to pass in a level one less than the current function ID for it to return the name of that function. I don't know how reliable this code will be but perhaps this gives you a starting point to work from.
Code: Select all
async function getAttribute(attributeName) {
// Get the control we are interested in and change bank/group to the one that contains it
let controlId = await runScript('Programmer/Editor/Fixtures/GetControlIdFromName?controlName=' + attributeName);
runScript('Programmer/Editor/Fixtures/SelectAttributeGroupByControl?controlId=' + controlId + '&wheelPageStride=&wheelAllocation=');
let wheel = -1;
for (let i = 0; i < 10; i++) {
// Check if the attribute we are looking for is on the current page
runScript('Programmer/Editor/Fixtures/SetContextAttributeFromId?attributeId=' + controlId);
wheel = await get('Programmer/Editor/Fixtures/CurrentWheel');
if (wheel >= 0) break;
// Try the next page of attributes
let bank = await get('Programmer/Editor/Fixtures/SelectedAttributeBank');
runScript('Programmer/Editor/Fixtures/SetContextAttributeFromId?attributeId=0');
runScript('Programmer/Editor/Fixtures/SelectAttributeBankWithGroup?bank=' + bank + '&wheelPageStride=&wheelAllocation=');
}
if (wheel >= 0) {
// If the current function type is Fixed we need to set the input level to one less than the function ID to get the current function
let functionType = await get('Programmer/Editor/Fixtures/ContextAttribute/FunctionType');
let level = 0;
if (functionType == 1) level = await get('Programmer/Editor/Fixtures/ContextAttribute/FunctionId') - 1;
// Get values for attributes on the current page
runScript('Programmer/Editor/Fixtures/RefreshPotentialAttributeValues?level=' + level + '&wheelPageStride=');
let chr = String.fromCharCode(65 + wheel); // Wheels are labelled A, B, C...
let id = await get('Programmer/Editor/Fixtures/Attribute' + chr + 'Id');
let name = await get('Programmer/Editor/Fixtures/Attribute' + chr + 'Name');
let functionName = await get('Programmer/Editor/Fixtures/Attribute' + chr + 'Value');
let value = '';
if (functionType != 1) value = await get('Programmer/Editor/Fixtures/ContextAttribute/Value');
functionName = functionName.split(/\r\n|\r|\n/g)[0]; // First line is the function name
document.getElementById('output').value += id + ': ' + name + '\n' + functionName + ' ' + value + '\n';
runScript('Programmer/Editor/Fixtures/SetContextAttributeFromId?attributeId=0');
} else {
document.getElementById('output').value += controlId + ' not found!\n';
}
}
-
- Posts: 7
- Joined: 13 Apr 2024, 14:36
Re: Get fixture attribute function name
Thanks Gregory
I have checked and it seems to work for all attributes I have tried, except with Pattern attribute in Gobos. In this case level = functionId - 1 doesn't match!!!
For example if I select PatternFunc 'Spin' I get this values int 'Pattern' attributes (values changes when changing PatternFunc):
FunctionIds are:
FunctionId 15 = 'Open'
FunctionId 16 = 'Pattern 1'
FunctionId 17 = 'Pattern 2'
But I get empty strings with level 14, 15 and 16 in RefreshPotentialAttributeValues.
And I get the right Strings with level 0, 1, 2 in this case.
All other attributes work fine, only fails Pattern Attribute.
Stange? It fails because functionIds are not 1,2,3,4... as in other attributes, but start in a number greater than 1. The offset depends on the PatternFunction option selected.
Colour attribute also fails... (depending of ColourFunc the FunctionIds have a starting value different than 1)
I have checked and it seems to work for all attributes I have tried, except with Pattern attribute in Gobos. In this case level = functionId - 1 doesn't match!!!
For example if I select PatternFunc 'Spin' I get this values int 'Pattern' attributes (values changes when changing PatternFunc):
FunctionIds are:
FunctionId 15 = 'Open'
FunctionId 16 = 'Pattern 1'
FunctionId 17 = 'Pattern 2'
But I get empty strings with level 14, 15 and 16 in RefreshPotentialAttributeValues.
And I get the right Strings with level 0, 1, 2 in this case.
All other attributes work fine, only fails Pattern Attribute.
Stange? It fails because functionIds are not 1,2,3,4... as in other attributes, but start in a number greater than 1. The offset depends on the PatternFunction option selected.
Colour attribute also fails... (depending of ColourFunc the FunctionIds have a starting value different than 1)
-
- Posts: 7
- Joined: 13 Apr 2024, 14:36
Re: Get fixture attribute function name
Maybe is possible to get the level of a wheel using any API? That returns the level for the current function of the wheel attribute?
I have seen there's a SetAttributeLevel, it doesn't exists a kind of GetAttributeLevel?
I have seen there's a SetAttributeLevel, it doesn't exists a kind of GetAttributeLevel?
Who is online
Users browsing this forum: No registered users and 2 guests