/// <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> private void AddTasks(CommuniSoft soft) { foreach (TaskFactory factory in this._taskFactories) { factory.Create( soft ); } }
/// <summary> /// /// </summary> /// <returns></returns> public void Create(CommuniSoft soft) { if (soft == null) throw new ArgumentNullException("soft"); foreach (Station st in soft.HardwareManager.Stations) { foreach (Device d in st.Devices) { //if (d.DeviceType == _deviceType) if (StringHelper.Equal(d.DeviceDefine.DeviceType, _deviceType)) { //Opera o = soft.OperaFactory.Create(_deviceType, _operaname); DeviceDefine dd = soft.DeviceDefineManager.DeviceDefineCollection.FindDeviceDefine(_deviceType); if (dd == null) { throw new ConfigException(_deviceType); } Opera o = dd.CreateOpera(_operaname); if (o == null) { string exmsg = string.Format("Create opera fail\r\n device: '{0}'\r\n opera: '{1}'", _deviceType, _operaname ); throw new ConfigException(exmsg); } Strategy s = _strategyFactory.Create(); Task t = new Task(d, o, s); soft.TaskManager.Tasks.Add(t); } } } }
/// <summary> /// /// </summary> /// <param name="soft"></param> /// <param name="task"></param> private void AddTask(CommuniSoft soft, Device device, Opera op) { Task task = new Task(device, op, new ImmediateStrategy()); soft.TaskManager.Tasks.AddToHead(task); NUnit.UiKit.UserMessage.DisplayInfo(strings.CommandSubmit); }
/// <summary> /// /// </summary> /// <param name="_soft"></param> /// <param name="node"></param> private void BuildStationCollection(CommuniSoft soft, XmlNode stationsNode) { if (soft == null) { throw new ArgumentNullException("soft"); } if (stationsNode == null) { throw new ArgumentNullException("stationsNode"); } foreach (XmlNode stationNode in stationsNode) { XmlNode stationNameNode = stationNode.SelectSingleNode(HardwareNodeNames.StationName); Debug.Assert(stationNameNode != null, "station name node == null"); string name = stationNameNode.InnerText; XmlNode communitypeNode = stationNode.SelectSingleNode(HardwareNodeNames.CommuniType); Debug.Assert(communitypeNode != null, "communitype node == null"); CommuniType communiType = BuildCommuniType(communitypeNode); DeviceCollection devices = null; XmlNode devicesNode = stationNode.SelectSingleNode(HardwareNodeNames.DeviceCollection); if (devicesNode != null) { devices = BuildDeviceCollection(devicesNode); } Station st = new Station(name, communiType); st.Devices = devices; soft.HardwareManager.Stations.Add(st); } }
/// <summary> /// /// </summary> /// <returns></returns> public void Create(CommuniSoft soft) { if (soft == null) { throw new ArgumentNullException("soft"); } foreach (Station st in soft.HardwareManager.Stations) { foreach (Device d in st.Devices) { //if (d.DeviceType == _deviceType) if (StringHelper.Equal(d.DeviceDefine.DeviceType, _deviceType)) { //Opera o = soft.OperaFactory.Create(_deviceType, _operaname); DeviceDefine dd = soft.DeviceDefineManager.DeviceDefineCollection.FindDeviceDefine(_deviceType); if (dd == null) { throw new ConfigException(_deviceType); } Opera o = dd.CreateOpera(_operaname); if (o == null) { string exmsg = string.Format("Create opera fail\r\n device: '{0}'\r\n opera: '{1}'", _deviceType, _operaname); throw new ConfigException(exmsg); } Strategy s = _strategyFactory.Create(); Task t = new Task(d, o, s); soft.TaskManager.Tasks.Add(t); } } } }
/// <summary> /// /// </summary> private void AddTasks(CommuniSoft soft) { foreach (TaskFactory factory in this._taskFactories) { factory.Create(soft); } }
/// <summary> /// /// </summary> /// <returns></returns> public virtual void Build(CommuniSoft soft) { //CommuniSoft soft = new CommuniSoft(); this._deviceDefineBuilder.Build(soft); this._hardwareBuilder.Build(soft); this._taskFactoriesBuilder.Build(soft); this._listenBuilder.Build(soft); }
/// <summary> /// /// </summary> /// <param name="soft"></param> public OperaFactoryBase(CommuniSoft communiSoft) { if (communiSoft == null) { throw new ArgumentNullException("communiSoft"); } _communiSoft = communiSoft; }
/// <summary> /// /// </summary> /// <param name="soft"></param> public DPUManager(CommuniSoft soft) { if( soft == null ) { throw new ArgumentNullException("soft"); } this.Soft = soft; }
public void Init(CommuniSoft communiSoft) { UC u = GetUC(); //u.Top = 240; //u.Dock = System.Windows.Forms.DockStyle.Fill; u.Description = this.Description; communiSoft.UIManager.ParentControl.Controls.Add(u); }
/// <summary> /// /// </summary> public override void Build(CommuniSoft soft) { XmlDocument doc = new XmlDocument(); doc.Load(_filename); XmlNode node = doc.SelectSingleNode(DeviceDefineNodeNames.DeviceDefineCollection); _operaFactory = new XmlOperaFactory(soft, node); //soft.OperaFactory = _operaFactory; _operaFactory.InitFDManager(soft.FDManager); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmMain_Load(object sender, EventArgs e) { FillStationTreeView(appp.CommuniSoft.HardwareManager, this.tvStation); CommuniSoft soft = appp.CommuniSoft; // register events // new CommuniSoftEventsRegister(soft, appp.YeHeProcessor).Registe(); appp.CommuniSoft.Start(); }
public static DPUManager Create(CommuniSoft soft, AssemblyInfoCollection assemblyInfos) { DPUManager dpuManager = new DPUManager(soft); foreach (AssemblyInfo ai in assemblyInfos) { IDPU dpu = (IDPU)ObjectFactory.CreateWithInterface(ai.Path, typeof(IDPU)); dpuManager.Add(dpu); } return dpuManager; }
public static SPUManager Create(CommuniSoft soft, AssemblyInfoCollection assemblyInfos) { SPUManager spuManager = new SPUManager(soft); foreach (AssemblyInfo ai in assemblyInfos) { ISPU spu = SPUFactory.Create(ai.Path); spuManager.Add(spu); } return spuManager; }
/// <summary> /// /// </summary> public override void Build(CommuniSoft soft) { XmlDocument doc = new XmlDocument(); doc.Load(_filename); XmlNode node = doc.SelectSingleNode(DeviceDefineNodeNames.DeviceDefineCollection); _operaFactory = new XmlOperaFactory(soft, node); //soft.OperaFactory = _operaFactory; _operaFactory.InitFDManager(soft.FDManager); }
/// <summary> /// /// </summary> /// <param name="communiSoft"></param> public CommuniSoftEventsRegister(CommuniSoft communiSoft, YeHeProcessor processor) { if (communiSoft == null) { throw new ArgumentNullException("communiSoft"); } if (processor == null) { throw new ArgumentNullException("processor"); } _communiSoft = communiSoft; //_processAddin = _communiSoft.ProcessAddinManager.ProcessAddin; _processAddin = processor; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmMain_Load(object sender, EventArgs e) { this.mnuTest.Visible = Config.Default.Test; FillStationTreeView(appp.CommuniSoft.HardwareManager, this.tvStation); CommuniSoft soft = appp.CommuniSoft; // register events // new CommuniSoftEventsRegister(soft, appp.YeHeProcessor).Registe(); appp.CommuniSoft.Start(); _xd2206DataImporter = new Importer(XD2300Processor.Default.ProcessImport); _xd2206DataImporter.Start(); }
/// <summary> /// /// </summary> /// <param name="soft"></param> public override void Build(CommuniSoft soft) { if (soft == null) throw new ArgumentNullException("soft"); XmlDocument doc = new XmlDocument(); doc.Load(_filename); XmlNode hardwareNode = doc.SelectSingleNode(HardwareNodeNames.Hardware); if (hardwareNode != null) { XmlNode stationsNode = hardwareNode.SelectSingleNode(HardwareNodeNames.StationCollection); if (stationsNode != null) { BuildStationCollection(soft, stationsNode); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnReadRealData_Click(object sender, EventArgs e) { if (this._grdevice != null) { if (!CheckStationConnected(_grdevice.Station)) { return; } CommuniSoft soft = CZGRApp.Default.Soft; //Opera op = soft.OperaFactory.Create( // CZGRCommon.DeviceTypes.GRDevice, // GROperaNames.ReadReal); Opera op = GRDevice.DeviceDefine.CreateOpera(GROperaNames.ReadReal); //Task task = new Task(grdevice, op, new ImmediateStrategy()); //soft.TaskManager.Tasks.AddToHead(task); this.AddTask(soft, _grdevice, op); } }
/// <summary> /// /// </summary> /// <param name="soft"></param> public override void Build(CommuniSoft soft) { XmlDocument doc = new XmlDocument(); doc.Load(_filename); XmlNode node = doc.SelectSingleNode(XmlListenNodeNames.ListenPortCollection); if (node != null) { foreach (XmlNode n in node.ChildNodes) { if (n.Name == XmlListenNodeNames.ListenPort) { int port = int.Parse(n.InnerText); SocketListener sckListener = new SocketListener(port); sckListener.Start(); soft.SocketListenerManager.Add(sckListener); } } } }
/// <summary> /// /// </summary> /// <param name="communiSoft"></param> /// <param name="dbiBase"></param> /// <param name="fromStation"></param> /// <param name="fromDevice"></param> /// <param name="fromOpera"></param> /// <param name="fromReceivePart"></param> /// <param name="fromAddress"></param> /// <param name="pr"></param> /// <returns></returns> public bool ProcessParseResult(CommuniSoft communiSoft, DBIBase dbiBase, string fromStation, string fromDevice, string fromOpera, string fromReceivePart, int fromAddress, ParseResult pr) { foreach (IParseResultProcessor p in IParseResultProcessorCollection) { if (p.ForDevice == fromDevice) { p.DBIBase = dbiBase; p.FromStation = fromStation; p.FromDevice = fromDevice; p.FromOpera = fromOpera; p.FromAddress = fromAddress; p.FromReceivePart = fromReceivePart; p.ProcessParseResult(communiSoft, pr); return(true); } } return(false); }
/// <summary> /// /// </summary> /// <param name="communiSoft"></param> /// <param name="dbiBase"></param> /// <param name="fromStation"></param> /// <param name="fromDevice"></param> /// <param name="fromOpera"></param> /// <param name="fromReceivePart"></param> /// <param name="fromAddress"></param> /// <param name="pr"></param> /// <returns></returns> public bool ProcessParseResult(CommuniSoft communiSoft, DBIBase dbiBase, string fromStation, string fromDevice, string fromOpera, string fromReceivePart, int fromAddress, ParseResult pr) { foreach (IParseResultProcessor p in IParseResultProcessorCollection) { if (p.ForDevice == fromDevice) { p.DBIBase = dbiBase; p.FromStation = fromStation; p.FromDevice = fromDevice; p.FromOpera = fromOpera; p.FromAddress = fromAddress; p.FromReceivePart = fromReceivePart; p.ProcessParseResult(communiSoft, pr); return true; } } return false; }
/// <summary> /// /// </summary> /// <param name="soft"></param> public override void Build(CommuniSoft soft) { if (soft == null) { throw new ArgumentNullException("soft"); } XmlDocument doc = new XmlDocument(); doc.Load(_filename); XmlNode hardwareNode = doc.SelectSingleNode(HardwareNodeNames.Hardware); if (hardwareNode != null) { XmlNode stationsNode = hardwareNode.SelectSingleNode(HardwareNodeNames.StationCollection); if (stationsNode != null) { BuildStationCollection(soft, stationsNode); } } }
/// <summary> /// /// </summary> /// <param name="soft"></param> public override void Build(CommuniSoft soft) { XmlDocument doc = new XmlDocument(); doc.Load(_filename); XmlNode node = doc.SelectSingleNode(XmlListenNodeNames.ListenPortCollection); if (node != null) { foreach (XmlNode n in node.ChildNodes) { if (n.Name == XmlListenNodeNames.ListenPort) { int port = int.Parse(n.InnerText); SocketListener sckListener = new SocketListener(port); sckListener.Start(); soft.SocketListenerManager.Add(sckListener); } } } }
/// <summary> /// /// </summary> /// <param name="node"></param> public XmlOperaFactory(CommuniSoft communiSoft, XmlNode deviceDefinesNode) : base(communiSoft) { if (deviceDefinesNode == null) { throw new ArgumentNullException("node"); } this._deviceDefinesNode = deviceDefinesNode; foreach (XmlNode deviceDefineNode in deviceDefinesNode.ChildNodes) { if (deviceDefineNode.Name == DeviceDefineNodeNames.DeviceDefine) { string deviceType = GetAttribute((XmlElement)deviceDefineNode, DeviceDefineNodeNames.DeviceType); string deviceText = GetAttribute((XmlElement)deviceDefineNode, DeviceDefineNodeNames.DeviceText); // TODO: remove xmlOperaFactory DeviceDefineCollection // // TODO: 2010-07-28 add device parameter define // DeviceDefine dd = new DeviceDefine(deviceType, deviceText); XmlNode paramDefinesNode = deviceDefineNode.SelectSingleNode(ParameterNodeNames.ParameterDefineCollection); if (paramDefinesNode != null) { ParameterDefineCollection paramDefines = XmlModbusParameterDefineBuilder.BuildParameterDefineCollection(paramDefinesNode); dd.ParameterDefineCollection = paramDefines; } this.DeviceDefineCollection.Add(dd); //this.CommuniSoft.DeviceDefineCollection.Add(dd); } } }
/// <summary> /// /// </summary> /// <param name="soft"></param> public override void Build(CommuniSoft soft) { BuildTaskFactories(); AddTasks(soft); }
/// <summary> /// /// </summary> /// <param name="soft"></param> public override void Build(CommuniSoft soft) { soft.DeviceDefineManager.LoadFromPath(_path); }
/// <summary> /// /// </summary> /// <param name="soft"></param> public override void Build(CommuniSoft soft) { soft.DeviceDefineManager.LoadFromPath(_path); }
/// <summary> /// /// </summary> /// <param name="soft"></param> public abstract void Build(CommuniSoft soft);
/// <summary> /// /// </summary> /// <param name="soft"></param> public override void Build(CommuniSoft soft) { BuildTaskFactories(); AddTasks(soft); }
/// <summary> /// /// </summary> /// <param name="soft"></param> abstract public void Build(CommuniSoft soft);
/// <summary> /// /// </summary> /// <param name="node"></param> public XmlOperaFactory(CommuniSoft communiSoft, XmlNode deviceDefinesNode) : base(communiSoft) { if (deviceDefinesNode == null) throw new ArgumentNullException("node"); this._deviceDefinesNode = deviceDefinesNode; foreach( XmlNode deviceDefineNode in deviceDefinesNode.ChildNodes ) { if (deviceDefineNode.Name == DeviceDefineNodeNames.DeviceDefine) { string deviceType = GetAttribute((XmlElement)deviceDefineNode, DeviceDefineNodeNames.DeviceType); string deviceText = GetAttribute((XmlElement)deviceDefineNode, DeviceDefineNodeNames.DeviceText); // TODO: remove xmlOperaFactory DeviceDefineCollection // // TODO: 2010-07-28 add device parameter define // DeviceDefine dd = new DeviceDefine(deviceType, deviceText); XmlNode paramDefinesNode = deviceDefineNode.SelectSingleNode(ParameterNodeNames.ParameterDefineCollection); if (paramDefinesNode != null) { ParameterDefineCollection paramDefines = XmlModbusParameterDefineBuilder.BuildParameterDefineCollection(paramDefinesNode); dd.ParameterDefineCollection = paramDefines; } this.DeviceDefineCollection.Add(dd); //this.CommuniSoft.DeviceDefineCollection.Add(dd); } } }
/// <summary> /// /// </summary> /// <param name="communiSoft"></param> /// <param name="pr"></param> public abstract void ProcessParseResult(CommuniSoft communiSoft, ParseResult pr);
/// <summary> /// /// </summary> /// <param name="communiSoft"></param> /// <param name="pr"></param> abstract public void ProcessParseResult(CommuniSoft communiSoft, ParseResult pr);
/// <summary> /// /// </summary> /// <param name="soft"></param> public OperaFactoryBase(CommuniSoft communiSoft) { if (communiSoft == null) throw new ArgumentNullException("communiSoft"); _communiSoft = communiSoft; }
/// <summary> /// /// </summary> /// <param name="_soft"></param> /// <param name="node"></param> private void BuildStationCollection(CommuniSoft soft, XmlNode stationsNode) { if (soft == null) throw new ArgumentNullException("soft"); if (stationsNode == null) throw new ArgumentNullException("stationsNode"); foreach (XmlNode stationNode in stationsNode) { XmlNode stationNameNode = stationNode.SelectSingleNode(HardwareNodeNames.StationName); Debug.Assert(stationNameNode != null, "station name node == null"); string name = stationNameNode.InnerText; XmlNode communitypeNode = stationNode.SelectSingleNode(HardwareNodeNames.CommuniType); Debug.Assert(communitypeNode != null, "communitype node == null"); CommuniType communiType = BuildCommuniType(communitypeNode); DeviceCollection devices = null; XmlNode devicesNode = stationNode.SelectSingleNode(HardwareNodeNames.DeviceCollection); if (devicesNode != null) { devices = BuildDeviceCollection(devicesNode); } Station st = new Station(name, communiType); st.Devices = devices; soft.HardwareManager.Stations.Add(st); } }
/// <summary> /// /// </summary> /// <param name="soft"></param> public override void Build(CommuniSoft soft) { System.Collections.Hashtable idStationMap = new System.Collections.Hashtable(); // build station // foreach (DataRow stationDR in _stationDataTable.Rows) { bool isStationDeleted = false; if (stationDR["Deleted"] != DBNull.Value) { isStationDeleted = Convert.ToBoolean(stationDR["Deleted"]); } if (!isStationDeleted) { string stationName = stationDR["Name"].ToString(); bool isExistStation = soft.HardwareManager.Stations.ExistName(stationName, null); if (!isExistStation) { string xml = stationDR["CommuniTypeContent"].ToString().Trim(); if (xml.Length == 0) { // TODO: 2010-09-17 // log error info // continue; } int stationID = (int)stationDR["StationID"]; XmlDataDocument doc = new XmlDataDocument(); doc.LoadXml(xml); XmlNode node = doc.SelectSingleNode("socketcommunitype"); CommuniType communiType = Xdgk.Communi.XmlBuilder.XmlSocketCommuniBuilder.Build(node); Station station = new Station(stationName, communiType); station.ID = stationID; idStationMap.Add(stationID, station); soft.HardwareManager.Stations.Add(station); } } } // build device // foreach (DataRow deviceDR in _deviceDataTable.Rows) { bool isDeviceDeleted = false; if (deviceDR["deleted"] != DBNull.Value) { isDeviceDeleted = Convert.ToBoolean(deviceDR["Deleted"]); } if (isDeviceDeleted) { continue; } int stationID = (int)deviceDR["StationID"]; int deviceID = (int)deviceDR["DeviceID"]; string deviceType = deviceDR["DeviceType"].ToString(); string addressString = deviceDR["Address"].ToString().Trim(); if (addressString.Length == 0) { continue; } int address = Convert.ToInt32(addressString); Station st = idStationMap[stationID] as Station; if (st == null) { continue; } //DeviceDefine dd = soft.DeviceDefineCollection.FindDeviceDefine(deviceType); DeviceDefine dd = soft.DeviceDefineManager.DeviceDefineCollection.FindDeviceDefine(deviceType); if (dd == null) { bool exist = soft.UnDefineDeviceType.Exist(deviceType); if (!exist) { soft.UnDefineDeviceType.Add(deviceType); string msg = string.Format(strings.UnDefineDeviceType, deviceType); NUnit.UiKit.UserMessage.Display(msg); } continue; } //Xdgk.Communi.Device device = new Device(dd, "", address); Xdgk.Communi.Device device = DeviceFactory.Create(dd, "", address); //Xdgk.Communi.Device device = new Device(deviceType, address); //string t = soft.OperaFactory.DeviceDefineCollection.GetDeviceText(deviceType); //device.Text = t; device.ID = deviceID; //Station st = soft.HardwareManager.GetStation(stationName); st.Devices.Add(device); } // // StationCollection rainStations = this.CreateRainStations(soft); foreach (Station item in rainStations) { soft.HardwareManager.Stations.Add(item); } }