Exemplo n.º 1
0
        /// <summary>
        /// エコーデータの読み込み
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="payload"></param>
        /// <param name="payload_len"></param>
        private static void ReadEcho(MrsConnection connection, IntPtr payload, UInt32 payload_len)
        {
            mrs.Time read_tm = new mrs.Time();
            read_tm.Set();

            byte[] read_data = new byte[payload_len];
            Marshal.Copy(payload, read_data, 0, (int)payload_len);

            mrs.Buffer buffer = new mrs.Buffer();
            buffer.Write(read_data);
            while (buffer.GetDataLen() > 0)
            {
                mrs.Time write_tm = buffer.ReadTime();
                MRS_LOG_DEBUG("ReadEcho data={0} data_len={1} diff_time={2}({3} - {4})",
                              ToString(buffer.GetData()), m_nWriteDataLen, (read_tm - write_tm).ToString(), read_tm.ToString(), write_tm.ToString());
                if (!buffer.Read(null, m_nWriteDataLen))
                {
                    MRS_LOG_ERR("Lost data. len={0} {1}", buffer.GetDataLen(), mrs.Utility.ToHex(buffer.GetData(), buffer.GetDataLen()));
                    m_bLoop = false;
                    break;
                }

                ++m_nReadCount;
                if (m_nWriteCount * m_nConnections <= m_nReadCount)
                {
                    MRS_LOG_DEBUG("Since all records have been received, it is finished.");
                    m_bLoop = false;
                }
            }
        }
Exemplo n.º 2
0
        public virtual void Set(mrs.Time time)
        {
            System.DateTime local_time = mrs.Time.UnixEpoch.AddSeconds(time.GetSec()).ToLocalTime();

            m_Year  = (UInt16)local_time.Year;
            m_Month = (byte)local_time.Month;
            m_Date  = (byte)local_time.Day;
            m_Hour  = (byte)local_time.Hour;
            m_Min   = (byte)local_time.Minute;
            m_Sec   = (byte)local_time.Second;
            m_Usec  = (UInt32)time.GetUsec();
        }
Exemplo n.º 3
0
        /// <summary>
        /// エコーデータの書き込み
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="data"></param>
        private static void WriteEcho(MrsConnection connection, byte[] data, uint data_len)
        {
            mrs.Time write_tm = new mrs.Time();
            write_tm.Set();
            mrs.Buffer buffer = new mrs.Buffer();
            buffer.WriteTime(write_tm);
            buffer.Write(data, data_len);

            if (m_canValidRecord)
            {
                mrs_write_record(connection, m_nRecordOptions, 0x01, buffer.GetData(), buffer.GetDataLen());
            }
            else
            {
                mrs_write(connection, buffer.GetData(), buffer.GetDataLen());
            }
        }
Exemplo n.º 4
0
 public static mrs.Time Now()
 {
     mrs.Time time = new mrs.Time();
     time.Set();
     return(time);
 }
Exemplo n.º 5
0
 public virtual bool WriteTime(mrs.Time time)
 {
     return(WriteTime(time.GetSec(), time.GetUsec()));
 }
Exemplo n.º 6
0
 public virtual void Set()
 {
     mrs.Time time = new mrs.Time();
     time.Set();
     Set(time);
 }