コード例 #1
0
ファイル: Station.cs プロジェクト: hkiaipc/yh
        /// <summary>
        /// 
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="description"></param>
        public Station(string stationName, CommuniType communiType )
        {
            _name = stationName;
            //m_Description = description;

            if (communiType == null)
                throw new ArgumentNullException("communiType");
            this.m_CommuniType = communiType;
        }
コード例 #2
0
ファイル: Station.cs プロジェクト: hkiaipc/yh
        /// <summary>
        /// 
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="description"></param>
        public Station(string stationName, string description, DeviceCollection deviceCollection, CommuniType communiType)
            : this(stationName, communiType)
        {
            if (deviceCollection == null)
                throw new ArgumentNullException("deviceCollection");
            m_DeviceCollection = deviceCollection;
            m_DeviceCollection.Station = this;

            m_CommuniType = communiType;
        }
コード例 #3
0
ファイル: SerialCommuniPort.cs プロジェクト: hkiaipc/yh
        /// <summary>
        /// 
        /// </summary>
        /// <param name="communiType"></param>
        /// <returns></returns>
        public override bool Match(CommuniType communiType)
        {
            if( communiType == null )
                throw new ArgumentNullException ("communiType" );

            if (communiType is SerialCommuniType)
            {

            }
            return false;
        }
コード例 #4
0
ファイル: frmStationItem.cs プロジェクト: hkiaipc/hunb
        /// <summary>
        /// 
        /// </summary>
        /// <param name="socketCT"></param>
        //private void EditStation(SocketCommuniType socketCT)
        private void EditStation(CommuniType ct)
        {
            string oldName = _station.Name;
            // edit
            _station.Name = this.txtStationName.Text.Trim();
            _station.CommuniType = ct;
            _station.Description = this.txtRemark.Text;

            GetCSDBI().EditStation(oldName, _station);
            YeHeCommuniServerApp.Default.CSDBI.UpdateStationGroup(
                _station.ID, this.GroupID);
        }
コード例 #5
0
ファイル: frmStationItem.cs プロジェクト: hkiaipc/hunb
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ct"></param>
        /// <returns></returns>
        private bool CreateCommuniType(out CommuniType ct)
        {
            ct = null;
            bool b = false;
            if (rbSerialPort.Checked)
            {
                SerialCommuniType serialCT;
                b = CreateSerialCommuniType(out serialCT);
                ct = serialCT;
            }

            else if (rbSocket.Checked)
            {
                SocketCommuniType socketct;
                b = CreateSocketCommuniType(out socketct);
                ct = socketct;
            }
            else
            {
                throw new NotImplementedException("unknown communi type");
            }
            return b;
        }
コード例 #6
0
ファイル: frmStationItem.cs プロジェクト: hkiaipc/hunb
        /// <summary>
        /// 
        /// </summary>
        /// <param name="socketCT"></param>
        //private void AddStation(SocketCommuniType socketCT)
        private void AddStation(CommuniType ct)
        {
            // add
            string name = this.txtStationName.Text.Trim();
            string desc = this.txtRemark.Text.Trim();
            Station dbstation = new Station(name, ct);
            //dbstation.Ordinal = (int)this.numOrdinal.Value;
            dbstation.Description = this.txtRemark.Text;
            //dbstation.Street = this.txtStreet.Text.Trim();
            //dbstation.Create();

            _station = dbstation;

            //_station = new CZGRStation(name,
                //socketCT, dbstation);

            //_stations.Add(_station);

            GetCSDBI().AddStation(dbstation);

            Debug.Assert(dbstation.ID > 0);
            YeHeCommuniServerApp.Default.CSDBI.UpdateStationGroup(dbstation.ID,
                this.GroupID);

            // TODO: add station to hardwaremanager
            //
        }
コード例 #7
0
ファイル: SocketCommuniPort.cs プロジェクト: hkiaipc/c2
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ct"></param>
        /// <returns></returns>
        public override bool Match(CommuniType communiType)
        {
            if (communiType == null)
                throw new ArgumentNullException("communiType");

            bool result = false;
            SocketCommuniType gprsct = communiType as SocketCommuniType;
            if (gprsct != null)
            {
                // 2009-09-14
                // throw ObjectDisposedException if socket is disposed
                //
                //IPEndPoint remoteIpep = ((IPEndPoint)this.Socket.RemoteEndPoint);
                //IPEndPoint localIpep = ((IPEndPoint)this.Socket.LocalEndPoint);
                IPEndPoint remoteIpep = ((IPEndPoint)this.RemoteEndPoint);
                IPEndPoint localIpep = ((IPEndPoint)this.LocalEndPoint);

                switch (gprsct.DiscriminateMode)
                {
                    case DiscriminateMode.ByIPAddress:
                        result = gprsct.IPAddress.Equals(remoteIpep.Address);
                        break;

                    case DiscriminateMode.ByLocalPort:
                        result = (localIpep.Port == gprsct.LocalPort);
                        break;

                    case DiscriminateMode.ByRemotePort:
                        result = remoteIpep.Port == gprsct.RemotePort;
                        break;

                    //case DiscriminateMode.ByIPAddressPort:
                    //    result = (gprsct.IPAddress.Equals(remoteIpep.Address) &&
                    //        (localIpep.Port == gprsct.LocalPort));
                    //    break;

                    case DiscriminateMode.ByPhoneNumber:
                        throw new NotImplementedException("DiscriminateMode.ByPhoneNumber");

                    default:
                        throw new ArgumentException("unknown DiscriminateMode: " + gprsct.DiscriminateMode);
                }
            }
            return result;
        }
コード例 #8
0
ファイル: CommuniPort.cs プロジェクト: wwkkww1983/yh
 /// <summary>
 ///
 /// </summary>
 /// <param name="ct"></param>
 /// <returns></returns>
 abstract public bool Match(CommuniType communiType);
コード例 #9
0
ファイル: Station.cs プロジェクト: wwkkww1983/yh
        /// <summary>
        ///
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="description"></param>
        public Station(string stationName, string description, DeviceCollection deviceCollection, CommuniType communiType)
            : this(stationName, communiType)
        {
            if (deviceCollection == null)
            {
                throw new ArgumentNullException("deviceCollection");
            }
            m_DeviceCollection         = deviceCollection;
            m_DeviceCollection.Station = this;

            m_CommuniType = communiType;
        }
コード例 #10
0
ファイル: CommuniPortManager.cs プロジェクト: hkiaipc/c2
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CommuniPort FindCommuniPort(CommuniType communiType)
        {
            if (communiType == null)
                throw new ArgumentNullException("communiType");

            foreach (CommuniPort cp in this.CommuniPorts)
            {
                if (cp.Match(communiType))
                    return cp;
            }
            return null;
        }