Esempio n. 1
0
        public Net2Time get()
        {
            Net2Time time = new Net2Time();

            //double diff = stop_watch.Elapsed.TotalMilliseconds;
            //result = (long)(diff) + time_offset;

            TimeSpan timeSpan = DateTime.Now.ToUniversalTime() - UNIX_EPOCH;
            double   msecs    = timeSpan.TotalMilliseconds;

            time.sec  = (uint)(msecs / 1000);
            time.nsec = (uint)((msecs / 1000 - time.sec) * 1e+9);

            return(time);
        }
Esempio n. 2
0
            protected Message createMessage(byte[] buffer, uint priority = 0)
            {
                Message msg = new Message();

                msg.header = new Header();

                msg.header.sequence = req_sequence++;

                if (delegateGetTime != null)
                {
                    Net2Time mtime = delegateGetTime();
                    msg.header.time_span_s  = mtime.sec;
                    msg.header.time_span_ns = mtime.nsec;
                }

                msg.header.source_channel_name = Name;
                msg.header.priority            = priority;
                msg.payload = buffer;

                return(msg);
            }
Esempio n. 3
0
            protected override void reportData(Message packet)
            {
                byte[] result = GetResponse(packet.header.sequence, packet.payload, packet.header.priority, Id);

                if (result != null)
                {
                    Message ack_message = new Message();
                    ack_message.header = new Header();

                    ack_message.payload             = result;
                    ack_message.header.sequence     = packet.header.sequence;
                    ack_message.header.mode         = Header.Mode.ACK;
                    ack_message.header.message_type = Header.Type.ROUTER;

                    Net2Time mtime = GetTime();
                    ack_message.header.time_span_s  = mtime.sec;
                    ack_message.header.time_span_ns = mtime.nsec;

                    ack_message.header.zmq_router_address = packet.header.zmq_router_address;

                    addToSendQueue(ack_message);
                }
            }