X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=dev4%2Fpsychlops%2Fcore%2Fdevice%2Fclock.cs;fp=dev4%2Fpsychlops%2Fcore%2Fdevice%2Fclock.cs;h=bc528212ac74d84a9ad37f41b29de62451fff053;hb=cb8916a7a5cd929f57b3f9edd99209680db90546;hp=0000000000000000000000000000000000000000;hpb=e05ab8e68d381f8f5c9a2ddb7c63b89a7bb6371a;p=psychlops%2Fsilverlight.git diff --git a/dev4/psychlops/core/device/clock.cs b/dev4/psychlops/core/device/clock.cs new file mode 100644 index 0000000..bc52821 --- /dev/null +++ b/dev4/psychlops/core/device/clock.cs @@ -0,0 +1,60 @@ +using System; + +namespace Psychlops +{ + + public struct Clock + { + long ticks; + // where ticks unit is 100 nano seconds. + + public void update() + { + ticks = DateTime.Now.Ticks; + } + public long at_msec() + { + return ticks/10000; + } + + public static Clock operator +(Clock lhs, Clock rhs) + { + return new Clock { ticks = lhs.ticks + rhs.ticks }; + } + public static Clock operator -(Clock lhs, Clock rhs) + { + return new Clock { ticks = lhs.ticks - rhs.ticks }; + } + + public static bool operator ==(Clock lhs, Clock rhs) + { + return lhs.ticks == rhs.ticks; + } + public static bool operator !=(Clock lhs, Clock rhs) + { + return lhs.ticks != rhs.ticks; + } + public static bool operator >(Clock lhs, Clock rhs) + { + return lhs.ticks > rhs.ticks; + } + public static bool operator <(Clock lhs, Clock rhs) + { + return lhs.ticks < rhs.ticks; + } + public static bool operator >=(Clock lhs, Clock rhs) + { + return lhs.ticks >= rhs.ticks; + } + public static bool operator <=(Clock lhs, Clock rhs) + { + return lhs.ticks <= rhs.ticks; + } + + public override string ToString() + { + return ticks.ToString(); + } + } + +}