Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EpicsServerChannel"/> class.
        /// </summary>
        /// <param name="server">
        /// The server.
        /// </param>
        /// <param name="serverId">
        /// The server id.
        /// </param>
        /// <param name="clientId">
        /// The client id.
        /// </param>
        /// <param name="channelName">
        /// The channel name.
        /// </param>
        /// <param name="conn">
        /// The conn.
        /// </param>
        internal EpicsServerChannel(
            EpicsServer server, int serverId, int clientId, string channelName, EpicsServerTCPConnection conn)
        {
            this.NotDisposing = true;
            this.ServerId     = serverId;
            this.ClientId     = clientId;
            this.ChannelName  = channelName;
            this.Server       = server;
            this.Conn         = conn;
            this.Conn.ConnectionStateChanged += this.Conn_ConnectionStateChanged;

            try
            {
                if (channelName.Contains("."))
                {
                    var splitted = channelName.Split('.');
                    this.Record   = this.Server.recordList[splitted[0]];
                    this.Property = (RecordProperty)Enum.Parse(typeof(RecordProperty), splitted[1]);
                }
                else
                {
                    this.Record = this.Server.recordList[this.ChannelName];
                }

                this.Conn.Send(
                    this.Server.Codec.channelCreatedMessage(
                        this.ClientId, this.ServerId, this.Record.TYPE, this.Record.dataCount, this.Access));
            }
            catch (Exception e)
            {
                this.Conn.Send(this.Server.Codec.channelCreationFailMessage(this.ClientId));
                this.Dispose();
            }
        }
Esempio n. 2
0
 internal EpicsArrayRecord(string recordName, EpicsServer server, int size)
     : base(recordName, server)
 {
     try
     {
         this.TYPE = EpicsCodec.CTypeTranslator[typeof(TDataType)];
         var data = new EpicsArray <TDataType>(size);
         data.DataManipulated += this.DataManipulated;
         this.dataCount        = size;
         this.value            = data;
     }
     catch (Exception e)
     {
         throw new Exception("Type not Supported by Epics Server");
     }
 }
Esempio n. 3
0
        // Properties

        /// <summary>
        /// Initializes a new instance of the <see cref="EpicsRecord{TDataType}"/> class.
        /// </summary>
        internal EpicsRecord(string recordName, EpicsServer server)
            : base(recordName, server)
        {
            try
            {
                if (typeof(TDataType).IsArray)
                {
                    throw new Exception("Use EpicsArrayRecord for Arrays!");
                }
                else
                {
                    this.TYPE = EpicsCodec.CTypeTranslator[typeof(TDataType)];
                }

                this.dataCount = 1;
            }
            catch (Exception e)
            {
                throw new Exception("Type not Supported by Epics Server");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EpicsServerUDPConnection"/> class.
        /// </summary>
        /// <param name="server">
        /// The server.
        /// </param>
        public EpicsServerUDPConnection(EpicsServer server)
            : base(new IPEndPoint(IPAddress.Parse(server.Config.ListenIP), server.Config.UDPPort))
        {
            this.Server = server;

            this.UDPSocket.ReceiveBufferSize = server.Config.UDPBufferSize;
            this.UDPSocket.SendBufferSize    = server.Config.UDPBufferSize;

            var       targetAddresses = new List <string>();
            var       interfaces      = NetworkInterface.GetAllNetworkInterfaces();
            long      longIp          = 0;
            IPAddress ip = null;

            foreach (var iface in interfaces)
            {
                var prop = iface.GetIPProperties();

                try
                {
                    longIp = (prop.UnicastAddresses[0].IPv4Mask.Address ^ IPAddress.Broadcast.Address)
                             | prop.UnicastAddresses[0].Address.Address;
                    ip = new IPAddress(longIp);
                }
                catch (Exception e)
                {
                    continue;
                }

                targetAddresses.Add(ip + ":" + this.Server.Config.UDPDestPort);
            }

            if (targetAddresses.Count == 0)
            {
                targetAddresses.Add(IPAddress.Broadcast + ":" + this.Server.Config.UDPDestPort);
            }

            this.wrapTargetList(targetAddresses);
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EpicsRecord"/> class.
 /// </summary>
 /// <param name="Name">
 /// The name.
 /// </param>
 /// <param name="server">
 /// The server.
 /// </param>
 internal EpicsRecord(string Name, EpicsServer server)
 {
     this.name   = Name;
     this.Server = server;
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EpicsServerTCPConnection"/> class.
 /// </summary>
 /// <param name="TCPSocket">
 /// The tcp socket.
 /// </param>
 /// <param name="server">
 /// The server.
 /// </param>
 internal EpicsServerTCPConnection(Socket TCPSocket, EpicsServer server)
     : base(TCPSocket)
 {
     this.Server    = server;
     this.remoteKey = TCPSocket.RemoteEndPoint.ToString();
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EpicsServerCodec"/> class.
 /// </summary>
 /// <param name="server">
 /// The server.
 /// </param>
 public EpicsServerCodec(EpicsServer server)
 {
     this.Server = server;
 }