added and used Time support for Queue messages
diff --git a/aos/build/queues/objects/queue.rb b/aos/build/queues/objects/queue.rb
index 1199cc2..b40ccb2 100644
--- a/aos/build/queues/objects/queue.rb
+++ b/aos/build/queues/objects/queue.rb
@@ -3,10 +3,11 @@
def initialize(type_name,name,length = nil) #lengths are for arrays
@type_name = type_name
@type = type_name.to_s
+ @type = '::aos::time::Time' if @type == 'Time'
@name = name
@length = length
end
- CommonMistakes = {"short" => "int16_t","int" => "int32_t","long" => "int64_t"}
+ CommonMistakes = {"short" => "int16_t","int" => "int32_t","long" => "int64_t","time" => "Time"}
def check_type_error(locals)
if(!(Sizes[@type] || (@length != nil && @type == "char")) )
if(correction = CommonMistakes[@type])
@@ -48,7 +49,8 @@
"int8_t" => "%\" PRId8 \"",
"int16_t" => "%\" PRId16 \"",
"int32_t" => "%\" PRId32 \"",
- "int64_t" => "%\" PRId64 \""}
+ "int64_t" => "%\" PRId64 \"",
+ "::aos::time::Time" => "%010\" PRId32 \".%05\" PRId32 \"s"}
def toPrintFormat()
if(format = PrintFormat[@type])
return format;
@@ -60,12 +62,12 @@
ERROR_MSG
end
- Sizes = {"bool" => 1, "float" => 4,"double" => 8}
+ Sizes = {"bool" => 1, "float" => 4,"double" => 8,"::aos::time::Time" => 8}
[8,16,32,64].each do |len|
Sizes["int#{len}_t"] = len / 8
Sizes["uint#{len}_t"] = len / 8
end
- Zero = {"float" => "0.0f","double" => "0.0","bool" => "false"}
+ Zero = {"float" => "0.0f","double" => "0.0","bool" => "false","::aos::time::Time" => "::aos::time::Time(0, 0)"}
def size()
if(size = Sizes[@type]); return size; end
return 1 if(@type == "char")
diff --git a/aos/build/queues/output/message_dec.rb b/aos/build/queues/output/message_dec.rb
index 59e2f35..a165359 100644
--- a/aos/build/queues/output/message_dec.rb
+++ b/aos/build/queues/output/message_dec.rb
@@ -301,6 +301,8 @@
def fetchPrintArgs(args, parent = "")
if (self.type == 'bool')
args.push("#{parent}#{self.name} ? 'T' : 'f'")
+ elsif (self.type == '::aos::time::Time')
+ args.push("#{parent}#{self.name}.sec(), #{parent}#{self.name}.nsec()")
else
args.push("#{parent}#{self.name}")
end
diff --git a/aos/build/queues/print_field.rb b/aos/build/queues/print_field.rb
index a86140f..84cf1f4 100644
--- a/aos/build/queues/print_field.rb
+++ b/aos/build/queues/print_field.rb
@@ -2,7 +2,7 @@
TypeNames = [8, 16, 32, 64].collect do |size|
["uint#{size}_t", "int#{size}_t"]
-end.flatten + ['bool', 'float', 'char', 'double']
+end.flatten + ['bool', 'float', 'char', 'double', '::aos::time::Time']
WriteIffChanged.open(ARGV[0]) do |output|
output.puts <<END
@@ -15,6 +15,7 @@
#include <stdio.h>
#include "aos/common/byteorder.h"
+#include "aos/common/time.h"
namespace aos {
diff --git a/aos/build/queues/queue_primitives.rb b/aos/build/queues/queue_primitives.rb
index 2c9594e..421c3b4 100644
--- a/aos/build/queues/queue_primitives.rb
+++ b/aos/build/queues/queue_primitives.rb
@@ -4,7 +4,7 @@
TypeNames = [8, 16, 32, 64].collect do |size|
["uint#{size}_t", "int#{size}_t"]
-end.flatten + ['bool', 'float', 'char', 'double']
+end.flatten + ['bool', 'float', 'char', 'double', '::aos::time::Time']
FileUtils.mkdir_p(File.dirname(ARGV[0]))
WriteIffChanged.open(ARGV[0]) do |output|
@@ -14,12 +14,15 @@
#include <stdint.h>
+#include "aos/common/time.h"
+
namespace aos {
namespace queue_primitive_types {
#{TypeNames.collect do |name|
message_element = Target::MessageElement.new(name, 'value')
statement = MessageElementStmt.new(name, 'value')
message_element.size = statement.size
+ name = 'Time' if name == '::aos::time::Time'
next <<END2
static const uint32_t #{name}_p = #{message_element.getTypeID()};
END2
@@ -40,7 +43,7 @@
message_element.size = statement.size
next <<END2
template<>
-class TypeID<#{name}> {
+class TypeID< #{name}> {
public:
static const uint32_t id = #{message_element.getTypeID()};
};
diff --git a/aos/common/common.gyp b/aos/common/common.gyp
index 8847d40..fdda3f7 100644
--- a/aos/common/common.gyp
+++ b/aos/common/common.gyp
@@ -57,6 +57,10 @@
'<(AOS)/linux_code/ipc_lib/ipc_lib.gyp:shared_mem',
'<(AOS)/linux_code/ipc_lib/ipc_lib.gyp:core_lib',
'mutex',
+ 'time',
+ ],
+ 'export_dependent_settings': [
+ 'time',
],
'actions': [
{
diff --git a/aos/common/time.h b/aos/common/time.h
index c646661..ca1d207 100644
--- a/aos/common/time.h
+++ b/aos/common/time.h
@@ -47,7 +47,7 @@
static const int32_t kNSecInUSec = 1000;
static const int32_t kMSecInSec = 1000;
static const int32_t kUSecInSec = 1000000;
- constexpr Time(int32_t sec, int32_t nsec)
+ constexpr Time(int32_t sec = 0, int32_t nsec = 0)
: sec_(sec), nsec_(CheckConstexpr(nsec)) {
}
#ifndef SWIG
diff --git a/aos/prime/input/joystick_input.cc b/aos/prime/input/joystick_input.cc
index a2ba21b..c546e63 100644
--- a/aos/prime/input/joystick_input.cc
+++ b/aos/prime/input/joystick_input.cc
@@ -19,7 +19,7 @@
// feed all 0s to the joystick code.
// The RobotState messages will be marked as fake so anything that outputs
// values won't while this is enabled.
- static const bool kFakeJoysticks = false;
+ static const bool kFakeJoysticks = true;
NetworkRobotJoysticks joysticks;
char buffer[sizeof(joysticks) + ::buffers::kOverhead];