Esempio n. 1
0
 public void addToWorking(datapoint d)
 {
     if (state == MemoryRecordingState.recording)
     {
         if (working != null)
         {
             working.data.Add(d);
         }
     }
 }
Esempio n. 2
0
 public void receive(string message)
 {
     mostRecent = datapoint.Deserialize(Convert.FromBase64String(message.Trim('\n')), 0);
     robot.memory.addToWorking(mostRecent);
     if (robot.memory.state != MemoryManager.MemoryRecordingState.playback)
     {
         robot.updateDisplay(mostRecent);
     }
     updateTimer();
     waitingForResponse = false;
 }
Esempio n. 3
0
        public static byte[] Serialize(datapoint item)
        {
            int    rawSize = Marshal.SizeOf(typeof(datapoint));
            IntPtr buffer  = Marshal.AllocHGlobal(rawSize);

            Marshal.StructureToPtr(item, buffer, false);
            byte[] rawData = new byte[rawSize];
            Marshal.Copy(buffer, rawData, 0, rawSize);
            Marshal.FreeHGlobal(buffer);
            return(rawData);
        }
Esempio n. 4
0
        public static datapoint Deserialize(byte[] rawData, int position)
        {
            int rawsize = Marshal.SizeOf(typeof(datapoint));

            if (rawsize > rawData.Length)
            {
                return(default(datapoint));
            }

            IntPtr buffer = Marshal.AllocHGlobal(rawsize);

            Marshal.Copy(rawData, position, buffer, rawsize);
            datapoint obj = (datapoint)Marshal.PtrToStructure(buffer, typeof(datapoint));

            Marshal.FreeHGlobal(buffer);
            return(obj);
        }