示例#1
0
文件: OYOPatrol.cs 项目: boyism80/oyo
 public static PatrolElement[] Read(string filename)
 {
     try
     {
         var fstream = File.Open(filename, FileMode.Open);
         var list    = null as PatrolElement[];
         using (var reader = new BinaryReader(fstream))
         {
             var count = reader.ReadInt32();
             list = new PatrolElement[count];
             for (var i = 0; i < count; i++)
             {
                 var elapsed_time = reader.ReadInt32();
                 var Pcmd         = new Pcmd(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
                 list[i] = new PatrolElement(elapsed_time, Pcmd);
             }
         }
         fstream.Close();
         return(list);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
示例#2
0
文件: OYOPatrol.cs 项目: boyism80/oyo
        public bool Write(Pcmd Pcmd)
        {
            if (this.IsEnabled() == false)
            {
                return(false);
            }

            if (this._last_Pcmd != null && this._last_Pcmd.Equals(Pcmd))
            {
                return(false);
            }

            if (this._last_Pcmd != null)
            {
                this._stopwatch.Stop();
                var element = new PatrolElement((int)this._stopwatch.ElapsedMilliseconds, this._last_Pcmd);

                this.PatrolElementQueue.Enqueue(element);
            }

            this._last_Pcmd = new Pcmd(Pcmd);
            this._stopwatch.Reset();
            this._stopwatch.Start();
            return(true);
        }