Example #1
0
        public override void Write(ulong[] memorypos, MultiDimArray buffer, ulong[] bufferpos, ulong[] count)
        {
            RRMultiDimArrayUntyped dat2      = null;
            RRBaseArray            dat2Dims  = null;
            RRBaseArray            dat2Array = null;

            try
            {
                int elemcount = 1;
                foreach (ulong v in count)
                {
                    elemcount *= (int)v;
                }
                uint[] count2 = count.Select(x => (uint)x).ToArray();
                T[]    array  = new T[elemcount];


                MultiDimArray writedat1 = new MultiDimArray(count2, array);
                writedat1.AssignSubArray(new uint[count.Length], buffer, bufferpos.Select(x => (uint)x).ToArray(), count.Select(x => (uint)x).ToArray());

                dat2       = new RRMultiDimArrayUntyped();
                dat2Dims   = MessageElementDataUtil.ArrayToRRBaseArray(count2);
                dat2.Dims  = dat2Dims;
                dat2Array  = MessageElementDataUtil.ArrayToRRBaseArray(array);
                dat2.Array = dat2Array;

                vector_uint64_t memorypos3 = new vector_uint64_t();
                foreach (ulong val in memorypos)
                {
                    memorypos3.Add(val);
                }
                vector_uint64_t count3 = new vector_uint64_t();
                foreach (ulong val in count)
                {
                    count3.Add(val);
                }
                vector_uint64_t bufferpos3 = new vector_uint64_t();
                for (int i = 0; i < count.Length; i++)
                {
                    bufferpos3.Add(0);
                }
                WrappedMultiDimArrayMemoryClientUtil.Write(innermem, memorypos3, dat2, bufferpos3, count3);
            }
            finally
            {
                if (dat2 != null)
                {
                    if (dat2Dims != null)
                    {
                        dat2Dims.Dispose();
                    }
                    if (dat2Array != null)
                    {
                        dat2Array.Dispose();
                    }
                    dat2.Dispose();
                }
            }
        }
Example #2
0
 public override void Write(ulong[] memorypos, PodMultiDimArray buffer, ulong[] bufferpos, ulong[] count)
 {
     using (bufferdirector buffer1 = new bufferdirector(buffer))
         using (vector_uint64_t memorypos1 = new vector_uint64_t(memorypos))
             using (vector_uint64_t bufferpos1 = new vector_uint64_t(bufferpos))
                 using (vector_uint64_t count1 = new vector_uint64_t(count))
                 {
                     innerclient.Write(memorypos1, buffer1, bufferpos1, count1);
                 }
 }
Example #3
0
 public override MessageElementNestedElementList PackWriteRequest(vector_uint64_t bufferpos, vector_uint64_t count)
 {
     using (bufferpos)
         using (count)
         {
             PodMultiDimArray o = new PodMultiDimArray(count.Select(x => (uint)x).ToArray(), new T[count.Aggregate(1, (x, y) => (int)x * (int)y)]);
             buffer.RetrieveSubArray(bufferpos.Select(x => (uint)x).ToArray(), o, new uint[buffer.Dims.Length], count.Select(x => (uint)x).ToArray());
             return(RobotRaconteurNode.s.PackPodMultiDimArray <T>(o));
         }
 }
Example #4
0
 public override void UnpackReadResult(MessageElementNestedElementList res, vector_uint64_t bufferpos,
                                       vector_uint64_t count)
 {
     using (res) using (bufferpos) using (count)
             {
                 PodMultiDimArray res1 = RobotRaconteurNode.s.UnpackPodMultiDimArrayDispose <T>(res);
                 buffer.AssignSubArray(bufferpos.Select(x => (uint)x).ToArray(), res1, new uint[buffer.Dims.Length],
                                       count.Select(x => (uint)x).ToArray());
             }
 }
Example #5
0
        public override void Read(ulong[] memorypos, MultiDimArray buffer, ulong[] bufferpos, ulong[] count)
        {
            RRMultiDimArrayUntyped dat      = null;
            RRBaseArray            datDims  = null;
            RRBaseArray            datArray = null;

            try
            {
                vector_uint64_t memorypos2 = new vector_uint64_t();
                foreach (ulong val in memorypos)
                {
                    memorypos2.Add(val);
                }
                vector_uint64_t count2 = new vector_uint64_t();
                foreach (ulong val in count)
                {
                    count2.Add(val);
                }

                dat = WrappedMultiDimArrayMemoryClientUtil.Read(innermem, memorypos2, count2);

                datDims  = dat.Dims;
                datArray = dat.Array;
                uint[] dims  = (uint[])MessageElementDataUtil.RRBaseArrayToArray(datDims);
                T[]    array = (T[])MessageElementDataUtil.RRBaseArrayToArray(datArray);

                MultiDimArray dat2 = new MultiDimArray(dims, array);
                buffer.AssignSubArray(bufferpos.Select(x => (uint)x).ToArray(), dat2, new uint[count.Length],
                                      count.Select(x => (uint)x).ToArray());
            }
            finally
            {
                if (dat != null)
                {
                    if (datDims != null)
                    {
                        datDims.Dispose();
                    }
                    if (datArray != null)
                    {
                        datArray.Dispose();
                    }
                    dat.Dispose();
                }
            }
        }
Example #6
0
 public override void Write(vector_uint64_t memorypos, MessageElementNestedElementList buffer,
                            vector_uint64_t bufferpos, vector_uint64_t count)
 {
     try
     {
         using (buffer) using (memorypos) using (bufferpos) using (count)
                     {
                         PodMultiDimArray buffer2 = RobotRaconteurNode.s.UnpackPodMultiDimArray <T>(buffer);
                         mem.Write(memorypos.ToArray(), buffer2, bufferpos.ToArray(), count.ToArray());
                     }
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
         }
     }
 }
Example #7
0
 public override vector_uint64_t Dimensions()
 {
     try
     {
         vector_uint64_t o = new vector_uint64_t();
         foreach (ulong i in mem.Dimensions)
         {
             o.Add(i);
         }
         return(o);
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
             return(new vector_uint64_t());
         }
     }
 }
Example #8
0
 public override MessageElementNestedElementList Read(vector_uint64_t memorypos, vector_uint64_t bufferpos, vector_uint64_t count)
 {
     try
     {
         using (memorypos)
             using (bufferpos)
                 using (count)
                 {
                     PodMultiDimArray buffer3 = new PodMultiDimArray(count.Select(x => (uint)x).ToArray(), new T[count.Aggregate(1, (x, y) => (int)x * (int)y)]);
                     mem.Read(memorypos.ToArray(), buffer3, new ulong[count.Count], count.ToArray());
                     return(RobotRaconteurNode.s.PackPodMultiDimArray <T>(buffer3));
                 }
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
         }
         return(null);
     }
 }