API Reference

From Flowcode Help
Revision as of 15:57, 16 January 2014 by JonnyW (talk | contribs) (XML import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

<sidebar>API Contents</sidebar> Flowcode provides an application programming interface to help writing simulation and PC-side programs.

This API is a list of macros built in to Flowcode with each group, or class, of macros dealing with a specific area of the system.

Use of this API is limited to simulation only - when downloaded to the chip these calls will be omitted, so if need be they can be interleaved in downloadable code.

Below is a reference to the classes and macros available:

Component
SetInteractive Sets whether a component can interact with the mouse
GetInteractive Gets whether a component can interact with the mouse
SetVisible Sets whether a component can be seen on the panel
GetVisible Gets whether a component can be seen on the panel
SetSolid Sets whether a component is checked in collision detections
GetSolid Gets whether a component is checked in collision detections
SetCompile Sets whether a component is considered for compilation or not
GetCompile Gets whether a component will be compiled or not
GetInstance Gets the type-instance of the component, >= 1 is valid
FindChild Finds a named object that is part of the component
GetParent Gets the owner of the components handle
GetNext Gets the next (younger) sibling of the components handle
GetLast Gets the previous (elder) sibling of the components handle
GetChildHead Gets the first (eldest) child of the component
GetChildTail Gets the last (youngest) child of the component
GetOriginal Gets the original definition of the component, returns Current if no original copy
Clone Clones an existing object to another position on the panel
Delete Deletes an existing object, removing it from the panel
Component.Property
GetValue Gets the value of a property as a string
SetColor Sets a components 'color' property as a R,G,B value
SetValue Sets a components property as a string
CopyValue Copies a property value from one target to another
SetChildValues Sets all child components property as a string
CopyChildValues Copies the values of a properties children from the source to dest
SetVisible Sets whether the property is visible or not
SetWritable Sets whether the property can be edited in the UI or not
GetVisible Gets whether the property is visible or not
GetWritable Gets whether the property can be edited in the UI or not
GetFilter Gets a components property filter string for lists, files, etc
SetFilter Sets a components property filter string for lists, files, etc
CopyFilter Copies a property filter from one target to another
GetListIndex Gets a single lists index value from a property by line number
GetListItem Gets a single list entry from a property by named index
SetListItem Sets an existing list entries text for the property by named index
AddListItem Alters or appends a list entries text for the property by named index
Panel.Position
Get Gets a handle to an object representing the components current position
GetOrigin Gets a handle to an empty position
Set Sets an objects position based on a component or pre-defined position
SetCoords Sets an objects coordinates based on a position
SetScale Sets an objects scale based on a position
SetRotation Sets an objects orientation based on a position
GetBox Gets a handle to an object representing the components bounding box position
Morph Blends positions from two sources to a destination
Animate Blends positions from two sources to a destination over time
StopAnimate Stops all animations started by this component
MoveAlong Moves the object by the given offset relative to its parent along an axis
MoveBy Moves the object by the given offset relative to its parent
MoveTo Moves the object to the given coordinates relative to its parent
ScaleTo Sets the objects scale to a value
ScaleUp Multiplies the objects scale by a value
ScaleDown Divides the objects scale by a value
RotateTo Rotates the object to the given rotation
RotateAlong Rotates the object by the given rotation along an axis
RotateX Rotates the object around the X axis
RotateY Rotates the object around the Y axis
RotateZ Rotates the object around the Z axis
GetCoords Returns the positions coordinates in (X,Y,Z) array
GetScale Returns the positions scale in (X,Y,Z) array
GetQuat Returns the positions quaternion in (X,Y,Z,W) array
GetEuler Returns the positions euler angles in (P,Y,R) array
Panel.Position.Math
GetDistance Gets the distance between two positions
GetDiff Gets the difference between two positions
Panel.Position.Camera
GetEye Gets a handle to the eye camera position
GetTarget Gets a handle to the target camera position
SetView Sets the eye and target focal point of the camera
SetLookAt Sets the eye and target point of the camera
SetEye Sets the eye point of the camera
SetTarget Sets the target point of the camera
Spin Rotates the camera along its view axis
Panel.PCloud
Create Creates a new point cloud tied to a position handle
SetPos Sets the position for the point cloud to be located at
GetPos Gets the position the point cloud is located at
SetPoints Sets the X,Y,Z point lists
SetPointsEx Sets the X,Y,Z point lists
SetGrid Sets the X,Y,Z point lists in a height-map grid
SetGridEx Sets the X,Y,Z point lists in a height-map grid
SetGridFlat Sets the X,Y,Z point lists in a flat height-map grid
SetGridPoint Given an XY on the grid, sets the vertex value at that point
UnitScale Creates a unit scaled axis (X, Y or Z) with a center of zero and a range of two
SetColor Sets the RGB colour of the entire cloud
SetColors Sets the RGB colour of the individual points in the cloud
SetGridColor Given an XY on the grid, sets the vertex colour at that point
SetMode Sets the rendering mode of the point cloud
SetPointLight Enables or disables simple lighting for point mode, providing a normal passing through the point and (0,0,0)
Update Manually refresh the screen the point cloud exists on
Panel.LinkBar
Create Creates a new bar linking a pair of position handles
SetVisible Sets whether the link is displayed or not
SetStartPos Sets the position for the start point of the bar
SetEndPos Sets the position for the end point of the bar
SetStartAdjustment Sets the clipping adjustments for the beginning of the link
SetEndAdjustment Sets the clipping adjustments for the end of the link
SetStartGfx Sets the graphic for the start point of the bar
SetBarGfx Sets the graphic for the main line of the bar
SetEndGfx Sets the graphic for the end point of the bar
GetStartPos Gets the position the bars start point is located at
GetBarPos Gets the position the bar is located at
GetEndPos Gets the position the bars end point is located at
Update Manually refresh the screen the point cloud exists on
EnableAuto Sets whether Flowcode should automatically draw links for component object property types
Panel.Collision
TestTable Tests whether an object collides with the table top, returns Z distance to move to rest on the table
TestSingle Tests whether an object collides with a position
GetSingleAxis Tests whether an object collides with a position
GetSinglePos Returns the position to move Pos to so it does not collide with Test - null if no collide
GetMultiAxis Tests whether an object collides with a position
GetMultiPos Returns the position to move Pos to so it does not collide with any other object - null if no collide
Panel.Graphics
Redraw Sends a redraw request to the given component
SetColor Sets the draw colour for and subsequent graphics objects
SetColorRGB Sets the draw colour for and subsequent graphics objects
SetTextFont Sets the text font for subsequent text objects
SetTextScale Sets the text scale for subsequent text objects
SetLineThickness Sets the thinkness when drawing lines and points
DrawCreate Creates a drawing area on a shape
DrawBegin Begins drawing on a given shape
DrawEnd Ends drawing started with DrawBegin()
DrawDelete Deletes a drawing area for a shape
DrawText Draws a line of text texture
DrawPoint Draws a point on a texture
DrawLine Draws a line on a texture
DrawLineA Draws a smooth line on a texture
DrawRect Draws a rectangle on a texture
DrawCircle Draws a circle on a texture
Panel.Graphics.Shape
Image Sets the image to draw on the last drawn shape
Mouse
GetButtons Gets the button state from the mouse: 4 for left, 1 for right
GetFocus Gets the handle of the component under the mouse
GetPosition Gets the position of the mouse, intersecting with a component or the viewing plane
GetPosition2D Gets the X/Y position of the mouse in screen coords
GetClickSide Gets the side of the component clicked on, 0 to 5
FCD
GetItemValue Gets a paths item value from the FCD document
GetItemHandle Gets a FCD items handle, suitable for traversal with the Tree API
GetPathHandle Gets a FCD paths handle, suitable for traversal with the Tree API
Sound
Play Plays a formatted file sound, returns true if the sound played OK
LoadWav Loads a wave file into memory, providing the values needed to play it
Create Creates a sound object that data can be played through
SetVolume Sets the volume of playbacks for this sound
GetVolume Gets the volume of playbacks for this sound in the range 0 to 1
GetBits Gets the number of bits per sample for the sound
GetRate Gets the current sample rate for the sound
SetRate Sets the current sample rate for the sound - this will stop the playing sound
Queue Queues a sound for playing
QueueEx Queues a sound for playing, with the format provided
Flush Stops all playing and queued sounds
GetPending Gets the number of sample blocks queued or playing for the sound
Scope
AddGroup Adds a group to the scope to which streams may be added
AddStream Adds a stream to the given group suitable for inputs and operations
AddBuffer Adds a fixed-view stream to the given group suitable for inputs and operations
Rename Renames the given scope group, stream or buffer
AddPort Adds an input to the stream from a port
AddAnalog Adds an input to the stream from an analog channel
AddCustom Adds an input to the stream from a custom injection
AddOp Adds an operation to act on the inputs of the stream
ClearOps Clears all inputs and operations from the given stream
SetBuffer Sets the contents of a snapshot stream
SetCustom Sets one of 32 custom analog values for the group
GetSnapshot Gets a block of the output stream with each input sample operated on, returns number of samples read
FindOutput Searches back through the output history for a value, returns offset of found sample from TimeUS, 0 if not found
FindBaud Attempts to calculate the baud given a series of transitions for the stream, returns calculated baud
AddOverlay Adds a packet overlay to the stream at a given offset from the current time
AddOverlays Adds overlay packets to the stream by decoding the stream contents
ClearOverlays Clears existing overlay packets from the stream
ClearAllOverlays Clears all existing overlay packets from the stream
Console
AddText Adds a window to the list of consoles available
AddMemory Adds a window to the list of consoles available
GetDefault Gets the default (read-only) console window
Rename Renames the given console
SetMemMode Sets whether to show address and bytes for the console
SetInputRGB Sets the colour of text inserted by the user from now on
SetOutputRGB Sets the colour of text inserted by the component from now on
WriteText Adds a block of text to the console window
GetLineText Reads a line of text from the given console, pass -1 for final line
SetLineText Writes a line of text from the given console, pass -1 for final line
GetLineBytes Reads a line of bytes from the given console extending the array if needed
SetLineBytes Writes a line of bytes from the given console, pass -1 for final line
CountLines Counts the number of lines in the console
ClearText Clears all the text in the console
Connection
GetPort Gets a ports value from its index
SetPort Sets a ports value from its index
GetAn Gets an analog value from its channel index
SetAn Sets an analog value from its index, range 0->1
Expand
PathName Expands a string using the built-in pathname expansion variables
MacroName Expands a string to the name of a macro used in the generated code
VarName Expands a string to the name of a global variable used in the generated code
Property Expands a string to the name of a property used in the generated code
MacroHead Expands a macro name to the code generated for the header of that macro
MacroBody Expands a macro name to the code generated for the body of that macro
MacroTail Expands a macro name to the code generated for the tail of that macro
Tree
GetValue Gets the value of the given object, if available
GetName Gets the name of the given object
GetPath Gets the full '.' separated name of the given object
GetSubValue Gets the value of a named sub-item of the given object, if available
Traverse Updates the object to step depth-first through the tree
StepNext Updates the object to point to the next (younger) sibling
StepNamedNext Updates the object to point to the next (younger) sibling matching the name
StepNamedIndex Updates the object to point to the Nth next (younger) sibling matching the name
StepLast Updates the object to point to the last (elder) sibling
StepParent Updates the object to point to its parent object
StepRoot Updates the object to point to the root of the tree
StepChildHead Updates the object to point to the head (eldest) child
StepChildTail Updates the object to point to the tail (youngest) child
StepChildPath Updates the object to point to the '.' separated named child path
CountChildren Returns the number of immediate children present for the object
CheckChildren Returns true if the object has children, else false
CountNamedChildren Returns the number of immediate children present for the object
CheckParent Returns true if the object has a parent, else false if it is the root
StepSubHead Updates the object to point to the head (eldest) attribute, if any
StepSubTail Updates the object to point to the tail (youngest) attribute, if any
StepSubName Updates the object to point to the named attribute, if any
GetCopy Creates a copy of the handle and returns the copy
File
AbsPath Gets an absolute path from a relative filename
RelPath Gets an relative path from an absolute filename
CreateDir Creates a directory structure
GetType Finds the type of a file: 0=Unknown, 1=File, 2=Dir, 4=Disk
GetSize Gets the number of bytes in the file, by handle or name
Delete Deletes the file or directory structure
Create Creates the new file as a standard stream
Open Opens the existing file as a standard stream
ReadArray Reads an array from the file, returns elements read
WriteArray Writes an array to the file
SetPos Sets the position of the next read or write in the file
GetPos Gets the position of the next read or write in the file
Flush Writes all unwritten data to the file in one block
File.Buffer
Open Opens the existing file as a circular buffer
Create Creates the new file as a circular buffer
ReadByte Reads a single byte from the input stream, -1 if empty
WriteByte Writes a single byte to the input stream
ReadArray Reads an array from the input stream, returns elements read
WriteArray Writes an array to the input stream
File.NVM
Open Opens the existing file as a block of non-volatile memory
Create Creates the new file as a block of non-volatile memory
ReadByte Reads a single byte from the NVM, -1 if empty
WriteByte Writes a single byte to the NVM multiple times
ReadArray Reads an array from the NVM, returns elements read
WriteArray Writes an array to the NVM
Time
GetMillisecs Returns the value of a monotonic non-decrementing millisecond counter
GetUTC Returns the current UTC Modified Julian Date value
GetLocal Returns the current local time as a Modified Julian Date value
AddMJD Increments or decrements a Modified Julian Date and millisecond value
MJDToDate Converts a Modified Julian Date into a Gregorian calendar date
DateToMJD Converts a Gregorian calendar date into a Modified Julian Date
MJDToSeconds Converts a Modified Julian Date into a number of seconds since a specified epoch
SecondsToMJD Returns the Modified Julian Date given by the number of seconds since a specified epoch
MJDToWeekday Gets the day of the week that the MJD represents
GetLeapYear Returns true if the given year is a leap year, else false
GetMonthDays Returns the number of days in the given month
Language
Translate Takes English text and optional hint and converts to the current language
System
Notify Sends a System.User message to the targeted component
Forward Sends the currently processing message to the target
ShowHandle Given a handle to an object with viewable presence, shows that object on screen
CreateHandle Creates a general-purpose garbage collected handle for resource management
SetHandleWord Sets a general purpose word in the handle for use by its owner
GetHandleWord Gets a general-purpose word set by the owner of a custom handle
DeleteHandle Deletes any handle created by the component
GetSender Gets the handle of the component that posted this event - 0 for system
TimerStart Calls the Component.Timer event with Ident as an argument after Millisecs time
TimerStop Kills any timers with the given ident for this component
WDTEnable Enables or disables the software watchdog during long operations
ClaimEvent Claims an event message by name, returns true if claimed
ReleaseEvent Releases a previously claimed an event message by name, returns true if released
EnableEvent Allows an event to be fired or removes the ability for an event to fire - this may be nested
ClaimMouse Claims mouse clicks for the target object
ReleaseMouse Releases mouse clicks for the target object
RedirectMacros Allows calls to one of your children to be redirected to another component
Debug
Print Prints out the string or value on a line in the debug window
PrintLn Prints out the string or value with a new-line in the debug window