Converted queue compiler to use time_point

Change-Id: I7f72d4bcdd801c6d19342f072276901f15380db9
diff --git a/aos/build/queues/objects/queue.rb b/aos/build/queues/objects/queue.rb
index 81cd181..7841411 100644
--- a/aos/build/queues/objects/queue.rb
+++ b/aos/build/queues/objects/queue.rb
@@ -3,7 +3,7 @@
 	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'
+    @type = '::aos::monotonic_clock::time_point' if @type == 'Time'
 		@name = name
 		@length = length
 	end
@@ -50,7 +50,7 @@
                        "int16_t" => "%\" PRId16 \"",
                        "int32_t" => "%\" PRId32 \"",
                        "int64_t" => "%\" PRId64 \"",
-                       "::aos::time::Time" => "\" AOS_TIME_FORMAT \""}
+                       "::aos::monotonic_clock::time_point" => "\" AOS_TIME_FORMAT \""}
         def toPrintFormat()
 		if(format = PrintFormat[@type])
 			return format;
@@ -62,12 +62,12 @@
 ERROR_MSG
 	end
 
-	Sizes = {"bool" => 1, "float" => 4,"double" => 8,"::aos::time::Time" => 8}
+	Sizes = {"bool" => 1, "float" => 4,"double" => 8,"::aos::monotonic_clock::time_point" => 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","::aos::time::Time" => "::aos::time::Time(0, 0)"}
+	Zero = {"float" => "0.0f","double" => "0.0","bool" => "false","::aos::monotonic_clock::time_point" => "::aos::monotonic_clock::epoch()"}
 	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 5b4e136..20a0c9d 100644
--- a/aos/build/queues/output/message_dec.rb
+++ b/aos/build/queues/output/message_dec.rb
@@ -331,8 +331,14 @@
     end
     if (@type == 'bool')
       args.push("#{parent}#{this_name} ? 'T' : 'f'")
-    elsif (@type == '::aos::time::Time')
-      args.push("AOS_TIME_ARGS(#{parent}#{this_name}.sec(), #{parent}#{this_name}.nsec())")
+    elsif (@type == '::aos::monotonic_clock::time_point')
+      args.push(["AOS_TIME_ARGS(static_cast<int32_t>(",
+                 "::std::chrono::duration_cast<::std::chrono::seconds>(",
+                 "#{parent}#{this_name}.time_since_epoch()).count()), ",
+                 "static_cast<int32_t>(::std::chrono::duration_cast<::std::chrono::nanoseconds>(",
+                 "#{parent}#{this_name}.time_since_epoch() - ",
+                 "::std::chrono::duration_cast<::std::chrono::seconds>(",
+                 "#{parent}#{this_name}.time_since_epoch())).count()))"].join(''))
     else
       args.push("#{parent}#{this_name}")
     end
diff --git a/aos/build/queues/print_field.rb b/aos/build/queues/print_field.rb
index 5eb3712..0e27bf0 100644
--- a/aos/build/queues/print_field.rb
+++ b/aos/build/queues/print_field.rb
@@ -1,7 +1,7 @@
 require_relative 'load.rb'
 
 # TODO(brians): Special-case Time too and float/double if we can find a good way to do it.
-GenericTypeNames = ['float', 'double', 'char', '::aos::time::Time']
+GenericTypeNames = ['float', 'double', 'char', '::aos::monotonic_clock::time_point']
 IntegerSizes = [8, 16, 32, 64]
 
 WriteIffChanged.open(ARGV[0]) do |output|
diff --git a/aos/build/queues/queue_primitives.rb b/aos/build/queues/queue_primitives.rb
index 801e606..45687ea 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', '::aos::time::Time']
+end.flatten + ['bool', 'float', 'char', 'double', '::aos::monotonic_clock::time_point']
 
 FileUtils.mkdir_p(File.dirname(ARGV[0]))
 WriteIffChanged.open(ARGV[0]) do |output|
@@ -22,7 +22,7 @@
   message_element = Target::MessageElement.new(name, 'value')
   statement = MessageElementStmt.new(name, 'value')
   message_element.size = statement.size
-  name = 'Time' if name == '::aos::time::Time'
+  name = 'Time' if name == '::aos::monotonic_clock::time_point'
   next <<END2
   static const uint32_t #{name}_p = #{message_element.getTypeID()};
 END2