Converting a Data Event Variable to a Level
davegrov
Junior Member
I am parsing out a light level form a lighting program and want to convert it to a level to send to a T.
How do I convert a variable to a value that can be sent to a TP Bargraph?
How do I convert a variable to a value that can be sent to a TP Bargraph?
Comments
-
Have you tried SEND_LEVEL? Sounds like the right thing to do in your application.
-
My Code
STRING:
{
SELECT
{
ACTIVE(FIND_STRING(DATA.TEXT,'DL,',1)):
{
ltLevel = (RIGHT_STRING(DATA.TEXT,2))
nLight = ((MID_STRING(DATA.TEXT,7,2))
SEND_LEVEL dvTP_Lights, ATOI(nlight+9), ATOI(ltLevel)
}
}
} -
this is too funny, a month or so ago I had reason to look at a very similar question. Here's what I did (it works):
if(find_string(data.text,'DL,[',1)) { remove_string(sTextBuffer,':',1) nzone = atoi(sTextBuffer) remove_string(sTextBuffer,',',1) nlightLevel[nZone] = type_cast(type_cast(atoi(sTextBuffer)) * 2.55) send_level dvTPLights, nLightLevelNbr[nZone], nLightLevel[nZone] }
Should we have a separate thread combining all these type of questions? Time's wasting. -
Still a novice here
What does the TYPE_CAST do?
I'm still stumped.
ACTIVE(find_string(data.text,'DL,,50
{
stextBuffer=(DATA.TEXT)
remove_string(sTextBuffer,':',1) // sTextBuffer Now = 4],50
nLightzone= atoi(sTextBuffer) //nLightzone= ? sTextBuffer is =4],50
remove_string(sTextBuffer,',',1) //sTextBuffer = 50
nlightLevel[nLightzone] = type_cast(type_cast(atoi((sTextBuffer)) + 9))
send_level dvTP_Lights, nlightLevel[nLightzone], nlightLevel[nLightzone]
} -
davegrov wrote:
Allows you to put a float or double into an integer w/o producing a compiler warning. The result of n x 2.55 would require a var delcared as a float or double to contain it. Type Cast allows you to scrap the decimal portion of the result w/o the warning.What does the TYPE_CAST do?
If the lights are 0-100 based I would forgo the multiplication and just make the bargragh 0-100 too and then send straight level values w/o conversion.//Request the current intensity of processor 1, link 1, MI address 0, RPM module 2, zone 4 // //DL, [01:01:00:02:04], 50 //RPM dimmer if(find_string(DATA.TEXT,'DL,[',1)) //DL, [01:04:03:05:07], 50 //H48 dimmer { STACK_VAR INTEGER nProcessor ; STACK_VAR INTEGER nLink ; STACK_VAR INTEGER nRouter ; STACK_VAR INTEGER nBus ; STACK_VAR INTEGER nDimmer ; STACK_VAR INTEGER nLevel ; nProcessor = atoi(remove_string(DATA.TEXT,':',1)) ; nLink = atoi(remove_string(DATA.TEXT,':',1)) ; if(nLink < 8) { nRouter = atoi(remove_string(DATA.TEXT,':',1)+1) ;//add 1 so it's not zero base nBus = atoi(remove_string(DATA.TEXT,':',1)) ; nDimmer = atoi(remove_string(DATA.TEXT,',',1)) ; } else //RF Dimmer { nRouter = 0 ; //no router for RF dimmers nBus = atoi(remove_string(DATA.TEXT,':',1)) ; nDimmer = atoi(remove_string(DATA.TEXT,',',1)) ; } nLevel = atoi(DATA.TEXT) ; //create a structure or array to hold values globally nDimZone[(*do math on above vars based on your system configuration*)] = nLevel ; SEND_LEVEL dvTPLights,1 (*level channel*), nLevel ; }
Now depending on the value received you may stil need to convert from ascii to integer like above.
Leave a Comment
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
