/*
 * App.h
 * 
 * Gocator Console
 * Copyright (C) 2010 by LMI Technologies Inc.
 * 
 * Licensed under The MIT License.
 * Redistributions of files must retain the above copyright notice.
 */
#include <Go2.h>

// Callback signature for a command handler, used with menus. 
typedef Go2Status (*CommandCallback)(Go2Handle context);

// Represents a command. 
typedef struct Command
{
    const Go2Char* name;                // Command name.
    const Go2Char* description;         // Command description;
    CommandCallback callback;           // Command handler. 
    Go2Bool enabled;                    // Is command enabled? 
} Command;

// Represents the state of this application.
typedef struct AppClass
{
    Go2System system;               // Represents a Gocator sensor system.
    CommandCallback menuHandler;    // Callback to display currently selected menu.
    Go2Bool quit;                   // Quit flag; set to zTRUE when application should exit. 
} AppClass; 

// Handle to an AppClass object. 
typedef Go2Handle App;        

// Initializes libraries, creates an App object, and runs the menu loop until the application exits. 
Go2Status App_Run(); 

// Creates and initializes an App object. 
Go2Status App_Construct(App* app); 

// Destroys an App object. 
Go2Status App_Destroy(App app); 

// Displays information about this application.
Go2Status App_DisplayAbout(App app);

// Displays error information when a zApi function fails. 
Go2Status App_DisplayError(App app, const Go2Char* operation, Go2Status result);

// Displays a menu and executes menu selections until the App.quit flag is set.
Go2Status App_RunMenuLoop(App app);

// Waits for the 'enter' key before continuing.
Go2Status App_WaitEnter(App app);

// Prompts for a text string via keyboard input.
Go2Status App_PromptText(App app, Go2Char* text, Go2UInt32 capacity); 

// Prompts for an unsigned integer via keyboard input.
Go2Status App_Prompt32u(App app, Go2UInt32* value); 

// Prompts for an IP address via keyboard input.
Go2Status App_PromptIPAddress(App app, Go2IPAddress* value); 

// Displays the specified command list as a menu and prompts for a selection.
Go2Status App_PromptMenu(App app, const Go2Char* title, const Command* commands, Go2UInt32 count); 

// Set the main application menu as the current menu.
Go2Status App_SetMainMenu(App app);

// Displays the main application menu and prompts for a selection.
Go2Status App_PromptMainMenu(App app);

// Sets the App.quit flag to signal that the application should exit.
Go2Status App_Exit(App app);

// Uses the Go2System_Discover function to get network address information for Gocator sensors.
Go2Status App_Discover(App app);

// Uses the Go2System_SetAddress function to set a sensor's network address information.
Go2Status App_SetAddress(App app);

// Uses the Go2System_Connect function to connect to a sensor.
Go2Status App_Connect(App app);

// Uses the Go2System_Disconnect function to disconnect from a sensor.
Go2Status App_Disconnect(App app);

// Uses the Go2System_Login function to log into the system as Admin.
Go2Status App_Login(App app);

// Uses the Go2System_Logout function to log out of the system.
Go2Status App_Logout(App app);

// Uses the Go2System_ConnectHealth and Go2System_ReceiveHealth functions to receive health messages. 
Go2Status App_Health(App app);

// Uses various Go2System functions to configure a sensor for profile measurement.
Go2Status App_Configure(App app);

// Uses various Go2System functions to clear the sensors calibration.
Go2Status App_ClearCalibration(App app);

// Uses various Go2System functions to run a sensor and receive data messages.
Go2Status App_Start(App app);

// Uses the Go2System_FileCount and Go2System_FileAt functions to get the list of files on the sensor.
Go2Status App_GetFileList(App app);

// Uses the Go2System_DownloadFile function to read a file from a sensor.
Go2Status App_DownloadFile(App app);

// Uses the Go2System_UploadFile function to write a file to a sensor.
Go2Status App_UploadFile(App app);

// Uses the Go2System_Backup function to create a backup of current sensor state.
Go2Status App_Backup(App app);

// Uses the Go2System_Restore function to restore sensor state from a backup file.
Go2Status App_Restore(App app);

// Uses the Go2System_Upgrade function to perform a firmware upgrade. 
Go2Status App_Upgrade(App app);

// Uses the Go2System_Resest function to perform a sensor reset. 
Go2Status App_Reset(App app);
