Exemplo n.º 1
0
 public void OnDataArrived(ICommunicationLayer layer, CommunicationData d)
 {
     foreach (var m in m_motorConnectors)
     {
         if (!m.Value.IsConnected())
         {
             continue;
         }
         foreach (var data in d.Data)
         {
             if (m.Value.GetSourceJoint() == data.name)
             {
                 _listeners.ForEach(p => p.OnDataReceived(this, d.TargetName, m.Value.GetTargetJoint(), data.values));
             }
         }
     }
 }
Exemplo n.º 2
0
        public static void WriteData(CommunicationData d, Stream s)
        {
            BinaryWriter w = new BinaryWriter(s);

            w.WriteStringNative(d.TargetName);
            w.Write(d.Data.Count);

            foreach (var v in d.Data)
            {
                w.WriteStringNative(v.name);
                w.Write(v.values.Count);
                foreach (var i in v.values)
                {
                    w.Write(i.KinValue);
                    w.Write(i.RealtimeValue);
                }
            }
        }
Exemplo n.º 3
0
        public static void ReadData(CommunicationData ret, Stream s)
        {
            BinaryReader r = new BinaryReader(s);

            ret.ClearData();
            ret.TargetName = r.ReadStringNative();
            int cnt = r.ReadInt32();

            for (int i = 0; i < cnt; ++i)
            {
                CommunicationData.DataPair d = new CommunicationData.DataPair();
                d.name = r.ReadStringNative();
                int v = r.ReadInt32();
                for (int j = 0; j < v; ++j)
                {
                    ControlInputValues cv = new ControlInputValues();
                    cv.KinValue      = r.ReadSingle();
                    cv.RealtimeValue = r.ReadSingle();
                    d.values.Add(cv);
                }
                ret.AddData(d.name, d.values.ToArray());
            }
        }