nrtb-core team mailing list archive
-
nrtb-core team
-
Mailing list archive
-
Message #00320
[Merge] lp:~fpstovall/nrtb/IPC_common_lib into lp:nrtb
Rick Stovall has proposed merging lp:~fpstovall/nrtb/IPC_common_lib into lp:nrtb.
Requested reviews:
NRTB Core (nrtb-core)
For more details, see:
https://code.launchpad.net/~fpstovall/nrtb/IPC_common_lib/+merge/87071
Added a new common library nrtb_comm including all C++ code needed to create/stream/destream the GBP messages used for inter-process messaging. All unit tests are complete and the build has been integrated to the main build sequence.
--
https://code.launchpad.net/~fpstovall/nrtb/IPC_common_lib/+merge/87071
Your team NRTB Core is requested to review the proposed merge of lp:~fpstovall/nrtb/IPC_common_lib into lp:nrtb.
=== modified file 'GPB_proto/ack_nak.proto'
--- GPB_proto/ack_nak.proto 2011-07-24 17:15:15 +0000
+++ GPB_proto/ack_nak.proto 2011-12-29 11:10:29 +0000
@@ -18,14 +18,7 @@
// return on of these for each message which has a failure.
message message_nak {
- enum nak_codes {
- bad_msg_length = 1; // Message length out of bounds.
- bad_msg_parse = 2; // GPB reported parse errors.
- overflow = 3; // Data lost in stream.
- invalid_message = 4; // Msg failed validation checks.
- sequence_error = 5; // Msg was invalid the current context.
- }
- required nak_codes reason = 1;
+ required uint32 reason = 1;
optional uint32 msg_uid = 2;
- optional uint32 last_good_msg_UID = 3;
+ optional uint32 last_good_msg_uid = 3;
}
=== modified file 'GPB_proto/sim_management.proto'
--- GPB_proto/sim_management.proto 2011-09-19 14:28:03 +0000
+++ GPB_proto/sim_management.proto 2011-12-29 11:10:29 +0000
@@ -8,6 +8,19 @@
package nrtb_msg;
+import "physics_common.proto";
+
+// This message is sent when a new object is
+// created, and as a part of the sim_setup_data
+// message below.
+message obj_setup_data {
+ required uint32 uid = 1; // obj uid
+ required string name = 2; // obj name
+ required uint32 obj_type = 3; // obj type
+ required location_data location = 4;
+ required velocity_data velocity = 5;
+}
+
// This message is sent by the sim engine to notify the
// databroker that a new simulation is starting and to
// provide identity and simulation setup data.
@@ -17,6 +30,7 @@
required uint32 quanta_ms = 3; // timestep in milliseconds
optional uint32 max_quantas = 4; // time limit in quantas.
optional string started_by = 5; // who requested this run
+ repeated obj_setup_data item = 6; // list of objects at start
}
// This message is sent by the sim engine to notify the
@@ -34,6 +48,6 @@
// sim engine that there is some problem and it can not
// continue.
message db_request_sim_stop {
- required bool data_lost = 1; // true if data has been lost
+ required bool failed = 1; // true if run ended with error
optional string reason = 2; // human readable cause
}
=== modified file 'GPB_proto/sim_obj_tq_update.proto'
--- GPB_proto/sim_obj_tq_update.proto 2011-07-24 17:15:15 +0000
+++ GPB_proto/sim_obj_tq_update.proto 2011-12-29 11:10:29 +0000
@@ -11,6 +11,7 @@
package nrtb_msg;
import "physics_common.proto";
+import "sim_management.proto";
// This message contains all the information required to report the
// the status or status changes of any given object in a simulation
@@ -32,4 +33,5 @@
required uint32 quanta_id = 1; // at 20 ms, this allows 2.72 years!
required uint32 sim_uid = 2;
repeated sim_obj_tq_data obj_data = 3;
+ repeated obj_setup_data new_objs = 4;
}
=== modified file 'GPB_proto/vis_get_listing.proto'
--- GPB_proto/vis_get_listing.proto 2011-09-19 14:28:03 +0000
+++ GPB_proto/vis_get_listing.proto 2011-12-29 11:10:29 +0000
@@ -8,6 +8,7 @@
package nrtb_msg;
+// visualization uses this to request a listing of sims in the database
message vis_get_sim_listing {
optional string name = 1; // may include sql wild-cards
optional string start_date = 2; // ISO SQL style date
@@ -15,6 +16,7 @@
optional uint32 max_count = 4; // max number to return
}
+// Each one of these contians information on one simulation.
message db_sim_record {
required uint32 uid = 1; // simulation UID.
required string name = 2; // human readable name
@@ -24,6 +26,7 @@
optional string ended = 6; // ISO datetime the sim ended
}
+// Databroker returns this to provide a listing of available matching sims
message db_sim_listing {
repeated db_sim_record sim_list = 1; // available sims.
-}
\ No newline at end of file
+}
=== modified file 'GPB_proto/vis_management.proto'
--- GPB_proto/vis_management.proto 2011-09-19 14:28:03 +0000
+++ GPB_proto/vis_management.proto 2011-12-29 11:10:29 +0000
@@ -18,13 +18,14 @@
optional bool streamning = 5; // if false, client needs msgs one at a time.
}
-// this message is sent from the visualization clien to databroker
+// this message is sent from the visualization client to databroker
// at the end of a conversation, before the connection is dropped.
message vis_end {
optional string save_state_uid = 1; // if provided, save the save for
// for next time.
}
+// sent by the data broker if it must terminate activities.
message db_cant_continue {
required bool must_close = 1; // if true, connection will be dropped.
required bool may_reset= 2; // if true, the client may reconnect.
=== added file 'Makefile'
--- Makefile 1970-01-01 00:00:00 +0000
+++ Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,38 @@
+#***********************************************
+#This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+all:
+ @echo "============= building all targets ==============="
+ @make action=lib doit
+ @echo "============= all targets complete ==============="
+
+modules:
+ @echo "============= building all targets ==============="
+ @make doit
+ @echo "============= completed all targets =============="
+
+clean:
+ @echo "============= cleaning all targets ==============="
+ @make action=clean doit
+ @rm -fv ./bin/*
+ @echo "========== all targets cleanup complete ==========="
+
+doit:
+ cd common; make ${action}
+ cd sim_engine; make ${action}
+
=== modified file 'README'
--- README 2010-01-25 01:10:14 +0000
+++ README 2011-12-29 11:10:29 +0000
@@ -1,3 +1,5 @@
+Enter the command "make" at the top level to build everything.
+
What the directories are for:
|-- GPB_proto
=== removed directory 'bin/plugins'
=== modified file 'common/Makefile'
--- common/Makefile 2011-10-07 00:01:15 +0000
+++ common/Makefile 2011-12-29 11:10:29 +0000
@@ -16,7 +16,7 @@
#
#***********************************************
-lib: ./lib/nrtb_common.a
+lib: ./lib/nrtb_common.a ./lib/nrtb_communication.a
./lib/nrtb_common.a:
@echo "============= building common libs ==============="
@@ -24,6 +24,9 @@
@ar -r ./lib/nrtb_common.a ./obj/*.o
@echo "============= common libs complete ==============="
+./lib/nrtb_communication.a:
+ @cd comm_handlers; make lib
+
modules:
@echo "============= building common modules ==============="
@make doit
@@ -32,7 +35,8 @@
clean:
@echo "============= cleaning common libs ==============="
@make action=clean doit
- @rm -fv ./obj/* ./lib/*
+ @rm -fv ./obj/* ./lib/* ./include/*
+ @cd comm_handlers; make clean
@echo "========== common lib cleanup complete ==========="
doit:
@@ -49,3 +53,4 @@
@cd confreader; make ${action}
@cd GPB; make ${action}
@cd transceiver; make ${action}
+
=== added directory 'common/comm_handlers'
=== added file 'common/comm_handlers/Makefile'
--- common/comm_handlers/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,52 @@
+#***********************************************
+#This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: ../lib/nrtb_communication.a
+
+../lib/nrtb_communication.a:
+ @echo "============= building communication libs ==============="
+ @make action=lib doit
+ @ar -r ../lib/nrtb_communication.a obj/*.o
+ cp -a include/* ../include
+ @echo "============= communication libs complete ==============="
+
+modules:
+ @echo "============= building communication modules ==============="
+ @make doit
+ @echo "============= completed communication modules =============="
+
+clean:
+ @echo "============= cleaning communication libs ==============="
+ @make action=clean doit
+ @rm -fv obj/* lib/* include/*
+ @rm -fv ../lib/nrtb_communication.a
+ @echo "========== communication lib cleanup complete ==========="
+
+doit:
+ @cd triplet; make ${action}
+ @cd location_data; make ${action}
+ @cd velocity_data; make ${action}
+ @cd obj_setup_info; make ${action}
+ @cd sim_info; make ${action}
+ @cd sim_termination; make ${action}
+ @cd sim_stop; make ${action}
+ @cd tq_obj_data; make ${action}
+ @cd tq_update; make ${action}
+ @cd ack_nak; make ${action}
+ @cd sim_db_wrapper; make ${action}
+
=== added directory 'common/comm_handlers/ack_nak'
=== added file 'common/comm_handlers/ack_nak/Makefile'
--- common/comm_handlers/ack_nak/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/ack_nak/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: ack_nak_test
+ @./ack_nak_test
+ @cp -v ack_nak.h ../include/
+ @cp -v ack_nak.o ../obj/
+ @echo ack_nak build complete!
+
+ack_nak_test: ack_nak.o ack_nak_test.cpp
+ @rm -f ack_nak_test
+ g++ -c ack_nak_test.cpp -I ../../include -I ../include
+ g++ -o ack_nak_test ack_nak_test.o ack_nak.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+ack_nak.o: ack_nak.cpp ack_nak.h Makefile
+ @rm -f ack_nak.o
+ g++ -c -O3 ack_nak.cpp -I ../include -I ../../include
+
+clean:
+ @rm -vf *.o ../include/ack_nak.h ../obj/ack_nak.o ack_nak_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/ack_nak/ack_nak.cpp'
--- common/comm_handlers/ack_nak/ack_nak.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/ack_nak/ack_nak.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,94 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#include "ack_nak.h"
+
+#include <iostream>
+
+namespace nrtb_com
+{
+
+com_ack::com_ack()
+{
+ msg_uid = 0;
+};
+
+com_ack::com_ack(nrtb_msg::message_ack* ext)
+{
+ set_from_message(ext);
+};
+
+void com_ack::set_from_message(nrtb_msg::message_ack* ext)
+{
+ msg_uid = ext->msg_uid();
+};
+
+void com_ack::load_message(nrtb_msg::message_ack* ext)
+{
+ ext->set_msg_uid(msg_uid);
+};
+
+bool com_ack::operator==(com_ack& a)
+{
+ return msg_uid == a.msg_uid;
+};
+
+com_nak::com_nak()
+{
+ reason = none;
+ msg_uid = 0;
+ last_good_msg_uid = 0;
+};
+
+com_nak::com_nak(nrtb_msg::message_nak* ext)
+{
+ set_from_message(ext);
+};
+
+void com_nak::set_from_message(nrtb_msg::message_nak* ext)
+{
+ reason = codes(ext->reason());
+ if (ext->has_msg_uid())
+ msg_uid = ext->msg_uid();
+ else msg_uid = 0;
+ if (ext->has_last_good_msg_uid())
+ last_good_msg_uid = ext->last_good_msg_uid();
+ else last_good_msg_uid = 0;
+};
+
+void com_nak::load_message(nrtb_msg::message_nak* ext)
+{
+ ext->set_reason(reason);
+ if (msg_uid) ext->set_msg_uid(msg_uid);
+ else ext->clear_msg_uid();
+ if (last_good_msg_uid)
+ ext->set_last_good_msg_uid(last_good_msg_uid);
+ else ext->clear_last_good_msg_uid();
+};
+
+bool com_nak::operator==(com_nak& a)
+{
+ bool returnme = true;
+ returnme = (reason == a.reason) && returnme;
+ returnme = (msg_uid == a.msg_uid) && returnme;
+ returnme = (last_good_msg_uid == a.last_good_msg_uid) && returnme;
+ return returnme;
+};
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/ack_nak/ack_nak.h'
--- common/comm_handlers/ack_nak/ack_nak.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/ack_nak/ack_nak.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,72 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef ack_nak_header
+#define ack_nak_header
+
+#include <ack_nak.pb.h>
+#include <stdint.h>
+
+namespace nrtb_com {
+
+class com_ack
+{
+public:
+
+ uint32_t msg_uid;
+
+ com_ack();
+ com_ack(nrtb_msg::message_ack * ext);
+ virtual ~com_ack() {};
+
+ void set_from_message(nrtb_msg::message_ack * ext);
+ void load_message(nrtb_msg::message_ack * ext);
+
+ bool operator ==(com_ack & a);
+};
+
+class com_nak
+{
+public:
+ enum codes
+ {
+ none,
+ bad_message_length,
+ bad_message_parse,
+ overflow,
+ invalid_message,
+ sequence_error
+ };
+
+ codes reason;
+ uint32_t msg_uid;
+ uint32_t last_good_msg_uid;
+
+ com_nak();
+ com_nak(nrtb_msg::message_nak * ext);
+ virtual ~com_nak() {};
+
+ void set_from_message(nrtb_msg::message_nak * ext);
+ void load_message(nrtb_msg::message_nak * ext);
+
+ bool operator ==(com_nak & a);
+};
+
+} // namespace nrtb::com
+
+#endif // ack_nak_header
=== added file 'common/comm_handlers/ack_nak/ack_nak_test.cpp'
--- common/comm_handlers/ack_nak/ack_nak_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/ack_nak/ack_nak_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,64 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "ack_nak.h"
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ {
+ nrtb_com::com_ack t;
+ t.msg_uid = 2;
+ nrtb_msg::message_ack gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_ack a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_ack unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_ack unit test PASS" << endl;
+ };
+ }
+ {
+ nrtb_com::com_nak t;
+ t.reason = nrtb_com::com_nak::sequence_error;
+ t.msg_uid = 2;
+ t.last_good_msg_uid = 3;
+ nrtb_msg::message_nak gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_nak a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_nak unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_nak unit test PASS" << endl;
+ };
+ }
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/include'
=== added directory 'common/comm_handlers/lib'
=== added directory 'common/comm_handlers/location_data'
=== added file 'common/comm_handlers/location_data/Makefile'
--- common/comm_handlers/location_data/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/location_data/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,38 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: location_data_test
+ @./location_data_test
+ @cp -v location_data.h ../include/
+ @cp -v location_data.o ../obj/
+ @echo location_data build complete!
+
+location_data_test: location_data.o location_data_test.cpp
+ @rm -f location_data_test
+ g++ -c location_data_test.cpp -I ../../include -I ../include
+ g++ -o location_data_test location_data_test.o location_data.o ../obj/triplet.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+location_data.o: location_data.cpp location_data.h Makefile
+ @rm -f location_data.o
+ g++ -c -O3 location_data.cpp -I ../include -I../../include
+
+clean:
+ @rm -vf *.o ../include/location_data.h ../obj/location_data.o location_data_test
+ @echo all objects and executables have been erased.
+
+
=== added file 'common/comm_handlers/location_data/location_data.cpp'
--- common/comm_handlers/location_data/location_data.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/location_data/location_data.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,55 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "triplet.h"
+#include "location_data.h"
+
+namespace nrtb_com
+{
+
+com_location::com_location() {};
+
+
+com_location::com_location(nrtb_msg::location_data * ext)
+{
+ set_from_message(ext);
+};
+
+void com_location::set_from_message(nrtb_msg::location_data* ext)
+{
+ position.set_from_message(ext->mutable_position());
+ attitude.set_from_message(ext->mutable_attitude());
+};
+
+void com_location::load_message(nrtb_msg::location_data* ext)
+{
+ position.load_message(ext->mutable_position());
+ attitude.load_message(ext->mutable_attitude());
+};
+
+bool com_location::operator==(com_location& a)
+{
+ bool returnme = true;
+ returnme = (position == a.position) and returnme;
+ returnme = (attitude == a.attitude) and returnme;
+ return returnme;
+}
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/location_data/location_data.h'
--- common/comm_handlers/location_data/location_data.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/location_data/location_data.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,46 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef location_header
+#define location_header
+
+#include <triplet.h>
+#include <physics_common.pb.h>
+
+namespace nrtb_com {
+
+class com_location
+{
+public:
+ com_triplet position;
+ com_triplet attitude;
+
+ com_location();
+ com_location(nrtb_msg::location_data * ext);
+ virtual ~com_location() {};
+
+ void set_from_message(nrtb_msg::location_data* ext);
+ void load_message(nrtb_msg::location_data* ext);
+
+ bool operator ==(com_location & a);
+
+};
+
+} // namespace nrtb::com
+
+#endif // triplet_header
=== added file 'common/comm_handlers/location_data/location_data_test.cpp'
--- common/comm_handlers/location_data/location_data_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/location_data/location_data_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,48 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "location_data.h"
+#include <physics_common.pb.h>
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::triplet seeda (1,2,3);
+ nrtb_com::triplet seedb = seeda + 1;
+ nrtb_com::com_location t;
+ t.position.internal = seeda;
+ t.attitude.internal = seedb;
+ nrtb_msg::location_data gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_location a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_location unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_location unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/obj'
=== added directory 'common/comm_handlers/obj_setup_info'
=== added file 'common/comm_handlers/obj_setup_info/Makefile'
--- common/comm_handlers/obj_setup_info/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/obj_setup_info/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: obj_setup_info_test
+ @./obj_setup_info_test
+ @cp -v obj_setup_info.h ../include/
+ @cp -v obj_setup_info.o ../obj/
+ @echo obj_setup_info build complete!
+
+obj_setup_info_test: obj_setup_info.o obj_setup_info_test.cpp
+ @rm -f obj_setup_info_test
+ g++ -c obj_setup_info_test.cpp -I ../../include -I ../include
+ g++ -o obj_setup_info_test obj_setup_info_test.o obj_setup_info.o ../obj/triplet.o ../obj/location_data.o ../obj/velocity_data.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+obj_setup_info.o: obj_setup_info.cpp obj_setup_info.h Makefile
+ @rm -f obj_setup_info.o
+ g++ -c -O3 obj_setup_info.cpp -I ../include -I../..//include
+
+clean:
+ @rm -vf *.o ../include/obj_setup_info.h ../obj/obj_setup_info.o obj_setup_info_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/obj_setup_info/obj_setup_info.cpp'
--- common/comm_handlers/obj_setup_info/obj_setup_info.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/obj_setup_info/obj_setup_info.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,66 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#include "obj_setup_info.h"
+
+namespace nrtb_com
+{
+
+com_obj_setup::com_obj_setup()
+{
+ name = "uninitialized";
+ uid = 0;
+ obj_type = 0;
+};
+
+com_obj_setup::com_obj_setup(nrtb_msg::obj_setup_data* ext)
+{
+ set_from_message(ext);
+};
+
+void com_obj_setup::set_from_message(nrtb_msg::obj_setup_data* ext)
+{
+ uid = ext->uid();
+ name = ext->name();
+ obj_type = ext->obj_type();
+ location.set_from_message(ext->mutable_location());
+ velocity.set_from_message(ext->mutable_velocity());;
+};
+
+void com_obj_setup::load_message(nrtb_msg::obj_setup_data* ext)
+{
+ ext->set_uid(uid);
+ ext->set_name(name);
+ ext->set_obj_type(obj_type);
+ location.load_message(ext->mutable_location());
+ velocity.load_message(ext->mutable_velocity());
+};
+
+bool com_obj_setup::operator ==(com_obj_setup& a)
+{
+ bool returnme = true;
+ returnme = (a.location == location) && returnme;
+ returnme = (a.velocity == velocity) && returnme;
+ returnme = (a.uid == uid) && returnme;
+ returnme = (a.name == name) && returnme;
+ returnme = (a.obj_type == obj_type) && returnme;
+ return returnme;
+};
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/obj_setup_info/obj_setup_info.h'
--- common/comm_handlers/obj_setup_info/obj_setup_info.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/obj_setup_info/obj_setup_info.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,49 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef obj_setup_header
+#define obj_setup_header
+
+#include <location_data.h>
+#include <velocity_data.h>
+#include <sim_management.pb.h>
+
+namespace nrtb_com {
+
+class com_obj_setup
+{
+public:
+ uint32_t uid;
+ std::string name;
+ uint32_t obj_type;
+ com_location location;
+ com_velocity velocity;
+
+ com_obj_setup();
+ com_obj_setup(nrtb_msg::obj_setup_data * ext);
+ virtual ~com_obj_setup() {};
+
+ void set_from_message(nrtb_msg::obj_setup_data* ext);
+ void load_message(nrtb_msg::obj_setup_data* ext);
+
+ bool operator ==(com_obj_setup & a);
+};
+
+} // namespace nrtb::com
+
+#endif // triplet_header
=== added file 'common/comm_handlers/obj_setup_info/obj_setup_info_test.cpp'
--- common/comm_handlers/obj_setup_info/obj_setup_info_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/obj_setup_info/obj_setup_info_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,52 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "obj_setup_info.h"
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::triplet seeda(1,2,3);
+ nrtb_com::triplet seedb = seeda + 1;
+ nrtb_com::com_obj_setup t;
+ t.uid = 1;
+ t.name = "test_object";
+ t.obj_type = 2;
+ t.location.position.internal = seeda;
+ t.location.position.internal = seedb;
+ t.velocity.speed.internal = seedb;
+ t.velocity.speed.internal = seeda;
+ nrtb_msg::obj_setup_data gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_obj_setup a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_obj_setup unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_obj_setup unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/sim_db_wrapper'
=== added file 'common/comm_handlers/sim_db_wrapper/Makefile'
--- common/comm_handlers/sim_db_wrapper/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_db_wrapper/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: sim_db_wrapper_test
+ @./sim_db_wrapper_test
+ @cp -v sim_db_wrapper.h ../include/
+ @cp -v sim_db_wrapper.o ../obj/
+ @echo sim_db_wrapper build complete!
+
+sim_db_wrapper_test: sim_db_wrapper.o sim_db_wrapper_test.cpp
+ @rm -f sim_db_wrapper_test
+ g++ -c sim_db_wrapper_test.cpp -I ../../include -I ../include
+ g++ -o sim_db_wrapper_test sim_db_wrapper_test.o sim_db_wrapper.o ../obj/ack_nak.o ../obj/obj_setup_info.o ../obj/sim_stop.o ../obj/tq_obj.o ../obj/location_data.o ../obj/sim_setup_info.o ../obj/sim_termination.o ../obj/tq_update.o ../obj/velocity_data.o ../obj/triplet.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+sim_db_wrapper.o: sim_db_wrapper.cpp sim_db_wrapper.h Makefile
+ @rm -f sim_db_wrapper.o
+ g++ -c -O3 sim_db_wrapper.cpp -I ../include -I ../../include
+
+clean:
+ @rm -vf *.o ../include/sim_db_wrapper.h ../obj/sim_db_wrapper.o sim_db_wrapper_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/sim_db_wrapper/sim_db_wrapper.cpp'
--- common/comm_handlers/sim_db_wrapper/sim_db_wrapper.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_db_wrapper/sim_db_wrapper.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,142 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#include "sim_db_wrapper.h"
+
+#include <iostream>
+
+namespace nrtb_com
+{
+
+com_sim_to_db::com_sim_to_db()
+{
+ // No actions needed.
+};
+
+com_sim_to_db::com_sim_to_db(nrtb_msg::sim_to_db* ext)
+{
+ set_from_message(ext);
+};
+
+void com_sim_to_db::set_from_message(nrtb_msg::sim_to_db* ext)
+{
+ msg_uid = ext->msg_uid();
+ // check each payload type to see if it's included
+ if (ext->has_ack())
+ ack.reset(new com_ack(ext->mutable_ack()));
+ else
+ ack.reset();
+ // nak
+ if (ext->has_nak())
+ nak.reset(new com_nak(ext->mutable_nak()));
+ else
+ nak.reset();
+ // quanta update
+ if (ext->has_quanta_results())
+ quanta_results.reset(new com_tq_update(ext->mutable_quanta_results()));
+ else
+ quanta_results.reset();
+ // sim setup
+ if (ext->has_sim_setup())
+ sim_setup.reset(new com_sim_setup(ext->mutable_sim_setup()));
+ else
+ sim_setup.reset();
+ // simulation normal end
+ if (ext->has_sim_end())
+ sim_end.reset(new com_sim_termination(ext->mutable_sim_end()));
+ else
+ sim_end.reset();
+ // simulation end request from the data broker
+ if (ext->has_db_abort())
+ db_abort.reset(new com_request_sim_stop(ext->mutable_db_abort()));
+ else
+ db_abort.reset();
+};
+
+void com_sim_to_db::load_message(nrtb_msg::sim_to_db* ext)
+{
+ ext->set_msg_uid(msg_uid);
+ // check each payload and process as needed.
+ if (ack)
+ ack->load_message(ext->mutable_ack());
+ else
+ ext->clear_ack();
+ // nak
+ if (nak)
+ nak->load_message(ext->mutable_nak());
+ else
+ ext->clear_nak();
+ // time quanta update
+ if (quanta_results)
+ quanta_results->load_message(ext->mutable_quanta_results());
+ else
+ ext->clear_quanta_results();
+ // simulation setup
+ if (sim_setup)
+ sim_setup->load_message(ext->mutable_sim_setup());
+ else
+ ext->clear_sim_setup();
+ // simulation normal end
+ if (sim_end)
+ sim_end->load_message(ext->mutable_sim_end());
+ else
+ ext->clear_sim_end();
+ // simulation end request from data broker
+ if (db_abort)
+ db_abort->load_message(ext->mutable_db_abort());
+ else
+ ext->clear_db_abort();
+};
+
+bool com_sim_to_db::operator==(com_sim_to_db& a)
+{
+ bool returnme = msg_uid == a.msg_uid;
+ // ack
+ if ((ack) and (a.ack))
+ returnme = (*ack == *a.ack) && returnme;
+ else if (!((!ack) and (!a.ack)))
+ returnme = false;
+ // nak
+ if ((nak) and (a.nak))
+ returnme = (*nak == *a.nak) && returnme;
+ else if (!((!nak) and (!a.nak)))
+ returnme = false;
+ // time quanta update
+ if ((quanta_results) and (a.quanta_results))
+ returnme = (*quanta_results == *a.quanta_results) && returnme;
+ else if (!((!quanta_results) and (!a.quanta_results)))
+ returnme = false;
+ // simulation setup
+ if ((sim_setup) and (a.sim_setup))
+ returnme = (*sim_setup == *a.sim_setup) && returnme;
+ else if (!((!sim_setup) and (!a.sim_setup)))
+ returnme = false;
+ // simulation normal stop
+ if ((sim_end) and (a.sim_end))
+ returnme = (*sim_end == *a.sim_end) && returnme;
+ else if (!((!sim_end) and (!a.sim_end)))
+ returnme = false;
+ // simulation end request from data broker
+ if ((db_abort) and (a.db_abort))
+ returnme = (*db_abort == *a.db_abort) && returnme;
+ else if (!((!db_abort) and (!a.db_abort)))
+ returnme = false;
+};
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/sim_db_wrapper/sim_db_wrapper.h'
--- common/comm_handlers/sim_db_wrapper/sim_db_wrapper.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_db_wrapper/sim_db_wrapper.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,64 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef sim_db_wrapper_header
+#define sim_db_wrapper_header
+
+#include <ack_nak.h>
+#include <sim_setup_info.h>
+#include <tq_update.h>
+#include <sim_stop.h>
+#include <sim_termination.h>
+#include <sim_to_db_wrapper.pb.h>
+#include <boost/shared_ptr.hpp>
+#include <stdint.h>
+
+namespace nrtb_com {
+
+typedef boost::shared_ptr<com_ack> ack_p;
+typedef boost::shared_ptr<com_nak> nak_p;
+typedef boost::shared_ptr<com_tq_update> tq_update_p;
+typedef boost::shared_ptr<com_sim_setup> sim_setup_p;
+typedef boost::shared_ptr<com_sim_termination> sim_end_p;
+typedef boost::shared_ptr<com_request_sim_stop> request_stop_p;
+
+class com_sim_to_db
+{
+public:
+
+ uint32_t msg_uid;
+ ack_p ack;
+ nak_p nak;
+ tq_update_p quanta_results;
+ sim_setup_p sim_setup;
+ sim_end_p sim_end;
+ request_stop_p db_abort;
+
+ com_sim_to_db();
+ com_sim_to_db(nrtb_msg::sim_to_db * ext);
+ virtual ~com_sim_to_db() {};
+
+ void set_from_message(nrtb_msg::sim_to_db * ext);
+ void load_message(nrtb_msg::sim_to_db * ext);
+
+ bool operator ==(com_sim_to_db & a);
+};
+
+} // namespace nrtb::com
+
+#endif // ack_nak_header
=== added file 'common/comm_handlers/sim_db_wrapper/sim_db_wrapper_test.cpp'
--- common/comm_handlers/sim_db_wrapper/sim_db_wrapper_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_db_wrapper/sim_db_wrapper_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,50 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "sim_db_wrapper.h"
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::com_sim_to_db t;
+ t.msg_uid = 2;
+ t.ack.reset(new nrtb_com::com_ack);
+ t.nak.reset(new nrtb_com::com_nak);
+ t.quanta_results.reset(new nrtb_com::com_tq_update);
+ t.sim_setup.reset(new nrtb_com::com_sim_setup);
+ t.sim_end.reset(new nrtb_com::com_sim_termination);
+ t.db_abort.reset(new nrtb_com::com_request_sim_stop);
+ nrtb_msg::sim_to_db gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_sim_to_db a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_sim_to_db unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_sim_to_db unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/sim_info'
=== added file 'common/comm_handlers/sim_info/Makefile'
--- common/comm_handlers/sim_info/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_info/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: sim_setup_info_test
+ @./sim_setup_info_test
+ @cp -v sim_setup_info.h ../include/
+ @cp -v sim_setup_info.o ../obj/
+ @echo sim_setup_info build complete!
+
+sim_setup_info_test: sim_setup_info.o sim_setup_info_test.cpp
+ @rm -f sim_setup_info_test
+ g++ -c sim_setup_info_test.cpp -I ../../include -I ../include
+ g++ -o sim_setup_info_test sim_setup_info_test.o sim_setup_info.o ../obj/triplet.o ../obj/location_data.o ../obj/velocity_data.o ../obj/obj_setup_info.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+sim_setup_info.o: sim_setup_info.cpp sim_setup_info.h Makefile
+ @rm -f sim_setup_info.o
+ g++ -c -O3 sim_setup_info.cpp -I ../include -I../../include
+
+clean:
+ @rm -vf *.o ../include/sim_setup_info.h ../obj/sim_setup_info.o sim_setup_info_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/sim_info/sim_setup_info.cpp'
--- common/comm_handlers/sim_info/sim_setup_info.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_info/sim_setup_info.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,104 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#include "sim_setup_info.h"
+
+#include <iostream>
+
+namespace nrtb_com
+{
+
+com_sim_setup::com_sim_setup()
+{
+ name = "uninitialized";
+ model = name;
+ quanta_ms = 0;
+ max_quantas = 0;
+ started_by = name;
+ items.clear();
+};
+
+com_sim_setup::com_sim_setup(nrtb_msg::sim_setup_data* ext)
+{
+ set_from_message(ext);
+};
+
+void com_sim_setup::set_from_message(nrtb_msg::sim_setup_data* ext)
+{
+ // load the singular variables.
+ name = ext->name();
+ model = ext->model();
+ quanta_ms = ext->quanta_ms();
+ max_quantas = ext->max_quantas();
+ started_by = ext->started_by();
+ // process the listed objects
+ int count = ext->item_size();
+ for (int i=0; i<count; i++)
+ {
+ obj_p t(new com_obj_setup(ext->mutable_item(i)));
+ items.push_back(t);
+ };
+};
+
+void com_sim_setup::load_message(nrtb_msg::sim_setup_data* ext)
+{
+ // set the singular variables
+ ext->set_name(name);
+ ext->set_model(model);
+ ext->set_quanta_ms(quanta_ms);
+ ext->set_max_quantas(max_quantas);
+ ext->set_started_by(started_by);
+ // process the items list
+ ext->clear_item();
+ obj_list::iterator c = items.begin();
+ obj_list::iterator e = items.end();
+ while (c != e)
+ {
+ (*c)->load_message(ext->add_item());
+ c++;
+ };
+};
+
+bool com_sim_setup::operator ==(com_sim_setup& a)
+{
+ bool returnme = true;
+ // check the singular variables
+ returnme = (name == a.name) and returnme;
+ returnme = (model == a.model) and returnme;
+ returnme = (quanta_ms == a.quanta_ms) and returnme;
+ returnme = (max_quantas == a.max_quantas) and returnme;
+ returnme = (started_by == a.started_by) and returnme;
+ // check the items listed.
+ if (items.size() != a.items.size())
+ {
+ // failed for sure.
+ returnme = false;
+ }
+ else
+ {
+ // check them to see if they are the same.
+ for (int i=0; i<items.size(); i++)
+ {
+ returnme = (*items[i] == *a.items[i]) and returnme;
+ };
+ };
+ return returnme;
+};
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/sim_info/sim_setup_info.h'
--- common/comm_handlers/sim_info/sim_setup_info.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_info/sim_setup_info.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,53 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef sim_setup_header
+#define sim_setup_header
+
+#include <obj_setup_info.h>
+#include <sim_management.pb.h>
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
+namespace nrtb_com {
+
+class com_sim_setup
+{
+public:
+ std::string name;
+ std::string model;
+ uint32_t quanta_ms;
+ uint32_t max_quantas;
+ std::string started_by;
+ typedef boost::shared_ptr<com_obj_setup> obj_p;
+ typedef std::vector<obj_p> obj_list;
+ obj_list items;
+
+ com_sim_setup();
+ com_sim_setup(nrtb_msg::sim_setup_data * ext);
+ virtual ~com_sim_setup() {};
+
+ void set_from_message(nrtb_msg::sim_setup_data* ext);
+ void load_message(nrtb_msg::sim_setup_data* ext);
+
+ bool operator ==(com_sim_setup & a);
+};
+
+} // namespace nrtb::com
+
+#endif // sim_setup_header
=== added file 'common/comm_handlers/sim_info/sim_setup_info_test.cpp'
--- common/comm_handlers/sim_info/sim_setup_info_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_info/sim_setup_info_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,57 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "sim_setup_info.h"
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::com_sim_setup t;
+ // setup single vars.
+ t.name = "test sim";
+ t.model = "test model";
+ t.quanta_ms = 1000 / 50;
+ t.max_quantas = 100;
+ t.started_by = "me";
+ // setup 50 objects
+ for (int i=0; i<50; i++)
+ {
+ nrtb_com::com_sim_setup::obj_p o(new nrtb_com::com_obj_setup());
+ o->uid = i;
+ t.items.push_back(o);
+ };
+ // run the test.
+ nrtb_msg::sim_setup_data gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_sim_setup a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_sim_setup unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_sim_setup unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/sim_stop'
=== added file 'common/comm_handlers/sim_stop/Makefile'
--- common/comm_handlers/sim_stop/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_stop/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: sim_stop_test
+ @./sim_stop_test
+ @cp -v sim_stop.h ../include/
+ @cp -v sim_stop.o ../obj/
+ @echo sim_stop build complete!
+
+sim_stop_test: sim_stop.o sim_stop_test.cpp
+ @rm -f sim_stop_test
+ g++ -c sim_stop_test.cpp -I ../../include -I ../include
+ g++ -o sim_stop_test sim_stop_test.o sim_stop.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+sim_stop.o: sim_stop.cpp sim_stop.h Makefile
+ @rm -f sim_stop.o
+ g++ -c -O3 sim_stop.cpp -I ../include -I ../../include
+
+clean:
+ @rm -vf *.o ../include/sim_stop.h ../obj/sim_stop.o sim_stop_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/sim_stop/sim_stop.cpp'
--- common/comm_handlers/sim_stop/sim_stop.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_stop/sim_stop.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,63 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#include "sim_stop.h"
+
+#include <iostream>
+
+namespace nrtb_com
+{
+
+com_request_sim_stop::com_request_sim_stop()
+{
+ failed = false;
+ reason = "";
+};
+
+com_request_sim_stop::com_request_sim_stop(nrtb_msg::db_request_sim_stop* ext)
+{
+ set_from_message(ext);
+};
+
+void com_request_sim_stop::set_from_message(nrtb_msg::db_request_sim_stop* ext)
+{
+ failed = ext->failed();
+ if (ext->has_reason())
+ reason = ext->reason();
+ else
+ reason = "";
+};
+
+void com_request_sim_stop::load_message(nrtb_msg::db_request_sim_stop* ext)
+{
+ ext->set_failed(failed);
+ if (reason != "")
+ ext->set_reason(reason);
+};
+
+bool com_request_sim_stop::operator==(com_request_sim_stop& a)
+{
+ bool returnme = true;
+ returnme = (failed == a.failed) and returnme;
+ returnme = (reason == a.reason) and returnme;
+ return returnme;
+};
+
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/sim_stop/sim_stop.h'
--- common/comm_handlers/sim_stop/sim_stop.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_stop/sim_stop.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,45 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef sim_stop_header
+#define sim_stop_header
+
+#include <sim_management.pb.h>
+#include <boost/shared_ptr.hpp>
+
+namespace nrtb_com {
+
+class com_request_sim_stop
+{
+public:
+ bool failed;
+ std::string reason;
+
+ com_request_sim_stop();
+ com_request_sim_stop(nrtb_msg::db_request_sim_stop * ext);
+ virtual ~com_request_sim_stop() {};
+
+ void set_from_message(nrtb_msg::db_request_sim_stop * ext);
+ void load_message(nrtb_msg::db_request_sim_stop * ext);
+
+ bool operator ==(com_request_sim_stop & a);
+};
+
+} // namespace nrtb::com
+
+#endif // sim_stop_header
=== added file 'common/comm_handlers/sim_stop/sim_stop_test.cpp'
--- common/comm_handlers/sim_stop/sim_stop_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_stop/sim_stop_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,47 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "sim_stop.h"
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::com_request_sim_stop t;
+ // setup single vars.
+ t.failed = true;
+ t.reason = "test message";
+ // run the test.
+ nrtb_msg::db_request_sim_stop gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_request_sim_stop a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_request_sim_stop unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_request_sim_stop unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/sim_termination'
=== added file 'common/comm_handlers/sim_termination/Makefile'
--- common/comm_handlers/sim_termination/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_termination/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: sim_termination_test
+ @./sim_termination_test
+ @cp -v sim_termination.h ../include/
+ @cp -v sim_termination.o ../obj/
+ @echo sim_termination build complete!
+
+sim_termination_test: sim_termination.o sim_termination_test.cpp
+ @rm -f sim_termination_test
+ g++ -c sim_termination_test.cpp -I ../../include -I ../include
+ g++ -o sim_termination_test sim_termination_test.o sim_termination.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+sim_termination.o: sim_termination.cpp sim_termination.h Makefile
+ @rm -f sim_termination.o
+ g++ -c -O3 sim_termination.cpp -I ../include -I../../include
+
+clean:
+ @rm -vf *.o ../include/sim_termination.h ../obj/sim_termination.o sim_termination_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/sim_termination/sim_termination.cpp'
--- common/comm_handlers/sim_termination/sim_termination.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_termination/sim_termination.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,79 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#include "sim_termination.h"
+
+#include <iostream>
+
+namespace nrtb_com
+{
+
+com_sim_termination::com_sim_termination()
+{
+ last_quanta = 0;
+ reason = "";
+ error_code = 0;
+ avg_cook_ms = 0.0;
+ avg_quanta_ms = 0.0;
+};
+
+com_sim_termination::com_sim_termination(nrtb_msg::sim_termination_data* ext)
+{
+ set_from_message(ext);
+};
+
+void com_sim_termination::set_from_message(nrtb_msg::sim_termination_data* ext)
+{
+ last_quanta = ext->last_quanta();
+ reason = ext->reason();
+ error_code = ext->error_code();
+ if (ext->has_avg_cook_ms())
+ avg_cook_ms = ext->avg_cook_ms();
+ else
+ avg_cook_ms = 0;
+ if (ext->has_avg_quanta_ms())
+ avg_quanta_ms = ext->avg_quanta_ms();
+ else
+ avg_quanta_ms = 0;
+};
+
+void com_sim_termination::load_message(nrtb_msg::sim_termination_data* ext)
+{
+ ext->set_last_quanta(last_quanta);
+ ext->set_reason(reason);
+ ext->set_error_code(error_code);
+ if (avg_cook_ms > 0)
+ ext->set_avg_cook_ms(avg_cook_ms);
+ if (avg_quanta_ms)
+ ext->set_avg_quanta_ms(avg_quanta_ms);
+};
+
+bool com_sim_termination::operator==(com_sim_termination& a)
+{
+ bool returnme = true;
+ returnme = (last_quanta == a.last_quanta) and returnme;
+ returnme = (reason == a.reason) and returnme;
+ returnme = (error_code == a.error_code) and returnme;
+ returnme = (avg_cook_ms == a.avg_cook_ms) and returnme;
+ returnme = (avg_quanta_ms == a.avg_quanta_ms) and returnme;
+ return returnme;
+};
+
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/sim_termination/sim_termination.h'
--- common/comm_handlers/sim_termination/sim_termination.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_termination/sim_termination.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,48 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef sim_termination_header
+#define sim_termination_header
+
+#include <sim_management.pb.h>
+#include <boost/shared_ptr.hpp>
+
+namespace nrtb_com {
+
+class com_sim_termination
+{
+public:
+ uint32_t last_quanta;
+ std::string reason;
+ uint32_t error_code;
+ float avg_cook_ms;
+ float avg_quanta_ms;
+
+ com_sim_termination();
+ com_sim_termination(nrtb_msg::sim_termination_data * ext);
+ virtual ~com_sim_termination() {};
+
+ void set_from_message(nrtb_msg::sim_termination_data * ext);
+ void load_message(nrtb_msg::sim_termination_data * ext);
+
+ bool operator ==(com_sim_termination & a);
+};
+
+} // namespace nrtb::com
+
+#endif // sim_terminmation_header
=== added file 'common/comm_handlers/sim_termination/sim_termination_test.cpp'
--- common/comm_handlers/sim_termination/sim_termination_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/sim_termination/sim_termination_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,50 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "sim_termination.h"
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::com_sim_termination t;
+ // setup single vars.
+ t.last_quanta = 8126313;
+ t.reason = "test message";
+ t.error_code = 12;
+ t.avg_cook_ms = 17.342;
+ t.avg_quanta_ms = 1000/50;
+ // run the test.
+ nrtb_msg::sim_termination_data gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_sim_termination a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_sim_termination unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_sim_termination unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/tq_obj_data'
=== added file 'common/comm_handlers/tq_obj_data/Makefile'
--- common/comm_handlers/tq_obj_data/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/tq_obj_data/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: tq_obj_test
+ @./tq_obj_test
+ @cp -v tq_obj.h ../include/
+ @cp -v tq_obj.o ../obj/
+ @echo tq_obj_update build complete!
+
+tq_obj_test: tq_obj.o tq_obj_test.cpp
+ @rm -f tq_obj_test
+ g++ -c tq_obj_test.cpp -I ../../include -I ../include
+ g++ -o tq_obj_test tq_obj_test.o tq_obj.o ../obj/triplet.o ../obj/location_data.o ../obj/velocity_data.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+tq_obj.o: tq_obj.cpp tq_obj.h Makefile
+ @rm -f tq_obj.o
+ g++ -c -O3 tq_obj.cpp -I ../include -I../../include
+
+clean:
+ @rm -vf *.o ../include/tq_obj.h ../obj/tq_obj.o tq_obj_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/tq_obj_data/tq_obj.cpp'
--- common/comm_handlers/tq_obj_data/tq_obj.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/tq_obj_data/tq_obj.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,134 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#include "tq_obj.h"
+
+namespace nrtb_com
+{
+
+com_tq_obj_update::com_tq_obj_update()
+{
+ obj_uid = 0;
+ event.clear();
+ inbound_com.clear();
+ outbound_com.clear();
+};
+
+com_tq_obj_update::com_tq_obj_update(nrtb_msg::sim_obj_tq_data* ext)
+{
+ set_from_message(ext);
+};
+
+void com_tq_obj_update::set_from_message(nrtb_msg::sim_obj_tq_data* ext)
+{
+ obj_uid = ext->obj_uid();
+ location.set_from_message(ext->mutable_location());
+ velocity.set_from_message(ext->mutable_velocity());
+ // load the events
+ int l = ext->event_size();
+ for (int i=0; i<l; i++)
+ {
+ event.push_back(ext->event(i));
+ };
+ // load the inbound messages
+ l = ext->inbound_comm_size();
+ for (int i=0; i<l; i++)
+ {
+ inbound_com.push_back(ext->inbound_comm(i));
+ };
+ // load the outbound messages
+ l = ext->outbound_comm_size();
+ for (int i=0; i<l; i++)
+ {
+ outbound_com.push_back(ext->outbound_comm(i));
+ };
+};
+
+void com_tq_obj_update::load_message(nrtb_msg::sim_obj_tq_data* ext)
+{
+ ext->set_obj_uid(obj_uid);
+ location.load_message(ext->mutable_location());
+ velocity.load_message(ext->mutable_velocity());
+ // load the events
+ typedef nrtb::strlist::iterator it;
+ it c = event.begin();
+ it e = event.end();
+ while (c != e)
+ {
+ ext->add_event(*c);
+ c++;
+ };
+ // load inbound com messages
+ c = inbound_com.begin();
+ e = inbound_com.end();
+ while (c != e)
+ {
+ ext->add_inbound_comm(*c);
+ c++;
+ };
+ // load outbound com messages
+ c = outbound_com.begin();
+ e = outbound_com.end();
+ while (c != e)
+ {
+ ext->add_outbound_comm(*c);
+ c++;
+ };
+};
+
+bool com_tq_obj_update::operator ==(com_tq_obj_update& a)
+{
+ bool returnme = true;
+ returnme = (a.obj_uid = obj_uid) && returnme;
+ returnme = (a.location == location) && returnme;
+ returnme = (a.velocity == velocity) && returnme;
+ // check the events
+ returnme = (a.event.size() == event.size()) && returnme;
+ if (returnme)
+ {
+ int l = event.size();
+ for (int i=0; i<l; i++)
+ {
+ returnme = (a.event[i] == event[i]) && returnme;
+ };
+ };
+ // check the inbound messages
+ returnme = (a.inbound_com.size() == inbound_com.size()) && returnme;
+ if (returnme)
+ {
+ int l = inbound_com.size();
+ for (int i=0; i<l; i++)
+ {
+ returnme = (a.inbound_com[i] == inbound_com[i]) && returnme;
+ };
+ };
+ // check out outbound messages
+ returnme = (a.outbound_com.size() == outbound_com.size()) && returnme;
+ if (returnme)
+ {
+ int l = outbound_com.size();
+ for (int i=0; i<l; i++)
+ {
+ returnme = (a.outbound_com[i] == outbound_com[i]) && returnme;
+ };
+ };
+ return returnme;
+};
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/tq_obj_data/tq_obj.h'
--- common/comm_handlers/tq_obj_data/tq_obj.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/tq_obj_data/tq_obj.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,50 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef tq_obj_update_header
+#define tq_obj_update_header
+
+#include <location_data.h>
+#include <velocity_data.h>
+#include <sim_obj_tq_update.pb.h>
+
+namespace nrtb_com {
+
+class com_tq_obj_update
+{
+public:
+ uint32_t obj_uid;
+ com_location location;
+ com_velocity velocity;
+ nrtb::strlist event;
+ nrtb::strlist inbound_com;
+ nrtb::strlist outbound_com;
+
+ com_tq_obj_update();
+ com_tq_obj_update(nrtb_msg::sim_obj_tq_data * ext);
+ virtual ~com_tq_obj_update() {};
+
+ void set_from_message(nrtb_msg::sim_obj_tq_data* ext);
+ void load_message(nrtb_msg::sim_obj_tq_data* ext);
+
+ bool operator ==(com_tq_obj_update & a);
+};
+
+} // namespace nrtb::com
+
+#endif // triplet_header
=== added file 'common/comm_handlers/tq_obj_data/tq_obj_test.cpp'
--- common/comm_handlers/tq_obj_data/tq_obj_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/tq_obj_data/tq_obj_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,73 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "tq_obj.h"
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::triplet seeda(1,2,3);
+ nrtb_com::triplet seedb = seeda + 1;
+ nrtb_com::com_tq_obj_update t;
+ t.obj_uid = 1;
+ t.location.position.internal = seeda;
+ t.location.position.internal = seedb;
+ t.velocity.speed.internal = seedb;
+ t.velocity.speed.internal = seeda;
+ // populate events
+ for (int i=0; i<10; i++)
+ {
+ stringstream buffer;
+ buffer << "event " << i;
+ t.event.push_back(buffer.str());
+ };
+ // populate inbound_com
+ for (int i=0; i<10; i++)
+ {
+ stringstream buffer;
+ buffer << "Command " << i;
+ t.inbound_com.push_back(buffer.str());
+ };
+ // populate outbound_com
+ for (int i=0; i<10; i++)
+ {
+ stringstream buffer;
+ buffer << "Response " << i;
+ t.outbound_com.push_back(buffer.str());
+ };
+ // start test.
+ nrtb_msg::sim_obj_tq_data gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_tq_obj_update a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_tq_obj_update unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_tq_obj_update unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/tq_update'
=== added file 'common/comm_handlers/tq_update/Makefile'
--- common/comm_handlers/tq_update/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/tq_update/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: tq_update_test
+ @./tq_update_test
+ @cp -v tq_update.h ../include/
+ @cp -v tq_update.o ../obj/
+ @echo tq_update_update build complete!
+
+tq_update_test: tq_update.o tq_update_test.cpp
+ @rm -f tq_update_test
+ g++ -c tq_update_test.cpp -I ../../include -I ../include
+ g++ -o tq_update_test tq_update_test.o tq_update.o ../obj/triplet.o ../obj/location_data.o ../obj/velocity_data.o ../obj/tq_obj.o ../obj/obj_setup_info.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+tq_update.o: tq_update.cpp tq_update.h Makefile
+ @rm -f tq_update.o
+ g++ -c -O3 tq_update.cpp -I ../include -I../../include
+
+clean:
+ @rm -vf *.o ../include/tq_update.h ../obj/tq_update.o tq_update_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/tq_update/tq_update.cpp'
--- common/comm_handlers/tq_update/tq_update.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/tq_update/tq_update.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,110 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#include "tq_update.h"
+#include <boost/shared_ptr.hpp>
+
+
+namespace nrtb_com
+{
+com_tq_update::com_tq_update()
+{
+ quanta_id = 0;
+ sim_uid = 0;
+};
+
+com_tq_update::com_tq_update(nrtb_msg::tq_data* ext)
+{
+ set_from_message(ext);
+};
+
+void com_tq_update::set_from_message(nrtb_msg::tq_data* ext)
+{
+ quanta_id = ext->quanta_id();
+ sim_uid = ext->sim_uid();
+ // load the updates
+ int l = ext->obj_data_size();
+ for (int i=0; i<l; i++)
+ {
+ com_tq_obj_update update(ext->mutable_obj_data(i));
+ obj_data.push_back(update);
+ };
+ // load the new objects
+ l = ext->new_objs_size();
+ for (int i=0; i<l; i++)
+ {
+ com_obj_setup obj(ext->mutable_new_objs(i));
+ new_objs.push_back(obj);
+ };
+};
+
+void com_tq_update::load_message(nrtb_msg::tq_data* ext)
+{
+ ext->set_quanta_id(quanta_id);
+ ext->set_sim_uid(sim_uid);
+ {
+ // load the updates
+ up_list::iterator c = obj_data.begin();
+ up_list::iterator e = obj_data.end();
+ while (c != e)
+ {
+ c->load_message(ext->add_obj_data());
+ c++;
+ };
+ }
+ {
+ // load the new objs
+ ob_list::iterator c = new_objs.begin();
+ ob_list::iterator e = new_objs.end();
+ while (c != e)
+ {
+ c->load_message(ext->add_new_objs());
+ c++;
+ };
+ }
+};
+
+bool com_tq_update::operator==(com_tq_update& a)
+{
+ bool returnme = true;
+ returnme = (quanta_id == a.quanta_id) && returnme;
+ returnme = (sim_uid == a.sim_uid) && returnme;
+ // check the updated objects list
+ returnme = (obj_data.size() == a.obj_data.size()) && returnme;
+ if (returnme)
+ {
+ int l = obj_data.size();
+ for (int i=1; i<l; i++)
+ {
+ returnme = (obj_data[i] == a.obj_data[i]) && returnme;
+ };
+ };
+ // check the new objects list
+ returnme = (new_objs.size() == a.new_objs.size()) && returnme;
+ if (returnme)
+ {
+ int l = new_objs.size();
+ for (int i=0; i<l; i++)
+ {
+ returnme = (new_objs[i] == a.new_objs[i]) && returnme;
+ };
+ };
+};
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/tq_update/tq_update.h'
--- common/comm_handlers/tq_update/tq_update.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/tq_update/tq_update.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,56 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef tq_update_header
+#define tq_update_header
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+#include <location_data.h>
+#include <velocity_data.h>
+#include <tq_obj.h>
+#include <obj_setup_info.h>
+#include <sim_obj_tq_update.pb.h>
+
+namespace nrtb_com {
+
+class com_tq_update
+{
+public:
+ typedef boost::shared_ptr<nrtb_com::com_tq_obj_update> up_p;
+ typedef boost::shared_ptr<nrtb_com::com_obj_setup> obj_p;
+ typedef std::vector<nrtb_com::com_tq_obj_update> up_list;
+ typedef std::vector<nrtb_com::com_obj_setup> ob_list;
+ uint32_t quanta_id;
+ uint32_t sim_uid;
+ up_list obj_data;
+ ob_list new_objs;
+
+ com_tq_update();
+ com_tq_update(nrtb_msg::tq_data * ext);
+ virtual ~com_tq_update() {};
+
+ void set_from_message(nrtb_msg::tq_data* ext);
+ void load_message(nrtb_msg::tq_data* ext);
+
+ bool operator ==(com_tq_update & a);
+};
+
+} // namespace nrtb::com
+
+#endif // triplet_header
=== added file 'common/comm_handlers/tq_update/tq_update_test.cpp'
--- common/comm_handlers/tq_update/tq_update_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/tq_update/tq_update_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,105 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "tq_update.h"
+#include <serializer.h>
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+nrtb::serializer sequence;
+
+nrtb_com::com_tq_obj_update mk_update()
+{
+ nrtb_com::com_tq_obj_update returnme;
+ returnme.obj_uid = sequence();
+ returnme.location.position.internal = sequence();
+ returnme.location.attitude.internal = sequence();
+ returnme.velocity.speed.internal = sequence();
+ returnme.velocity.rotation.internal = sequence();
+ // load events
+ for (int i=0; i<10; i++)
+ {
+ stringstream buffer;
+ buffer << "Event " << sequence();
+ returnme.event.push_back(buffer.str());
+ };
+ // load inbound
+ for (int i=0; i<10; i++)
+ {
+ stringstream buffer;
+ buffer << "Inbound " << sequence();
+ returnme.inbound_com.push_back(buffer.str());
+ };
+ // load outbound
+ for (int i=0; i<10; i++)
+ {
+ stringstream buffer;
+ buffer << "Outbound " << sequence();
+ returnme.outbound_com.push_back(buffer.str());
+ };
+ return returnme;
+};
+
+nrtb_com::com_obj_setup mk_new()
+{
+ nrtb_com::com_obj_setup returnme;
+ returnme.uid = sequence();
+ stringstream buffer;
+ buffer << "Object " << sequence();
+ returnme.name = buffer.str();
+ returnme.location.position.internal = sequence();
+ returnme.location.attitude.internal = sequence();
+ returnme.velocity.speed.internal = sequence();
+ returnme.velocity.rotation.internal = sequence();
+ returnme.obj_type = sequence();
+ return returnme;
+};
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::triplet seeda(1,2,3);
+ nrtb_com::triplet seedb = seeda + 1;
+ nrtb_com::com_tq_update t;
+ for (int i=0; i<45; i++)
+ {
+ t.obj_data.push_back(mk_update());
+ };
+ for (int i=0; i<5; i++)
+ {
+ t.new_objs.push_back(mk_new());
+ };
+ // start test.
+ nrtb_msg::tq_data gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_tq_update a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_tq_update unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_tq_update unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/triplet'
=== added file 'common/comm_handlers/triplet/Makefile'
--- common/comm_handlers/triplet/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/triplet/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: triplet_test
+ @./triplet_test
+ @cp -v triplet.h ../include/
+ @cp -v triplet.o ../obj/
+ @echo triplet build complete!
+
+triplet_test: triplet.o triplet_test.cpp
+ @rm -f triplet_test
+ g++ -c triplet_test.cpp -I ../../include
+ g++ -o triplet_test triplet_test.o triplet.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+triplet.o: triplet.cpp triplet.h Makefile
+ @rm -f triplet.o
+ g++ -c -O3 triplet.cpp -I../../include
+
+clean:
+ @rm -vf *.o ../include/triplet.h ../obj/triplet.o triplet_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/triplet/triplet.cpp'
--- common/comm_handlers/triplet/triplet.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/triplet/triplet.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,57 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "triplet.h"
+
+namespace nrtb_com
+{
+
+com_triplet::com_triplet()
+{};
+
+com_triplet::com_triplet(nrtb_msg::triplet* ext)
+{
+ set_from_message(ext);
+};
+
+void com_triplet::set_from_message(nrtb_msg::triplet* ext)
+{
+ internal = 0;
+ internal.x = ext->x();
+ internal.y = ext->y();
+ internal.z = ext->z();
+};
+
+void com_triplet::load_message(nrtb_msg::triplet* ext)
+{
+ ext->set_x(internal.x);
+ ext->set_y(internal.y);
+ ext->set_z(internal.z);
+};
+
+bool com_triplet::operator==(com_triplet& a)
+{
+ return internal == a.internal;
+}
+
+
+
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/triplet/triplet.h'
--- common/comm_handlers/triplet/triplet.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/triplet/triplet.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,47 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef triplet_header
+#define triplet_header
+
+#include <triad.h>
+#include <physics_common.pb.h>
+
+namespace nrtb_com {
+
+// -- typedefs to be used by callers
+typedef nrtb::triad<long double> triplet;
+
+class com_triplet
+{
+public:
+ triplet internal;
+
+ com_triplet();
+ com_triplet(nrtb_msg::triplet* ext);
+ virtual ~com_triplet() {};
+
+ void set_from_message(nrtb_msg::triplet* ext);
+ void load_message(nrtb_msg::triplet* ext);
+
+ bool operator ==(com_triplet & a);
+};
+
+} // namespace nrtb::com
+
+#endif // triplet_header
=== added file 'common/comm_handlers/triplet/triplet_test.cpp'
--- common/comm_handlers/triplet/triplet_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/triplet/triplet_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,47 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "triplet.h"
+#include <physics_common.pb.h>
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::triplet seed(1,2,3);
+ nrtb_com::com_triplet t;
+ t.internal = seed;
+ nrtb_msg::triplet gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_triplet a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_triplet unit test FAIL "
+ << t.internal << " : " << a.internal << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_triplet unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added directory 'common/comm_handlers/velocity_data'
=== added file 'common/comm_handlers/velocity_data/Makefile'
--- common/comm_handlers/velocity_data/Makefile 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/velocity_data/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,37 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: velocity_data_test
+ @./velocity_data_test
+ @cp -v velocity_data.h ../include/
+ @cp -v velocity_data.o ../obj/
+ @echo velocity_data build complete!
+
+velocity_data_test: velocity_data.o velocity_data_test.cpp
+ @rm -f velocity_data_test
+ g++ -c velocity_data_test.cpp -I ../../include -I ../include
+ g++ -o velocity_data_test velocity_data_test.o velocity_data.o ../obj/triplet.o ../../lib/nrtb_common.a ../../lib/nrtb_gpb.a -lprotobuf -lpthread
+
+velocity_data.o: velocity_data.cpp velocity_data.h Makefile
+ @rm -f velocity_data.o
+ g++ -c -O3 velocity_data.cpp -I ../include -I../../include
+
+clean:
+ @rm -vf *.o ../include/velocity_data.h ../obj/velocity_data.o velocity_data_test
+ @echo all objects and executables have been erased.
+
=== added file 'common/comm_handlers/velocity_data/velocity_data.cpp'
--- common/comm_handlers/velocity_data/velocity_data.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/velocity_data/velocity_data.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,55 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "triplet.h"
+#include "velocity_data.h"
+
+namespace nrtb_com
+{
+
+com_velocity::com_velocity() {};
+
+
+com_velocity::com_velocity(nrtb_msg::velocity_data * ext)
+{
+ set_from_message(ext);
+};
+
+void com_velocity::set_from_message(nrtb_msg::velocity_data* ext)
+{
+ speed.set_from_message(ext->mutable_speed());
+ rotation.set_from_message(ext->mutable_rotation());
+};
+
+void com_velocity::load_message(nrtb_msg::velocity_data* ext)
+{
+ speed.load_message(ext->mutable_speed());
+ rotation.load_message(ext->mutable_rotation());
+};
+
+bool com_velocity::operator==(com_velocity& a)
+{
+ bool returnme = true;
+ returnme = (speed == a.speed) and returnme;
+ returnme = (rotation == a.rotation) and returnme;
+ return returnme;
+};
+
+} // namespace nrtb::com
+
=== added file 'common/comm_handlers/velocity_data/velocity_data.h'
--- common/comm_handlers/velocity_data/velocity_data.h 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/velocity_data/velocity_data.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,45 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef velocity_header
+#define velocity_header
+
+#include <triplet.h>
+#include <physics_common.pb.h>
+
+namespace nrtb_com {
+
+class com_velocity
+{
+public:
+ com_triplet speed;
+ com_triplet rotation;
+
+ com_velocity();
+ com_velocity(nrtb_msg::velocity_data * ext);
+ virtual ~com_velocity() {};
+
+ void set_from_message(nrtb_msg::velocity_data* ext);
+ void load_message(nrtb_msg::velocity_data* ext);
+
+ bool operator ==(com_velocity & a);
+};
+
+} // namespace nrtb::com
+
+#endif // triplet_header
=== added file 'common/comm_handlers/velocity_data/velocity_data_test.cpp'
--- common/comm_handlers/velocity_data/velocity_data_test.cpp 1970-01-01 00:00:00 +0000
+++ common/comm_handlers/velocity_data/velocity_data_test.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,48 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "velocity_data.h"
+#include <physics_common.pb.h>
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int returncode = 0;
+ nrtb_com::triplet seeda(1,2,3);
+ nrtb_com::triplet seedb = seeda + 1;
+ nrtb_com::com_velocity t;
+ t.speed.internal = seeda;
+ t.rotation.internal = seedb;
+ nrtb_msg::velocity_data gpb;
+ t.load_message(&gpb);
+ nrtb_com::com_velocity a(&gpb);
+ if (!(t == a))
+ {
+ returncode = 1;
+ cout << "nrtb_com::com_velocity unit test FAIL " << endl;
+ }
+ else
+ {
+ cout << "nrtb_com::com_velocity unit test PASS" << endl;
+ };
+
+ return returncode;
+};
\ No newline at end of file
=== added file 'sim_engine/Makefile'
--- sim_engine/Makefile 1970-01-01 00:00:00 +0000
+++ sim_engine/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,45 @@
+#***********************************************
+#This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: ./bin/nrtb_simulation
+
+./bin/nrtb_simulation: ../common/nrtb_common.a
+ @echo "============= building simulation engine ==============="
+ @make action=lib doit
+ #temp target
+ touch ./bin/nrtb_simulation
+ @echo temp target created.
+ @echo "============= simulation engine complete ==============="
+
+modules:
+ @echo "============= building simulation engine ==============="
+ @make doit
+ @echo "============= completed simulation engine =============="
+
+clean:
+ @echo "============= cleaning simulation engine ==============="
+ @make action=clean doit
+ @rm -fv .obj/* ./lib/* ./include/* ./bin/*
+ @echo "========== simulation engine cleanup complete ==========="
+
+doit:
+ cd comm_manager; make ${action}
+
+../common/nrtb_common.a:
+ @cd ../common; make
+
=== added directory 'sim_engine/comm_manager'
=== added file 'sim_engine/comm_manager/Makefile'
--- sim_engine/comm_manager/Makefile 1970-01-01 00:00:00 +0000
+++ sim_engine/comm_manager/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,39 @@
+#***********************************************
+#This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: ../lib/sim_communications.a
+
+../lib/sim_communications.a:
+ @echo "============= building communication libs ==============="
+# @make action=lib doit
+ @touch ../lib/sim_communications.a
+ @echo "============= communication libs complete ==============="
+
+modules:
+ @echo "============= building communication modules ==============="
+ @make doit
+ @echo "============= completed communication modules =============="
+
+clean:
+ @echo "============= cleaning communication libs ==============="
+# @make action=clean doit
+ @rm -fv ../lib/sim_communications.a
+ @echo "========== communication lib cleanup complete ==========="
+
+doit:
+
=== added directory 'sim_engine/comm_manager/in_processor'
=== added directory 'sim_engine/comm_manager/manager'
=== added file 'sim_engine/comm_manager/manager/Makefile'
--- sim_engine/comm_manager/manager/Makefile 1970-01-01 00:00:00 +0000
+++ sim_engine/comm_manager/manager/Makefile 2011-12-29 11:10:29 +0000
@@ -0,0 +1,42 @@
+#***********************************************
+# This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+# NRTB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NRTB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+lib: sim_db_channel_test
+ @./sim_db_channel_test
+ @cp -v sim_db_channel.h ../include/
+ @cp -v sim_db_channel.o ../obj/
+ @echo build complete
+
+../../common/lib/nrtb_common.a:
+ @cd ../../commmon; make
+
+sim_db_channel_test: sim_db_channel.o sim_db_channel_test.cpp ../../common/lib/nrtb_common.a
+ @rm -f sim_db_channel_test
+ g++ -c sim_db_channel_test.cpp -I ../include
+ g++ -o sim_db_channel_test sim_db_channel_test.o sim_db_channel.o -L ../../common/lib/
+ nrtb_common.a nrtb_gpb.a -lpthread
+
+
+sim_db_channel.o: sim_db_channel.cpp sim_db_channel.h Makefile
+ @rm -f sim_db_channel.o
+ g++ -c -O3 sim_db_channel.cpp -I ../../common/include
+
+clean:
+ @rm -vf *.o ../include/sim_db_channel.h sim_db_channel_test
+ @echo all objects and executables have been erased.
+
=== added file 'sim_engine/comm_manager/manager/sim_db_channel.cpp'
--- sim_engine/comm_manager/manager/sim_db_channel.cpp 1970-01-01 00:00:00 +0000
+++ sim_engine/comm_manager/manager/sim_db_channel.cpp 2011-12-29 11:10:29 +0000
@@ -0,0 +1,196 @@
+cd /***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+
+#include "sim_db_channel.h"
+#include <confreader.h>
+
+using string;
+
+namespace nrtb
+{
+
+void sim_db_channel::return_to_base_state()
+{
+ // shutdown the queues and threads, if any.
+ if (in_queue) in_queue->shutdown();
+ if (out_queue) out_queue->shutdown();
+ if (input_manager)
+ {
+ input_manager->join();
+ input_manager.reset();
+ };
+ if (output_manager)
+ {
+ output_manager->join();
+ output_manager.reset();
+ };
+ // release the buffers
+ out_queue.reset();
+ in_queue.reset();
+ // close and deallocate the transceiver
+ link.reset();
+};
+
+sim_db_channel::sim_db_channel()
+{
+ // get the global_conf_reader
+ global_conf_reader & conf = global_conf_reader::get_instance();
+ // get the values for our run.
+ in_queue_limit = conf.get<int>("sim_db_channel.in_buff", 50);
+ out_queue_limit = conf.get<int>("sim_db_channel.out_buff", 50);
+};
+
+sim_db_channel::~sim_db_channel()
+{
+ try { return_to_base_state(); }
+ catch (...) {};
+};
+
+void sim_db_channel::establish_link(std::string address)
+{
+ // determine which address we should use.
+ if (address == "na")
+ {
+ // get the global_conf_reader
+ global_conf_reader & conf = global_conf_reader::get_instance();
+ address = conf.get<std::string>("sim_db_channel.remote_addr",
+ "127.0.0.1:63456");
+ };
+ // See if we need to add the port to the address.
+ if (address.find(":") == std::string::npos)
+ {
+ address = address.append(":63456");
+ };
+ // okay.. at this point we should have the valid
+ // address to start the transceiver with.
+ string breadcrumbs = "init ";
+ try
+ {
+ in_queue.reset(new msg_buff(in_queue_limit));
+ breadcrumbs.append("in_queue ");
+ out_queue.reset(new msg_buff(out_queue_limit));
+ breadcrumbs.append("out_queue ");
+ tcp_socket_p sock(new tcp_socket);
+ link.reset(new io_t(sock));
+ breadcrumbs.append("link ");
+ output_manager.reset(new out_processor(out_queue, link));
+ breadcrumbs.append("output_manager ");
+ input_manager.reset(new in_processor(in_queue, link));
+ breadcrumbs.append("input_manager ");
+ sock->connect(address);
+ breadcrumbs.append("connected ");
+ output_manager->start();
+ breadcrumbs.append("out_started ");
+ input_manager->start();
+ breadcrumbs.append("in_started ");
+ }
+ catch (...)
+ {
+ // roll back the startup attempt
+ return_to_base_state();
+ // whine and complain.
+ cant_connect_exception e;
+ e.store(breadcrumbs);
+ throw e;
+ };
+};
+
+void sim_db_channel::sim_start(sim_db_channel::sim_info data)
+{
+ // send the sim setup information
+ msg_p msg(new nrtb_msg::sim_setup_data());
+ msg->set_name(data.name);
+ msg->set_model(data.model);
+ msg->set_quanta_ms(data.quanta_ms);
+ msg->set_max_quantas(data.max_quantas);
+ msg->set_started_by(data.started_by);
+ // assemble the new objects
+ obj_setup_list::iterator c = data.items.begin();
+ obj_setup_list::iterator e = data.items.end();
+ while (c != e)
+ {
+ // get a new obj_setup_data.
+ nrtb_msg::obj_setup_data * item;
+ item = msg->add_item();
+ // map the data..
+ item->set_uid(c->uid);
+ item->set_name(c->name);
+ item->set_obj_type(c->obj_type);
+ //TODO: More to do here.
+ nrtb_msg::location_data * loc = item->mutable_location();
+
+ }
+ // message is done, send it.
+ out_queue->push(msg);
+
+
+};
+
+sim_db_channel::in_processor::in_processor(
+ sim_db_channel::msg_buff_p buf, io_p io)
+{
+
+};
+
+sim_db_channel::in_processor::run()
+{
+
+};
+
+sim_db_channel::out_processor::out_processor(
+ sim_db_channel::msg_buff_p buf, io_p io)
+{
+
+};
+
+sim_db_channel::out_processor::run()
+{
+
+};
+
+
+} // namespace nrtb
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
=== added file 'sim_engine/comm_manager/manager/sim_db_channel.h'
--- sim_engine/comm_manager/manager/sim_db_channel.h 1970-01-01 00:00:00 +0000
+++ sim_engine/comm_manager/manager/sim_db_channel.h 2011-12-29 11:10:29 +0000
@@ -0,0 +1,197 @@
+/***********************************************
+ This file is part of the NRTB project (https://launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#ifndef sim_db_channel_header
+#define sim_db_channel_header
+
+#include <common.h>
+#include <base_thread.h>
+#include <circular_queue.h>
+#include <transceiver.h>
+#include <triad.h>
+#include <sim_to_db_wrapper.pb.h>
+#include <boost/shared_ptr.hpp>
+
+namespace nrtb
+{
+
+class sim_db_channel
+{
+public:
+
+ // -- typedefs to be used by callers
+ typedef triad<long double> triplet;
+ // individual object setup info
+ struct obj_setup_info
+ {
+ uint32_t uid;
+ std::string name;
+ uint32_t obj_type;
+ triplet location;
+ triplet attitude;
+ triplet velocity;
+ triplet rotation;
+ };
+ // typedef a list of obj_setup_infos
+ typedef std::list<obj_setup_info> obj_setup_list;
+ // overall simulation info
+ struct sim_info
+ {
+ uint32_t uid;
+ std::string name;
+ uint32_t quanta_ms:
+ uint32_t max_quantas;
+ std::string started_by;
+ obj_setup_list items;
+ };
+ // obj per instant status info
+ struct tq_obj_data
+ {
+ uint32 uid;
+ triplet location;
+ triplet attitude;
+ triplet velocity;
+ triplet rotation;
+ strlist in_msgs;
+ strlist out_msgs;
+ strlist notes;
+ };
+ typedef std::list<tq_obj_data> tq_obj_updates;
+ // time quanta update record
+ struct tq_update
+ {
+ uint32 uid;
+ uint32 quanta_index;
+ uint32 actual_ms;
+ uint32 cook_ms;
+ tq_obj_updates updates;
+ obj_setup_list new_items;
+ };
+
+ /***************************************************
+ in alpha phase, all exceptions will force the channel
+ back to it's initial state, closing any connection
+ which may be active at the time.
+ ***************************************************/
+
+ // general parent for all class exceptions
+ class general_exception: public base_exception {};
+ class cant_connect_exception: public general_exception {};
+ class unrecoverable_com_error: public general_exception {};
+ class local_invalid_context: public general_exception {};
+ class remote_invalid_context: public general_exception {};
+ class in_buffer_overflow: public general_exception {};
+ class out_buffer_overflow: public general_exception {};
+
+ // Note: the constructor expects to find all needed
+ // parameters in a nrtb::global_conf_reader object.
+ sim_db_channel();
+ // this will attempt to gracefuly close the connection
+ virtual ~sim_db_channel();
+
+ /*************************************************
+ Called to open the connection and do any
+ link negociation which may be required.
+ If address is provided it will be used, otherwise
+ the global_conf_reader will be queried for one.
+ if none is available, this class will throw.
+ **************************************************/
+ void establish_link(std::string address = "na");
+
+ /*****************************************************
+ Called to notify the databroker that a new simulation
+ is starting.
+ Must be called after establish_link() and only once
+ at the beginning of each simulation or an
+ local_invalid_context exception will be thrown.
+ Any throws will cause the connection to be closed
+ and the channel returned to its initial state.
+ *****************************************************/
+ void sim_start(sim_info data);
+
+ /************************************************
+ * this is called to send the results of a
+ * single time quanta's updates the the databroker.
+ *
+ * This will throw if not called after establish_link
+ * and sim_start and before sim_end. In that case
+ * the channel will be returne to it's initial
+ * state
+ ************************************************/
+ void sim_update(tq_update data);
+
+ /************************************************
+ * Called ot notify the databroker of the end of
+ * a simulation run.
+ * failed: true if the sim errored out.
+ * reason: a human readable cause
+ *
+ * This will throw if not called after establish_link
+ * and sim_start and before sim_end. In that case
+ * the channel will be returne to it's initial
+ * state
+ ************************************************/
+ void sim_end(bool failed, std::string reason);
+
+ /*************************************************
+ * Call this to notify the databroker that we are
+ * closing the connection and then actually close
+ * it.
+ *
+ * This will throw if a simulation is in progress.
+ * Either way, the channel will be returned to
+ * its initial state.
+ *************************************************/
+ void end_link();
+
+
+protected:
+ typedef boost::shared_ptr<thread> thread_p;
+ typedef nrtb_msg::sim_to_db_wrapper msg_t;
+ typedef transceiver<msg_t, msg_t> io_t;
+ typedef boost::shared_ptr<io_t> io_p;
+ typedef boost::shared_ptr<msg_t> msg_p;
+ typedef circular_queue<msg_p> msg_buff;
+ typedef boost::shared_ptr<msg_buff> msg_buff_p;
+ thread_p input_manager;
+ thread_p output_manager;
+ io_p link;
+ msg_buff_p out_queue;
+ msg_buff_p in_queue;
+ unsigned int in_queue_limit, out_queue_limit;
+ // the other methods call this in case of error.
+ void return_to_base_state();
+ class in_processor: thread
+ {
+ in_processor(msg_buff_p buf, io_p io);
+ virtual ~in_processor() {};
+ run();
+ };
+
+ class out_processor: thread
+ {
+ out_processor(msg_buff_p buf, io_p io);
+ virtual ~out_processor() {};
+ run();
+ };
+
+};
+
+} // namepace nrtb
+
+#endif // sim_db_channel_header
=== added directory 'sim_engine/comm_manager/out_processor'
=== added directory 'sim_engine/obj'
=== renamed directory 'sim_engine/physics/point_mass' => 'sim_engine/physics/rigid_body'
=== added directory 'sim_engine/test'
=== added directory 'sim_engine/test/fake_simengine'
Follow ups