Fawkes API
Fawkes Development Version
|
23 #include <blackboard/bbconfig.h>
24 #include <blackboard/exceptions.h>
25 #include <blackboard/internal/interface_mem_header.h>
26 #include <blackboard/internal/memory_manager.h>
27 #include <config/sqlite.h>
28 #include <utils/system/console_colors.h>
29 #include <utils/time/time.h>
38 main(
int argc,
char **argv)
43 std::string token =
"";
45 token = config.
get_string(
"/fawkes/mainapp/blackboard_magic_token");
47 cout <<
"Could not read shared memory token for blackboard." << endl;
48 cout <<
"BlackBoard is probably running without shared memory." << endl;
59 cout <<
"No BlackBoard shared memory segment found!" << endl;
64 << cblue <<
"Fawkes BlackBoard Memory Info" << cnormal << endl
65 <<
"========================================================================" << endl;
67 printf(
"Memory Size: %s%8u%s %sB%s BlackBoard version: %s%u%s\n"
68 "Free Memory: %s%8u%s %sB%s Alloc. memory: %s%8u%s %sB%s Overhang: %s%8u%s %sB%s\n"
69 "Free Chunks: %s%8u%s Alloc. chunks: %s%8u%s\n",
102 gettimeofday(&a, NULL);
103 cout <<
"Waiting for lock on shared memory.. " << flush;
105 gettimeofday(&b, NULL);
106 cout <<
"lock aquired. Waited " <<
time_diff_sec(b, a) <<
" seconds" << endl;
109 if (memmgr->
begin() == memmgr->
end()) {
110 cout <<
"No interfaces allocated." << endl;
112 cout << endl <<
"Interfaces:" << endl;
114 printf(
"%sMemSize Overhang Type/ID/Hash Serial Ref W/R%s\n"
115 "------------------------------------------------------------------------\n",
121 for (cit = memmgr->
begin(); cit != memmgr->
end(); ++cit) {
123 cout <<
"*cit == NULL" << endl;
127 char tmp_hash[INTERFACE_HASH_SIZE_ * 2 + 1];
128 for (
size_t s = 0; s < INTERFACE_HASH_SIZE_; ++s) {
129 snprintf(&tmp_hash[s * 2], 3,
"%02X", ih->
hash[s]);
131 printf(
"%7u %8u %sT%s %-32s %6u %3u %1d/%-3d\n%18s %sI%s %-32s\n%18s %sH%s %-32s\n",
unsigned int free_size() const
Get total free memory.
unsigned int overhang() const
Get number of overhanging bytes.
void unlock()
Unlock memory.
virtual void load(const char *file_path)=0
Load configuration.
ChunkIterator end()
Get end of chunk list.
Iterator for memory chunks.
unsigned int size() const
Get size of data segment.
unsigned int version() const
Get BlackBoard version.
unsigned int allocated_size() const
Get total allocated memory.
BlackBoard memory manager.
double time_diff_sec(const timeval &a, const timeval &b)
Calculate time difference of two time structs.
Thrown if shared memory could not be opened.
bool try_lock()
Try to lock memory.
Fawkes library namespace.
unsigned int num_free_chunks() const
Get number of free chunks.
ChunkIterator begin()
Get first element for chunk iteration.
unsigned int memory_size() const
Get size of memory.
virtual unsigned int get_uint(const char *path)=0
Get value from configuration which is of type unsigned int.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
unsigned int overhang_size() const
Get number of overhanging bytes.
Configuration storage using SQLite.
unsigned int num_allocated_chunks() const
Get number of allocated chunks.
Base class for exceptions in Fawkes.