/// <summary> /// /// </summary> /// <returns></returns> private bool CreateSocketCommuniType(out SocketCommuniType ct) { DiscriminateMode dm = (DiscriminateMode)this.cmbDiscriminateMode.SelectedValue; ct = null; switch (dm) { case DiscriminateMode.ByIPAddress: bool b = CheckIPAddress(); if (!b) { return(false); } IPAddress ip = GetIPAddress(); ct = new SocketCommuniType(ip); break; case DiscriminateMode.ByLocalPort: int lp = GetLocalPort(); ct = new SocketCommuniType(dm, lp); break; case DiscriminateMode.ByRemotePort: int rp = GetRemotePort(); ct = new SocketCommuniType(dm, rp); break; default: throw new NotImplementedException("DiscriminateMode: " + dm); } return(true);; }
/// <summary> /// /// </summary> /// <param name="socketCT"></param> private void AddStation(SocketCommuniType socketCT) { // add string name = this.txtStationName.Text.Trim(); string desc = this.txtRemark.Text.Trim(); Station dbstation = new Station(name, socketCT); //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); // TODO: add station to hardwaremanager // }
/// <summary> /// /// </summary> /// <returns></returns> public StationCollection CreateRainStations(CommuniSoft soft) { string deviceType = "LXRainDevice"; StationCollection stations = new StationCollection(); DataTable stTable = LXDBDBI.LXDB.GetRainStationDataTable(); foreach (DataRow row in stTable.Rows) { string rainName = row["Rain_Name"].ToString(); int rainAddress = Convert.ToInt32(row["Rain_addr"]); string ipString = row["Rain_IP"].ToString(); IPAddress ip = IPAddress.Parse(ipString); int deviceid = rainAddress; int stationid = rainAddress; SocketCommuniType ct = new SocketCommuniType(ip); Station st = new Station(rainName, ct); st.ID = stationid; DeviceDefine dd = soft.DeviceDefineManager. DeviceDefineCollection.FindDeviceDefine(deviceType); LXRainDevice d = new LXRainDevice(dd, rainAddress); d.ID = deviceid; st.Devices.Add(d); stations.Add(st); } return(stations); }
public void t1() { CommuniSoft cs = new CommuniSoft(); CommuniType ct = new SocketCommuniType("1234"); CommuniPort cp = cs.CommuniPortManager.FindCommuniPort(ct); Assert.IsNull(cp); }
/// <summary> /// /// </summary> /// <param name="socketCT"></param> private void EditStation(SocketCommuniType socketCT) { string oldName = _station.Name; // edit _station.Name = this.txtStationName.Text.Trim(); _station.CommuniType = socketCT; //CZGRDBI.DBStation dbst = _station.Tag as CZGRDBI.DBStation; Station dbst = _station; dbst.Name = _station.Name; //dbst.Ordinal = (int)this.numOrdinal.Value; dbst.Description = this.txtRemark.Text; //dbst.Street = this.txtStreet.Text.Trim(); //dbst.CommuniTypeContent = _station.CommuniType.ToXml(); dbst.CommuniType = socketCT; //dbst.Update(); GetCSDBI().EditStation(oldName, dbst); }
/// <summary> /// /// </summary> /// <param name="station"></param> public frmStationItem(StationCollection stations, Station station) : this() { this._stations = stations; this._station = station; this.ADEState = ADEStatus.Edit; SocketCommuniType socketct = this._station.CommuniType as SocketCommuniType; this.txtStationName.Text = this._station.Name; //this.numOrdinal.Value = this._station.DBStation.Ordinal; this.txtRemark.Text = this._station.Description; //this.txtStreet.Text = this._station.DBStation.Street; if (socketct.DiscriminateMode == DiscriminateMode.ByIPAddress) { this.txtStationIP.Text = socketct.IPAddress.ToString(); } this.numLocalPort.Value = socketct.LocalPort; this.numRemotePort.Value = socketct.RemotePort; this.cmbDiscriminateMode.SelectedValue = socketct.DiscriminateMode; }
/// <summary> /// /// </summary> /// <returns></returns> private bool CreateSocketCommuniType( out SocketCommuniType socketct) { DiscriminateMode dm = (DiscriminateMode)this.cmbDiscriminateMode.SelectedValue; socketct = null; switch (dm) { case DiscriminateMode.ByIPAddress : bool b = CheckIPAddress(); if (!b) return false; IPAddress ip = GetIPAddress(); socketct = new SocketCommuniType(ip); break; case DiscriminateMode.ByLocalPort: int lp = GetLocalPort(); socketct = new SocketCommuniType(dm, lp); break; case DiscriminateMode.ByRemotePort: int rp = GetRemotePort(); socketct = new SocketCommuniType(dm, rp); break; default: throw new NotImplementedException("DiscriminateMode: " + dm); } return true; }
/// <summary> /// /// </summary> /// <returns></returns> public StationCollection CreateRainStations(CommuniSoft soft) { string deviceType = "LXRainDevice"; StationCollection stations = new StationCollection(); DataTable stTable = LXDBDBI.LXDB.GetRainStationDataTable(); foreach (DataRow row in stTable.Rows) { string rainName = row["Rain_Name"].ToString(); int rainAddress = Convert.ToInt32(row["Rain_addr"]); string ipString = row["Rain_IP"].ToString(); IPAddress ip = IPAddress.Parse(ipString); int deviceid = rainAddress; int stationid = rainAddress; SocketCommuniType ct = new SocketCommuniType(ip); Station st = new Station(rainName, ct); st.ID = stationid; DeviceDefine dd = soft.DeviceDefineManager. DeviceDefineCollection.FindDeviceDefine(deviceType); LXRainDevice d = new LXRainDevice(dd,rainAddress); d.ID = deviceid; st.Devices.Add(d); stations.Add(st); } return stations; }