Esempio n. 1
0
        public override void handler(MessageElement m, HandlerErrorInfo error)
        {
            // using (m)
            {
                try
                {
                    this.Dispose();

                    if (error.error_code != 0)
                    {
                        using (m) using (MessageEntry merr = new MessageEntry())
                            {
                                this.handler_task.SetException(RobotRaconteurExceptionUtil.ErrorInfoToException(error));
                                return;
                            }
                    }

                    this.handler_task.SetResult(m);
                }
                catch (Exception e)
                {
                    using (m) using (MessageEntry merr = new MessageEntry())
                        {
                            RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
                            RRDirectorExceptionHelper.SetError(merr, e.ToString());
                        }
                }
            }
        }
Esempio n. 2
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();
                }
            }
        }
Esempio n. 3
0
        public override void handler(WrappedServiceStub innerstub, HandlerErrorInfo error)
        {
            try
            {
                if (error.error_code != 0)
                {
                    using (MessageEntry merr = new MessageEntry())
                    {
                        this.handler_task.SetException(RobotRaconteurExceptionUtil.ErrorInfoToException(error));
                        return;
                    }
                }

                object s  = null;
                T      s1 = default(T);
                try
                {
                    int id = innerstub.GetObjectHeapID();
                    if (id != 0)
                    {
                        handler_task.SetResult((T)RRObjectHeap.GetObject(id));
                        return;
                    }

                    ServiceFactory f;
                    if (factory == null)
                    {
                        f = RobotRaconteurNode.s.GetServiceType(innerstub.RR_objecttype.GetServiceDefinition().Name);
                    }
                    else
                    {
                        f = factory;
                    }
                    s  = f.CreateStub(innerstub);
                    s1 = (T)s;
                }
                catch (Exception e)
                {
                    handler_task.SetException(e);
                    return;
                }

                handler_task.SetResult(s1);
            }
            catch (Exception e)
            {
                using (MessageEntry merr = new MessageEntry())
                {
                    RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
                    RRDirectorExceptionHelper.SetError(merr, e.ToString());
                }
            }
        }
Esempio n. 4
0
 public override void handler(TimerEvent ev, HandlerErrorInfo error)
 {
     try
     {
         handler_func(ev);
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
         }
     }
 }
Esempio n. 5
0
 public override void handler()
 {
     try
     {
         handler_task.SetResult(0);
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
         }
     }
 }
Esempio n. 6
0
 public override ulong DimCount()
 {
     try
     {
         return(mem.DimCount);
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
             return(0);
         }
     }
 }
Esempio n. 7
0
 public override vector_uint64_t Dimensions()
 {
     try
     {
         return(new vector_uint64_t(mem.Dimensions));
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
             return(new vector_uint64_t());
         }
     }
 }
Esempio n. 8
0
 public override void Close(WrappedServiceSkelAsyncAdapter async_adapter)
 {
     try
     {
         async_adapter.MakeAsync();
         generator.AsyncClose().ContinueWith(t => async_adapter.EndTask(t));
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
             return;
         }
     }
 }
Esempio n. 9
0
        public override MessageElementNestedElementList Read(ulong memorypos, ulong bufferpos, ulong count)
        {
            try
            {
                T[] buffer3 = new T[count];
                mem.Read(memorypos, buffer3, 0, count);

                return(RobotRaconteurNode.s.PackPodArray <T>(buffer3));
            }
            catch (Exception e)
            {
                using (MessageEntry merr = new MessageEntry())
                {
                    RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
                    RRDirectorExceptionHelper.SetError(merr, e.ToString());
                }
                return(null);
            }
        }
Esempio n. 10
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());
         }
     }
 }
Esempio n. 11
0
 public override void Write(ulong memorypos, MessageElementNestedElementList buffer, ulong bufferpos, ulong count)
 {
     try
     {
         using (buffer)
         {
             T[] buffer2 = (T[])RobotRaconteurNode.s.UnpackPodArray <T>(buffer);
             mem.Write(memorypos, buffer2, bufferpos, count);
         }
     }
     catch (Exception e)
     {
         using (MessageEntry merr = new MessageEntry())
         {
             RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
             RRDirectorExceptionHelper.SetError(merr, e.ToString());
         }
     }
 }
Esempio n. 12
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());
         }
     }
 }
Esempio n. 13
0
        public override void Read(ulong memorypos, RRBaseArray buffer, ulong bufferpos, ulong count)
        {
            try
            {
                using (buffer)
                {
                    T[] buffer3 = new T[count];
                    mem.Read(memorypos, buffer3, 0, count);

                    MessageElementDataUtil.ArrayToRRBaseArray(buffer3, buffer);
                }
            }
            catch (Exception e)
            {
                using (MessageEntry merr = new MessageEntry())
                {
                    RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
                    RRDirectorExceptionHelper.SetError(merr, e.ToString());
                }
            }
        }
Esempio n. 14
0
 public override MessageElement Next(MessageElement m, WrappedServiceSkelAsyncAdapter async_adapter)
 {
     using (m)
     {
         try
         {
             async_adapter.MakeAsync();
             generator.AsyncNext().ContinueWith(t => async_adapter.EndTask <ReturnType>(t, async_ret => RobotRaconteurNode.s.PackAnyType <ReturnType>("return", ref async_ret)));
             return(null);
         }
         catch (Exception e)
         {
             using (MessageEntry merr = new MessageEntry())
             {
                 RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
                 RRDirectorExceptionHelper.SetError(merr, e.ToString());
                 return(null);
             }
         }
     }
 }
Esempio n. 15
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);
     }
 }
Esempio n. 16
0
        public override void handler(string s, HandlerErrorInfo error)
        {
            try
            {
                if (error.error_code != 0)
                {
                    using (MessageEntry merr = new MessageEntry())
                    {
                        handler_task.SetException(RobotRaconteurExceptionUtil.ErrorInfoToException(error));
                        return;
                    }
                }

                handler_task.SetResult(s);
            }
            catch (Exception e)
            {
                using (MessageEntry merr = new MessageEntry())
                {
                    RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
                    RRDirectorExceptionHelper.SetError(merr, e.ToString());
                }
            }
        }
Esempio n. 17
0
        public override void handler(HandlerErrorInfo error)
        {
            try
            {
                if (error.error_code != 0)
                {
                    using (MessageEntry merr = new MessageEntry())
                    {
                        this.handler_func(RobotRaconteurExceptionUtil.ErrorInfoToException(error));
                        return;
                    }
                }

                handler_func(new Exception("Unknown exception"));
            }
            catch (Exception e)
            {
                using (MessageEntry merr = new MessageEntry())
                {
                    RobotRaconteurExceptionUtil.ExceptionToMessageEntry(e, merr);
                    RRDirectorExceptionHelper.SetError(merr, e.ToString());
                }
            }
        }