コード例 #1
0
        internal override void Decode(EpicsChannel channel, uint nbElements)
        {
            Status   = (Status)channel.DecodeData <ushort>(1, 0);
            Severity = (Severity)channel.DecodeData <ushort>(1, 2);
            int  pos = 4;
            Type t   = typeof(TType);

            if (t.IsArray)
            {
                t = t.GetElementType();
            }
            if (t == typeof(object))
            {
                t = channel.ChannelDefinedType;
            }
            if (t == typeof(double) || t == typeof(float))
            {
                Precision = channel.DecodeData <short>(1, pos);
                pos      += 4; // 2 for precision field + 2 padding for "RISC alignment"
            }
            if (t != typeof(string))
            {
                EGU  = channel.DecodeData <string>(1, pos, 8);
                pos += 8;
                int tSize = TypeHandling.EpicsSize(t);

                //HighDisplayLimit = channel.DecodeData<TType>(1, pos);
                HighDisplayLimit = Convert.ToDouble(channel.DecodeData(t, 1, pos));
                pos += tSize;
                //LowDisplayLimit = channel.DecodeData<TType>(1, pos);
                LowDisplayLimit = Convert.ToDouble(channel.DecodeData(t, 1, pos));
                pos            += tSize;
                //HighAlertLimit = channel.DecodeData<TType>(1, pos);
                HighAlertLimit = Convert.ToDouble(channel.DecodeData(t, 1, pos));
                pos           += tSize;
                //HighWarnLimit = channel.DecodeData<TType>(1, pos);
                HighWarnLimit = Convert.ToDouble(channel.DecodeData(t, 1, pos));
                pos          += tSize;
                //LowWarnLimit = channel.DecodeData<TType>(1, pos);
                LowWarnLimit = Convert.ToDouble(channel.DecodeData(t, 1, pos));
                pos         += tSize;
                //LowAlertLimit = channel.DecodeData<TType>(1, pos);
                LowAlertLimit   = Convert.ToDouble(channel.DecodeData(t, 1, pos));
                pos            += tSize;
                LowControlLimit = Convert.ToDouble(channel.DecodeData(t, 1, pos));
                pos            += tSize;
                //HighControlLimit = channel.DecodeData<TType>(1, pos);
                HighControlLimit = Convert.ToDouble(channel.DecodeData(t, 1, pos));
                pos += tSize;
            }
            else
            {
                EGU = "";
            }
            if (t == typeof(byte))
            {
                pos++; // 1 padding for "RISC alignment"
            }
            Value = channel.DecodeData <TType>(nbElements, pos);
        }
コード例 #2
0
        internal override void Decode(EpicsChannel channel, uint nbElements)
        {
            Status   = (Status)channel.DecodeData <ushort>(1, 0);
            Severity = (Severity)channel.DecodeData <ushort>(1, 2);
            Time     = channel.DecodeData <DateTime>(1, 4);
            int  pos = 12;
            Type t   = typeof(TType);

            if (t.IsArray)
            {
                t = t.GetElementType();
            }
            if (t == typeof(object))
            {
                t = channel.ChannelDefinedType;
            }
            // padding for "RISC alignment"
            if (t == typeof(byte))
            {
                pos += 3;
            }
            else if (t == typeof(double))
            {
                pos += 4;
            }
            else if (t == typeof(short))
            {
                pos += 2;
            }
            Value = channel.DecodeData <TType>(nbElements, pos);
        }
コード例 #3
0
        void AfterActionStatusChanged(EpicsChannel sender, ChannelStatus newStatus)
        {
            List <Action <EpicsChannel> > todo = new List <Action <EpicsChannel> >();

            lock (AfterAction)
            {
                //Console.WriteLine("After Action Status Changed");
                this.StatusChanged -= AfterActionStatusChanged;
                if (Disposed)
                {
                    return;
                }
                if (AfterAction == null)
                {
                    return;
                }

                todo = AfterAction.ToList();
                AfterAction.Clear();
            }

            foreach (var i in todo)
            {
                i(this);
            }
        }
コード例 #4
0
 void MultiGetAfterReadNotify(EpicsChannel sender, object newValue)
 {
     sender.AfterReadNotify -= MultiGetAfterReadNotify;
     try
     {
         multiActionCountDown.Signal();
     }
     catch
     {
     }
 }
コード例 #5
0
 internal override void Decode(EpicsChannel channel, uint nbElements)
 {
     Status   = (Status)channel.DecodeData <ushort>(1, 0);
     Severity = (Severity)channel.DecodeData <ushort>(1, 2);
     NbStates = channel.DecodeData <ushort>(1, 4);
     States   = new string[NbStates];
     Value    = channel.DecodeData <ushort>(1, 422);
     for (int i = 0; i < NbStates; i++)
     {
         States[i] = channel.DecodeData <string>(1, 6 + i * 26, 26);
     }
 }
コード例 #6
0
        internal void Add(EpicsChannel channel)
        {
            lock (toSearch)
            {
                channel.SearchInvervalCounter = channel.SearchInverval = 1;

                if (!toSearch.Contains(channel))
                {
                    toSearch.Add(channel);
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Creates a new Generic EpicsChannel of the given type.
        /// </summary>
        /// <typeparam name="TType">Type of the channel which needs to be deal with.</typeparam>
        /// <param name="channelName">Name of the channel</param>
        /// <returns></returns>
        public EpicsChannel <TType> CreateChannel <TType>(string channelName)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            EpicsChannel <TType> channel = new EpicsChannel <TType>(this, channelName);

            lock (Channels)
            {
                Channels.Add(channel.CID, channel);
            }
            return(channel);
        }
コード例 #8
0
        void SendMonitor(EpicsChannel action)
        {
            if (ChannelDataCount == 0)
            {
                return;
            }

            //Console.WriteLine("Sending new event add");
            DataPacket p = DataPacket.Create(16 + 16);

            p.Command = (ushort)CommandID.CA_PROTO_EVENT_ADD;
            Type t = typeof(TType);

            if (t.IsArray)
            {
                t = t.GetElementType();
            }
            else if (t.IsGenericType)
            {
                if (t.GetGenericArguments().First() == typeof(object))
                {
                    t = t.GetGenericTypeDefinition().MakeGenericType(new Type[] { channelDefinedType });
                }
            }
            p.DataType   = (ushort)TypeHandling.Lookup[t];
            p.DataCount  = ChannelDataCount;
            p.Parameter1 = SID;
            p.Parameter2 = CID;

            p.SetUInt16(12 + 16, (ushort)MonitorMask);

            if (ioc != null)
            {
                ioc.Send(p);
            }
        }
コード例 #9
0
        internal void SetIoc(DataPipe pipe)
        {
            TcpReceiver tcpReceiver = (TcpReceiver)pipe[0];

            tcpReceiver.AddChannel(this);
            lock (ConnectionLock)
            {
                if (!Client.Searcher.Contains(this))
                {
                    return;
                }
                Client.Searcher.Remove(this);
                SID = 0;

                ioc = tcpReceiver;
                lock (ioc.ChannelSID)
                {
                    //Console.WriteLine(ioc.ChannelSID.Count);
                    // Channel already known
                    if (ioc.ChannelSID.ContainsKey(ChannelName))
                    {
                        SID = ioc.ChannelSID[ChannelName];
                        //Console.WriteLine("Here");
                        EpicsChannel chan = ioc.ConnectedChannels.FirstOrDefault(row => row.ChannelName == ChannelName && row.ChannelDataCount != 0);
                        if (chan != null)
                        {
                            this.ChannelDataCount   = chan.ChannelDataCount;
                            this.channelDefinedType = chan.channelDefinedType;
                            this.ChannelDataCount   = chan.ChannelDataCount;
                            this.channelDefinedType = chan.ChannelDefinedType;
                            Status = ChannelStatus.CONNECTED;
                            ConnectionEvent.Set();
                        }
                    }
                }
            }
            if (SID != 0)
            {
                //Console.WriteLine("SID " + SID + " STATUS CHANGED");
                if (StatusChanged != null)
                {
                    StatusChanged(this, Status);
                }
                return;
            }
            if (Client.Configuration.DebugTiming)
            {
                lock (ElapsedTimings)
                {
                    if (!ElapsedTimings.ContainsKey("IocConnection"))
                    {
                        ElapsedTimings.Add("IocConnection", Stopwatch.Elapsed);
                    }
                }
            }

            // We need to create the channel
            int padding;

            if (ChannelName.Length % 8 == 0)
            {
                padding = 8;
            }
            else
            {
                padding = (8 - (ChannelName.Length % 8));
            }

            DataPacket packet = DataPacket.Create(16 + ChannelName.Length + padding);

            packet.Command    = (ushort)CommandID.CA_PROTO_CREATE_CHAN;
            packet.DataType   = 0;
            packet.DataCount  = 0;
            packet.Parameter1 = cid;
            packet.Parameter2 = (uint)EpicsConstants.CA_MINOR_PROTOCOL_REVISION;
            packet.SetDataAsString(ChannelName);

            if (ioc != null)
            {
                ioc.Send(packet);
            }
            else
            {
                Disconnect();
                return;
            }
            lock (ElapsedTimings)
            {
                if (!ElapsedTimings.ContainsKey("SendCreateChannel"))
                {
                    ElapsedTimings.Add("SendCreateChannel", Stopwatch.Elapsed);
                }
            }
        }
コード例 #10
0
 internal void Remove(EpicsChannel channel)
 {
     lock (toSearch)
         toSearch.Remove(channel);
 }
コード例 #11
0
 internal bool Contains(EpicsChannel channel)
 {
     lock (toSearch)
         return(toSearch.Contains(channel));
 }
コード例 #12
0
 internal abstract void Decode(EpicsChannel channel, uint nbElements);