Exemplo n.º 1
0
        public override void Write(WrappedMultiDimArrayMemoryParams p)
        {
            RRMultiDimArrayUntyped pbuffer      = null;
            RRBaseArray            pbufferDims  = null;
            RRBaseArray            pbufferArray = null;

            try
            {
                ulong[] count     = p.count.ToArray();
                ulong[] bufferpos = p.bufferpos.ToArray();
                ulong[] memorypos = p.memorypos.ToArray();

                ulong elemcount = 1;
                foreach (ulong e in count)
                {
                    elemcount *= e;
                }

                pbuffer      = p.buffer;
                pbufferDims  = pbuffer.Dims;
                pbufferArray = pbuffer.Array;

                int[] dims  = (int[])MessageElementDataUtil.RRBaseArrayToArray(pbufferDims);
                T[]   array = (T[])MessageElementDataUtil.RRBaseArrayToArray(pbufferArray);

                MultiDimArray m = new MultiDimArray(count.Select(x => (uint)x).ToArray(), array);

                mem.Write(memorypos, m, bufferpos, count);
            }
            catch (Exception e)
            {
                using (MessageEntry merr = new MessageEntry())
                {
                    RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
                    RRDirectorExceptionHelper.SetError(merr, e.ToString());
                }
            }
            finally
            {
                if (p != null && pbuffer != null)
                {
                    if (pbufferDims != null)
                    {
                        pbufferDims.Dispose();
                    }
                    if (pbufferArray != null)
                    {
                        pbufferArray.Dispose();
                    }
                }
                if (p != null)
                {
                    p.Dispose();
                }
            }
        }
Exemplo n.º 2
0
        private object GetData()
        {
            using (MessageElementData val = _GetData())
            {
                if (val == null)
                {
                    return(null);
                }
                object a = null;
                a = MessageElementDataUtil.ToRRBaseArray(val);
                if (a != null)
                {
                    if (DataTypeUtil.IsNumber(val.GetTypeID()))
                    {
                        RRBaseArray ra = (RRBaseArray)a;
                        try
                        {
                            return(MessageElementDataUtil.RRBaseArrayToArray(ra));
                        }
                        finally
                        {
                            ra.Dispose();
                        }
                    }
                    if (val.GetTypeID() == DataTypes.string_t)
                    {
                        RRBaseArray ra = (RRBaseArray)a;
                        try
                        {
                            return(MessageElementDataUtil.RRBaseArrayToString(ra));
                        }
                        finally
                        {
                            ra.Dispose();
                        }
                    }
                    IDisposable ad = a as IDisposable;
                    if (ad != null)
                    {
                        ad.Dispose();
                    }
                    throw new DataTypeException("Unknown RRArray type");
                }
                a = MessageElementDataUtil.ToMessageElementNestedElementList(val);
                if (a != null)
                {
                    return(a);
                }
                throw new ApplicationException("Unknown data type");
            }

            throw new ApplicationException("Unknown data type");
        }
Exemplo n.º 3
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();
                }
            }
        }
Exemplo n.º 4
0
        public override void Read(ulong memorypos, T[] buffer, ulong bufferpos, ulong count)
        {
            RRBaseArray dat = null;

            try
            {
                dat = WrappedArrayMemoryClientUtil.Read(innerarray, memorypos, count);
                T[] dat2 = (T[])MessageElementDataUtil.RRBaseArrayToArray(dat);
                Array.Copy(dat2, 0, buffer, (long)bufferpos, (long)count);
            }
            finally
            {
                if (dat != null)
                {
                    dat.Dispose();
                }
            }
        }
Exemplo n.º 5
0
 public override void Write(ulong memorypos, RRBaseArray buffer, ulong bufferpos, ulong count)
 {
     try
     {
         using (buffer)
         {
             T[] buffer2 = (T[])MessageElementDataUtil.RRBaseArrayToArray(buffer);
             mem.Write(memorypos, buffer2, bufferpos, count);
         }
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
         }
     }
 }