NamedMaps: Difference between revisions
New page: ==Overview== Named maps are a convenience feature for compost that was added to GibbsCAM 9.0 (8.9.80) to help post developers store and retrieve data. This type of storage and retrieval is... |
|||
| Line 34: | Line 34: | ||
Keys can be any numeric value, whole or decimal. There is no effective limit to the number of keys a post can use in a single map. | Keys can be any numeric value, whole or decimal. There is no effective limit to the number of keys a post can use in a single map. | ||
== Usage | == Usage == | ||
Maps are most commonly used in MTM machines to track items from one flow to another. A common need is for the operations in flow 2 to need to know what the spindle speed and/or direction in flow 1 was. This is often accomplished by using specialized code in the VMM to store values associated with one or more Sync IDs. | Maps are most commonly used in MTM machines to track items from one flow to another. A common need is for the operations in flow 2 to need to know what the spindle speed and/or direction in flow 1 was. This is often accomplished by using specialized code in the VMM to store values associated with one or more Sync IDs. | ||
Revision as of 18:05, 28 April 2009
Overview
Named maps are a convenience feature for compost that was added to GibbsCAM 9.0 (8.9.80) to help post developers store and retrieve data. This type of storage and retrieval is common for specific types of MTM machines.
Maps
Maps are a data structure that will store a value with an associated key. This type of storage allows for easy access and retrieval of data if the key value is known.
Previously in compost map type structures were done using heroic use of the Save# and Recall# commands. This can be cumbersome and confusing, specially when more then one value is needed for each key. Before GibbsCAM 6.0 these variable based maps could only use the whole numbers 1 to 100 as key values.
Implementation
Maps are implemented with 3 simple commands.
Saving data in a map
To save data in a map and associate it with a key, the command SetMap# is used.
SetMap# ('MyMap') Operation# SpeedRPM#
This example will save the current speed into the map, and associated to the current operation number, as it's key.
Retrieving data from a map
To access the data store in a map, by the key, the command GetMap# is used.
GetMap# ('MyMap') Operation#
This example would return the value that was associated with the operation number, in this case, the value of SpeedRPM# at the time the map was set.
Clearing a map
If the data in the map is not longer needed, or the map needs to be reused, the post can call the command ClearMap to remove all data in the map.
ClearMap('MyMap')
All maps are cleared at the start of posting.
Names
Named Maps in compost, by definition have a name. The name is any valid string literal, and defines an grouping for all the key/value pairs. Each name defines a unique data structure and can share keys with other maps with out problems. Names are case sensitive and can be up to 255 characters long. There is no effective limit to the number of maps a post can use.
Keys
Keys can be any numeric value, whole or decimal. There is no effective limit to the number of keys a post can use in a single map.
Usage
Maps are most commonly used in MTM machines to track items from one flow to another. A common need is for the operations in flow 2 to need to know what the spindle speed and/or direction in flow 1 was. This is often accomplished by using specialized code in the VMM to store values associated with one or more Sync IDs.
This can now be done in compost by simply doing the following;
In flow 1 when the speed is computed.
SetMap#('SyncSpeedMap') OpStartSync# SpeedRPM#
In flow 2, when the speed is needed,
GetMap#('SyncSpeedMap') OpStartSync#
This is a much cleaner way then the older variable implementation where conflicts between key names and other variables woudl require mathematical tricks to work out.
Save# Add# OpStartSync# Num#('1000') SpeedRPM#
and
Recall# Add# OpStartSync# Num#('1000')