Go to the documentation of this file. 1 #ifndef HIVE_MIND_ANGLECALCULATORPARAMETERS_H
2 #define HIVE_MIND_ANGLECALCULATORPARAMETERS_H
7 #define NUM_ANTENNA_PAIRS (3)
8 #define NUM_PDOA_SLOPES (2)
10 #define ANGLE_PARAMETERS_VALID_SECRET_NUMBER (42)
63 #endif // HIVE_MIND_ANGLECALCULATORPARAMETERS_H
uint16_t getBytecodeLength() const override
Get the size of the BittyBuzz byte code.
Definition: BittyBuzzBytecode.cpp:38
const char * getFunctionName() const
get the name of the function
Definition: BittyBuzzFunctionDescription.cpp:15
bool handleResponse(const ResponseDTO &response)
Definition: BittyBuzzMessageHandler.cpp:221
HashMapStack< std::string_view, BittyBuzzRegisteredClosure, m_maxSize > m_closureRegisterMap
Definition: BittyBuzzClosureRegister.h:36
const IBSP & m_bsp
Definition: BittyBuzzVm.h:65
IBittyBuzzClosureRegister * g_closureRegister
Function register used by the BBVM to register new functions.
Definition: BittyBuzzSystem.cpp:9
float log10(float x)
Calculates the logarithm base 10.
Definition: Math.cpp:32
BBVMRet
Definition: IBittyBuzzVm.h:10
virtual void flush()=0
Adds a newline and flushes the input to the serial port.
ICircularQueue< MessageDTO > & m_remoteQueue
Definition: BittyBuzzMessageHandler.h:32
void registerClosure()
register a new function, exposing it to the remote composant of the swarm Signature register_closure(...
Definition: BittyBuzzUserFunctions.cpp:90
void sqrt()
Calculates the square root Signature sqrt(arg1)
Definition: BittyBuzzMathFunctions.cpp:156
Definition: BittyBuzzNeighborsManager.h:8
void logVmDump(LogLevel logLevel)
Logs the vm dump which contains information about the vm state, heap, stack, etc.
Definition: BittyBuzzSystem.cpp:65
Definition: BittyBuzzClosureRegister.h:13
ResponseDTO handleRequest(const RequestDTO &request)
Definition: BittyBuzzMessageHandler.cpp:162
virtual uint16_t getUUId() const =0
Returns the unique id associated with the board.
bbzheap_idx_t m_closureHeapIdx
Definition: IBittyBuzzClosureRegister.h:17
uint16_t m_closureId
Definition: IBittyBuzzClosureRegister.h:16
void log()
Calculates the natural logarithm (ln) Signature log(arg1)
Definition: BittyBuzzMathFunctions.cpp:91
uint16_t m_strId
Definition: BittyBuzzLibMemberRegister.h:14
void min()
Return the min Signature min(arg1, arg2)
Definition: BittyBuzzMathFunctions.cpp:251
virtual bbzvm_bcode_fetch_fun getBytecodeFetchFunction() const =0
Obtain the function that fetches the BittyBuzz byte code.
virtual void clearClosures()=0
Clears all the registered closures.
void foreachFunctionCallback(bbzheap_idx_t key, bbzheap_idx_t value, void *params)
Definition: BittyBuzzUserFunctions.cpp:17
virtual std::optional< RelativePosition > getRobotPosition(uint16_t robotId) const =0
Returns the last known relative position of a given robot.
void isClosure()
Checks if a variable is a function closure Signature isclosure(arg1)
Definition: BittyBuzzUserFunctions.cpp:281
float ln(float x)
Calculates the natural logarithm.
Definition: Math.cpp:30
std::variant< bbzvm_funp, float, int16_t > m_value
Definition: BittyBuzzLibMemberRegister.h:15
ThreadSafeQueue< uint16_t > & getInterlocUpdateOutputQueue()
get interloc position update msg queu
Definition: InterlocContainer.cpp:29
A class to register buzz function/closures id and associate them with a string.
Definition: IBittyBuzzClosureRegister.h:24
BittyBuzzClosureRegister & getBBZClosureRegister()
return an instance of a bittybuzz function register
Definition: BittyBuzzContainer.cpp:16
virtual void updateNeighbors()=0
const char * getStateString(bbzvm_state state)
Definition: BittyBuzzSystem.cpp:143
std::optional< std::reference_wrapper< const BittyBuzzRegisteredClosure > > getRegisteredClosure(const char *functionName) const override
get the id of a stored function by it's associated name
Definition: BittyBuzzClosureRegister.cpp:55
bool isBuzzToBuzzUserCallRequest(const RequestDTO &request)
Definition: BittyBuzzMessageHandler.cpp:239
int16_t g_vmStepDelayMs
The delay between each call of the step function in buzz.
Definition: BittyBuzzUserFunctions.cpp:8
std::array< std::tuple< const char *, FunctionDescriptionArgumentTypeDTO >, FunctionDescriptionDTO::ARGUMENTS_MAX_SIZE > m_argumentDescriptions
Definition: BittyBuzzFunctionDescription.h:47
ICircularQueue< uint16_t > & m_posUpdateQueue
Definition: BittyBuzzNeighborsManager.h:17
static bool handleGenericResponse(const GenericResponseDTO &response)
Definition: BittyBuzzMessageHandler.cpp:184
ICircularQueue< MessageDTO > & m_inputQueue
Definition: BittyBuzzMessageHandler.h:30
virtual LogRet log(LogLevel level, const char *format,...)=0
Logs if the provided level is higher than the current log level (Thread-safe)
bool start() override
Starts the vm.
Definition: BittyBuzzVm.cpp:64
bool queueBuzzMessages() override
queues the buzz messages
Definition: BittyBuzzMessageService.cpp:66
void callHostFunction()
calls a function to a host Signature call_host_function(agent_id, fname, params)
Definition: BittyBuzzUserFunctions.cpp:180
BittyBuzzBytecode(ILogger &logger, const uint8_t *bytecode, uint16_t bytecodeLength)
Definition: BittyBuzzBytecode.cpp:25
float fabs(float x)
Return the absolute value.
Definition: Math.cpp:50
void errorReceiver(bbzvm_error errcode)
Callback to handle errors on bittybuzz vm.
Definition: BittyBuzzSystem.cpp:29
BittyBuzzStringResolver createBittyBuzzStringResolver(ILogger &logger)
Creates a BittyBuzzStringResolver with the main.bzz bytecode.
Definition: BittyBuzzFactory.cpp:16
bool isNumber(bbzobj_t *obj)
Definition: BittyBuzzMathFunctions.cpp:7
std::array< std::array< float, NUM_PDOA_SLOPES >, NUM_ANTENNA_PAIRS > m_pdoaSlopes
Definition: AngleCalculatorParameters.h:25
ICircularQueue< MessageDTO > & m_remoteQueue
Definition: BittyBuzzMessageService.h:37
BittyBuzzMessageHandler & getBBZMessageHandler()
return an instance of a bittybuzz message handler
Definition: BittyBuzzContainer.cpp:8
bbzheap_idx_t m_selfHeapIdx
Definition: IBittyBuzzClosureRegister.h:18
const uint8_t * bbz_bcodeFetcher(bbzpc_t offset, uint8_t size)
Definition: BittyBuzzBytecode.cpp:10
float floor(float x)
Floor x downward.
Definition: Math.cpp:38
void log()
Logs to the default output Signature log(args...)
Definition: BittyBuzzUserFunctions.cpp:67
std::array< float, NUM_ANTENNA_PAIRS > m_pdoaNormalizationFactors
Definition: AngleCalculatorParameters.h:21
ThreadSafeQueue< MessageDTO > & getBuzzMsgQueue()
get the buzz message queue
Definition: MessageHandlerContainer.cpp:35
BittyBuzzLib< std::array< BittyBuzzLibMemberRegister, 24 > > createBittyBuzzMathLib()
Creates a the math table library for the bvm.
Definition: BittyBuzzFactory.cpp:46
void clearClosures() override
Clears all the registered closures.
Definition: BittyBuzzClosureRegister.cpp:49
std::array< uint8_t, NUM_ANTENNA_PAIRS > m_parametersValidSecretNumbers
Definition: AngleCalculatorParameters.h:54
void callIfNumber(uint16_t argPos, callbackFloatArg callback)
Definition: BittyBuzzMathFunctions.cpp:24
BittyBuzzMessageService(ICircularQueue< MessageDTO > &hostQueue, ICircularQueue< MessageDTO > &remoteQueue, ICircularQueue< MessageDTO > &buzzQueue, IBSP &bsp, ILogger &logger)
Definition: BittyBuzzMessageService.cpp:6
Definition: BittyBuzzMessageService.h:10
void ceili()
Ceil a value Signature ceili(arg1)
Definition: BittyBuzzMathFunctions.cpp:63
void isLambdaClosure()
Checks if a variable is a lambda, unamed closure Signature islambda_closure(arg1)
Definition: BittyBuzzUserFunctions.cpp:290
BittyBuzzStringResolver(const std::pair< const uint16_t, const char * > *stringArray, uint16_t arrayLength, uint16_t stringIdOffset, ILogger &logger)
Definition: BittyBuzzStringResolver.cpp:3
HashMapStack< uint16_t, const char *, m_maxSize > m_closureNameRegisters
Definition: BittyBuzzClosureRegister.h:35
virtual bool registerClosure(const char *functionName, bbzheap_idx_t closureHeapIdx, bbzheap_idx_t selfHeapIdx, const BittyBuzzFunctionDescription &description)=0
register a closure to the list
virtual bool processMessage()=0
process a message and sends a response if needed. A response is sent to the appropriate queue on a re...
BittyBuzzNeighborsManager & getBBZNeighborsManager()
return an instance of a bittybuzz neighbors manager
Definition: BittyBuzzContainer.cpp:29
void terminate() override
Terminate the virtual machine and removes all messages that were supposed to be processed.
Definition: BittyBuzzVm.cpp:80
const std::pair< const uint16_t, const char * > * m_stringArray
Definition: BittyBuzzStringResolver.h:22
const char * getErrorString(bbzvm_error error)
Definition: BittyBuzzSystem.cpp:160
bool handleVmMessage(const VmMessageDTO &vmMsg)
Definition: BittyBuzzMessageHandler.cpp:190
uint16_t m_argumentDescriptionsLength
Definition: BittyBuzzFunctionDescription.h:48
char perm(bbzobj_t *obj)
Definition: BittyBuzzSystem.cpp:43
bbzvm_t m_bbzVm
Definition: BittyBuzzVm.h:73
void max()
Return the max Signature max(arg1, arg2)
Definition: BittyBuzzMathFunctions.cpp:267
float m_boardOrientationOffset
Definition: AngleCalculatorParameters.h:60
IBittyBuzzMessageService * g_messageService
Message service used by the BBVM to send requests to host and remote.
Definition: BittyBuzzSystem.cpp:10
BittyBuzzLibMemberRegister(uint16_t strId, std::variant< bbzvm_funp, float, int16_t > value)
Definition: BittyBuzzLibMemberRegister.cpp:3
BittyBuzzLib< std::array< BittyBuzzLibMemberRegister, 2 > > createBittyBuzzUILib()
Creates a the ui table library for the bvm.
Definition: BittyBuzzFactory.cpp:76
bool addArgument(const char *argumentName, FunctionDescriptionArgumentTypeDTO argumentType)
add an argument to the list of the description
Definition: BittyBuzzFunctionDescription.cpp:17
void(* callbackFloatArg)(float arg)
Definition: BittyBuzzMathFunctions.cpp:23
bool handleBuzzMessages(const BuzzMessagesDTO &msg)
Definition: BittyBuzzMessageHandler.cpp:201
FunctionCallResponseDTO handleFunctionCallRequest(const FunctionCallRequestDTO &functionRequest)
Definition: BittyBuzzMessageHandler.cpp:74
void delay()
wait for a certain delay Signature delay(arg1) Warning this function make the whole VM sleep which ca...
Definition: BittyBuzzUserFunctions.cpp:327
static constexpr uint16_t VM_DUMP_LOG_WAIT_TIME_MS
Definition: BittyBuzzSystem.cpp:14
LogLevel
The log level used for the logger.
Definition: ILogger.h:9
std::array< std::array< float, NUM_PDOA_SLOPES >, NUM_ANTENNA_PAIRS > m_pdoaIntercepts
Definition: AngleCalculatorParameters.h:30
IBSP & m_bsp
Definition: BittyBuzzMessageService.h:40
bool init(const std::reference_wrapper< IBittyBuzzLib > *bbzLibs, uint32_t bbzLibsLength) override
Init the virtual machine.
Definition: BittyBuzzVm.cpp:38
float ceil(float x)
Round x upward.
Definition: Math.cpp:36
float tan(float x)
calculate the tangent
Definition: Math.cpp:12
Definition: AngleCalculatorParameters.h:16
void log2()
Calculates the logarithm base 2 Signature log2(arg1)
Definition: BittyBuzzMathFunctions.cpp:105
Manages the UI available to the user.
Definition: IUserUI.h:7
Definition: IBittyBuzzNeighborsManager.h:4
void isString()
Checks if a variable is a float Signature istable(arg1)
Definition: BittyBuzzUserFunctions.cpp:263
bool registerClosure(const char *functionName, bbzheap_idx_t closureHeapIdx, bbzheap_idx_t selfHeapIdx, const BittyBuzzFunctionDescription &description) override
register a closure to the list
Definition: BittyBuzzClosureRegister.cpp:16
BittyBuzzLib< std::array< BittyBuzzLibMemberRegister, 15 > > createBittyBuzzGlobalLib(int16_t vmStepDelay)
Creates an array of FunctionRegister associated with the code from main.bzz.
Definition: BittyBuzzFactory.cpp:21
uint16_t getRegisteredClosureLength() const override
get the length/number of the registered closures
Definition: BittyBuzzClosureRegister.cpp:68
bbzheap_idx_t m_key
Definition: BittyBuzzUserFunctions.cpp:45
uint16_t messageQueueLength() const override
gets the number of message to be processed in the queue
Definition: BittyBuzzMessageHandler.cpp:42
Definition: BittyBuzzUserFunctions.cpp:10
void tan()
Calculates the tengent Signature tan(arg1)
Definition: BittyBuzzMathFunctions.cpp:194
NotificationQueue< MessageDTO > & getRemoteMsgQueue()
get the remote message queue
Definition: MessageHandlerContainer.cpp:57
static bool handleUserCallResponse(const UserCallResponseDTO &response)
Definition: BittyBuzzMessageHandler.cpp:178
std::array< std::array< uint8_t, NUM_ANTENNA_PAIRS >, NUM_ANTENNA_PAIRS > m_slopeDecisionMatrix
Definition: AngleCalculatorParameters.h:48
float m_angle
Angle of other agent in current agent frame (in degrees)
Definition: RelativePosition.h:17
float asin(float x)
calculate the arc sine
Definition: Math.cpp:16
void ceilf()
Ceil a value Signature ceilf(arg1)
Definition: BittyBuzzMathFunctions.cpp:70
void asin()
Calculates the arc sine Signature asin(arg1)
Definition: BittyBuzzMathFunctions.cpp:206
void abs()
Calculates the absolute value Signature abs(arg1)
Definition: BittyBuzzMathFunctions.cpp:33
BittyBuzzBytecode createBittyBuzzBytecode(ILogger &logger)
Creates a BittyBuzzBytecode with the main.bzz bytecode.
Definition: BittyBuzzFactory.cpp:12
float cos(float x)
calculate the cosine
Definition: Math.cpp:8
#define NUM_ANTENNA_PAIRS
Definition: AngleCalculatorParameters.h:7
IBittyBuzzClosureRegister & m_closureRegister
Definition: BittyBuzzVm.h:69
void exp()
Calculates e^x Signature exp(x)
Definition: BittyBuzzMathFunctions.cpp:144
bbzheap_idx_t m_value
Definition: BittyBuzzUserFunctions.cpp:46
bbzvm_bcode_fetch_fun getBytecodeFetchFunction() const override
Obtain the function that fetches the BittyBuzz byte code.
Definition: BittyBuzzBytecode.cpp:34
virtual std::optional< const char * > getString(uint16_t stringId) const =0
Get the string from the stringId.
Description for a function, used for the FunctionDescriptionRequest/Response.
Definition: BittyBuzzFunctionDescription.h:11
std::optional< const char * > getString(uint16_t stringId) const override
Get the string from the stringId.
Definition: BittyBuzzStringResolver.cpp:13
BittyBuzzFunctionDescription m_description
Definition: IBittyBuzzClosureRegister.h:19
ILogger * g_logger
Logger used for error reception or user functions.
Definition: BittyBuzzSystem.cpp:6
int abs(int x)
Return the absolute value.
Definition: Math.cpp:52
bool processMessage() override
process a message and sends a response if needed. A response is sent to the appropriate queue on a re...
Definition: BittyBuzzMessageHandler.cpp:20
ILogger & m_logger
Definition: BittyBuzzMessageHandler.h:34
Class that resolves a string from the bittybuzz virtual machine.
Definition: IBittyBuzzStringResolver.h:10
static const uint8_t * g_bittyBuzzBytecode
Definition: BittyBuzzBytecode.cpp:7
IBittyBuzzMessageService & m_messageService
Definition: BittyBuzzVm.h:67
bbzvm_instr getInstruction() const override
Get the current instruction of the VM.
Definition: BittyBuzzVm.cpp:126
BittyBuzzMessageService & getBBZMessageService()
return an instance of a bittybuzz message service
Definition: BittyBuzzContainer.cpp:21
Definition: BittyBuzzUserFunctions.cpp:44
float acos(float x)
calculate the arc cosine
Definition: Math.cpp:14
Definition: BittyBuzzStringResolver.h:9
BittyBuzzFunctionDescription(const char *functionName)
Definition: BittyBuzzFunctionDescription.cpp:3
void toInt()
Casts a type to int Signature int(arg1)
Definition: BittyBuzzUserFunctions.cpp:299
ILogger & m_logger
Definition: BittyBuzzVm.h:70
Logger & getLogger()
Return a reference to the global logger.
Definition: LoggerContainer.cpp:5
std::optional< float > getFloatArg(uint16_t stackAt)
Definition: BittyBuzzMathFunctions.cpp:9
float atan2(float y, float x)
calculate the arc of x/y
Definition: Math.cpp:20
bbzvm_state getState() const override
Get the state of the vm.
Definition: BittyBuzzVm.cpp:122
void atan()
Calculates the arc cosine Signature atan(arg1)
Definition: BittyBuzzMathFunctions.cpp:232
std::variant< bbzvm_funp, float, int16_t > getValue() const
Definition: BittyBuzzLibMemberRegister.cpp:9
virtual uint16_t getBytecodeLength() const =0
Get the size of the BittyBuzz byte code.
A logger class with basic logging capabilities.
Definition: ILogger.h:35
ICircularQueue< MessageDTO > & m_hostQueue
Definition: BittyBuzzMessageHandler.h:31
void log10()
Calculates the logarithm base 10 Signature log10(arg1)
Definition: BittyBuzzMathFunctions.cpp:117
virtual void setLed(bool state)=0
Set the led on or off.
a class containing info of a registered closure
Definition: IBittyBuzzClosureRegister.h:9
virtual uint32_t generateRandomNumber()=0
Returns a positive random number, uses an hardware RNG if available.
BBVMRet step() override
Does one execution step in the virtual machine. Thus execute the buzz code in the step function.
Definition: BittyBuzzVm.cpp:90
const uint16_t m_arrayLength
Definition: BittyBuzzStringResolver.h:23
IBSP & getBSP()
Returns an instance of the platform dependent BSP.
Definition: BSPContainer.cpp:13
std::array< std::array< uint8_t, 2 >, NUM_ANTENNA_PAIRS > m_antennaPairs
Definition: AngleCalculatorParameters.h:35
IInterloc & getInterloc()
Definition: InterlocContainer.cpp:12
const IBittyBuzzStringResolver * g_stringResolver
String resolver used for user functions.
Definition: BittyBuzzSystem.cpp:8
void acos()
Calculates the arc cosine Signature acos(arg1)
Definition: BittyBuzzMathFunctions.cpp:219
const float E
The euleur number as a constant note that since buzz approximates ln(e) may not equal 1.
Definition: BittyBuzzMathFunctions.h:15
static uint16_t g_bittyBuzzBytecodeLength
Definition: BittyBuzzBytecode.cpp:8
Definition: BittyBuzzBytecode.h:9
bool flush()
Definition: BittyBuzzMessageService.cpp:105
void clearMessages() override
clears all the pending messages in the input queue without processing them
Definition: BittyBuzzMessageHandler.cpp:40
bool m_err
Definition: BittyBuzzUserFunctions.cpp:11
void functionCall(uint16_t stringId)
Call a bittybuzz function that takes not arguments (init, step, etc),.
Definition: BittyBuzzSystem.cpp:17
void stop() override
Stops the vm, can be called in another thread or in an interrupt.
Definition: BittyBuzzVm.cpp:73
Definition: RelativePosition.h:6
void setHex()
Sets the user sevent segment to a value Signature set_hex(arg1)
Definition: BittyBuzzUIFunctions.cpp:22
FunctionListLengthResponseDTO handleFunctionListLengthRequest(const FunctionListLengthRequestDTO &functionLengthRequest)
Definition: BittyBuzzMessageHandler.cpp:44
uint16_t getArgumentsLength() const
get the length of the array
Definition: BittyBuzzFunctionDescription.cpp:12
int logObj(bbzobj_t *obj, char *str, uint16_t maxSize)
Logs an bittybuzz object to a human readable format.
Definition: BittyBuzzUtils.cpp:3
A buzz library, can register on the global scope or on a table.
Definition: BittyBuzzLib.h:11
void callBuzzFunction()
calls a function to a buzz Signature call_buzz_function(agent_id, fname, params)
Definition: BittyBuzzUserFunctions.cpp:208
Definition: BittyBuzzMessageHandler.h:11
bool callBuzzFunction(uint16_t agentId, const char *functionName, const FunctionCallArgumentDTO *args, uint16_t argsLength) override
call a function to a buzz vm
Definition: BittyBuzzMessageService.cpp:42
void floori()
Floor a value Signature floori(arg1)
Definition: BittyBuzzMathFunctions.cpp:49
void isInt()
Checks if a variable is an int Signature isint(arg1)
Definition: BittyBuzzUserFunctions.cpp:245
ILogger & m_logger
Definition: BittyBuzzStringResolver.h:21
BittyBuzzNeighborsManager(const IInterloc &interloc, ICircularQueue< uint16_t > &posUpdateQueue)
Definition: BittyBuzzNeighborsManager.cpp:5
IBittyBuzzMessageHandler & m_messageHandler
Definition: BittyBuzzVm.h:66
const uint16_t m_stringIdOffset
Definition: BittyBuzzStringResolver.h:24
virtual bool queueBuzzMessages()=0
queues the buzz messages
std::array< FunctionCallArgumentDTO, FunctionCallRequestDTO::FUNCTION_CALL_ARGUMENTS_MAX_LENGTH > m_arguments
Definition: BittyBuzzUserFunctions.cpp:13
IUserUI * g_userUI
User interface (LED, Hex display, etc) available to the user via buzz.
Definition: BittyBuzzSystem.cpp:12
ICircularQueue< MessageDTO > & m_hostQueue
Definition: BittyBuzzMessageService.h:36
void roundf()
Rounds a value Signature roundf(arg1)
Definition: BittyBuzzMathFunctions.cpp:84
BuzzMessagesDTO m_messages
Definition: BittyBuzzMessageService.h:39
void roundi()
Rounds a value Signature roundi(arg1)
Definition: BittyBuzzMathFunctions.cpp:77
virtual void clearMessages()=0
clears all the pending messages in the input queue without processing them
virtual bool callBuzzFunction(uint16_t agentId, const char *functionName, const FunctionCallArgumentDTO *args, uint16_t argsLength)=0
call a function to a buzz vm
Definition: IInterloc.h:15
virtual uint16_t getRegisteredClosureLength() const =0
get the length/number of the registered closures
NotificationQueue< MessageDTO > & getHostMsgQueue()
get the host message queue
Definition: MessageHandlerContainer.cpp:44
message service use by the BBVM. Constructs the messages and dispatches it at the appropriate place (...
Definition: IBittyBuzzMessageService.h:9
bool callHostFunction(uint16_t agentId, const char *functionName, const FunctionCallArgumentDTO *args, uint16_t argsLength) override
call a function to a host
Definition: BittyBuzzMessageService.cpp:17
BittyBuzzMessageHandler(const IBittyBuzzClosureRegister &closureRegister, ICircularQueue< MessageDTO > &inputQueue, ICircularQueue< MessageDTO > &hostQueue, ICircularQueue< MessageDTO > &remoteQueue, const IBSP &bsp, ILogger &logger)
Definition: BittyBuzzMessageHandler.cpp:7
uint16_t m_length
Definition: BittyBuzzUserFunctions.cpp:14
float log2(float x)
Calculates the logarithm base 2.
Definition: Math.cpp:34
IBSP * g_bsp
BSP used by the bbvm for random numbers.
Definition: BittyBuzzSystem.cpp:11
UserSegment intToUserSegment(int16_t i)
Definition: BittyBuzzUIFunctions.cpp:4
BittyBuzzRegisteredClosure(uint16_t closureId, BittyBuzzFunctionDescription description, bbzheap_idx_t closureHeapIdx, bbzheap_idx_t selfHeapIdx)
Definition: BittyBuzzClosureRegister.cpp:6
virtual int print(const char *format,...)=0
Provides an interface to print to the console or serial port. The arguments and return values match t...
void logObj(ILogger &logger, LogLevel logLevel, bbzheap_idx_t heapIdx)
Definition: BittyBuzzSystem.cpp:50
const IBSP & m_bsp
Definition: BittyBuzzMessageHandler.h:33
std::optional< std::reference_wrapper< BuzzMessageDTO > > getNextMessage()
Definition: BittyBuzzMessageService.cpp:91
FunctionDescriptionArgumentTypeDTO getbbzObjType(bbzobj_t *bbzObj)
Definition: BittyBuzzUserFunctions.cpp:56
UserCallResponseDTO handleUserCallRequest(const UserCallRequestDTO &userRequest)
Definition: BittyBuzzMessageHandler.cpp:135
uint16_t getStringId() const
Definition: BittyBuzzLibMemberRegister.cpp:7
void updateNeighbors() override
Definition: BittyBuzzNeighborsManager.cpp:9
const char * m_functionName
Definition: BittyBuzzFunctionDescription.h:44
void isTable()
Checks if a variable is a table Signature istable(arg1)
Definition: BittyBuzzUserFunctions.cpp:272
void logDump(LogLevel logLevel) override
Logs the virtual machine state, stack, heap and table segments.
Definition: BittyBuzzVm.cpp:78
const char * getInstructionString(bbzvm_instr instruction)
Definition: BittyBuzzSystem.cpp:197
const IBittyBuzzBytecode & m_bytecode
Definition: BittyBuzzVm.h:64
Manages the user interface The user interface can consist of buttons, LED, serial print ports,...
Definition: IUserInterface.h:36
IBittyBuzzNeighborsManager & m_neighborsManager
Definition: BittyBuzzVm.h:68
void pow()
Calculates the base raised to the power of the exponent. Signature pow(base, exponent)
Definition: BittyBuzzMathFunctions.cpp:130
UserSegment
Definition: UserStates.h:4
const float PI
The value of PI as a constant note that since it approximates cos(pi) may not equal 0.
Definition: BittyBuzzMathFunctions.h:22
float pow(float base, float exponent)
Calculates the base raised to the power of the exponent.
Definition: Math.cpp:22
FunctionDescriptionResponseDTO handleFunctionDescriptionRequest(const FunctionDescriptionRequestDTO &functionDescRequest)
Definition: BittyBuzzMessageHandler.cpp:50
Manages the BittyBuzz byte code.
Definition: IBittyBuzzBytecode.h:9
Handles messages destined to the bbvm.
Definition: IBittyBuzzMessageHandler.h:8
void toFloat()
Casts a type to float Signature float(arg1)
Definition: BittyBuzzUserFunctions.cpp:313
void rng_uniform()
Return a number with a uniform distribution Signature rng_uniform()
Definition: BittyBuzzMathFunctions.cpp:283
virtual uint16_t messageQueueLength() const =0
gets the number of message to be processed in the queue
const IBittyBuzzClosureRegister & m_closureRegister
Definition: BittyBuzzMessageHandler.h:29
virtual void setSegment(UserSegment segment)=0
Set the user seven segment to a value.
BittyBuzzVm(const IBittyBuzzBytecode &bytecode, const IBittyBuzzStringResolver &stringResolver, IBittyBuzzMessageHandler &messageHandler, IBittyBuzzClosureRegister &closureRegister, IBittyBuzzMessageService &messageService, IBittyBuzzNeighborsManager &neighborsManager, IUserUI &userUI, IBSP &bsp, ILogger &logger, IUserInterface &ui)
The constructor of the bbvm.
Definition: BittyBuzzVm.cpp:9
void isNil()
Checks if a variable is nil Signature isnil(arg1)
Definition: BittyBuzzUserFunctions.cpp:236
void isFloat()
Checks if a variable is a float.
Definition: BittyBuzzUserFunctions.cpp:254
void floorf()
Floor a value Signature floorf(arg1)
Definition: BittyBuzzMathFunctions.cpp:56
IUserInterface * g_ui
UserInterface used by the bbvm for printing user logs.
Definition: BittyBuzzSystem.cpp:7
virtual bool callHostFunction(uint16_t agentId, const char *functionName, const FunctionCallArgumentDTO *args, uint16_t argsLength)=0
call a function to a host
virtual std::optional< std::reference_wrapper< const BittyBuzzRegisteredClosure > > getRegisteredClosure(const char *functionName) const =0
get the id of a stored function by it's associated name
void cos()
Calculates the cosine Signature cos(arg1)
Definition: BittyBuzzMathFunctions.cpp:181
bool handleMessage(const MessageDTO &message)
Definition: BittyBuzzMessageHandler.cpp:247
static ILogger * g_logger
Definition: BittyBuzzBytecode.cpp:6
const float pi
Definition: Math.cpp:4
float m_distance
Distance in meters.
Definition: RelativePosition.h:12
ICircularQueue< MessageDTO > & m_buzzQueue
Definition: BittyBuzzMessageService.h:38
const uint16_t m_bytecodeLength
Definition: BittyBuzzBytecode.h:22
const IInterloc & m_interloc
Definition: BittyBuzzNeighborsManager.h:16
bbzvm_error getError() const override
Get the error state of the VM.
Definition: BittyBuzzVm.cpp:124
void foreachNameAndType(bbzheap_idx_t key, bbzheap_idx_t value, void *params)
Definition: BittyBuzzUserFunctions.cpp:50
void sin()
Calculates the sine Signature sin(arg1)
Definition: BittyBuzzMathFunctions.cpp:168
const std::array< std::tuple< const char *, FunctionDescriptionArgumentTypeDTO >, FunctionDescriptionDTO::ARGUMENTS_MAX_SIZE > & getArguments() const
get the array of arguments description
Definition: BittyBuzzFunctionDescription.cpp:8
float sin(float x)
calculate the sine
Definition: Math.cpp:10
float sqrt(float x)
Calculates the square root.
Definition: Math.cpp:24
void setLed()
Sets the user LED on or off Signature set_led(arg1)
Definition: BittyBuzzUIFunctions.cpp:14
float exp(float x)
Calculates the exponent.
Definition: Math.cpp:28