public bool OnInit() { _log.NormalLog(string.Format("ModbusTCPClientHanderTask:Init=>Initing ")); try { //获取配置 _config = ReaderXMLUtil.ReadXMLConfig <ModbusTCPClientConfig>("../../../../conf/Configuration.xml", ModbusTCPClientConfig.ReadConfig, "setup", "ModbusTCPClientHandlerTask")[0]; if (_config.IpAddress == "" || _config.SignalListFilePath == "") { _log.ErrorLog(string.Format("ModbusTCPClientHanderTask Init fail:{0}", "IP address or Signal file path is null!")); return(false); } _setup = new EthernetSetUp(_config.IpAddress, _config.Port); _timeout = new TimeOut("ModbusTCPClientHanderTask", _config.TimeOut, _log); _timeRead = new Timer.Timer(_config.PollingTime); _client = new ModbusTCPClient(_setup, _timeout, _log); //获取点数据 _workbook = XmlSerialiaztion.XmlDeserial <XMLWorkbook>(_config.SignalListFilePath, _log); _points = PointsCollcetCreate.Create(_workbook, _log); //点数据注册 PointsRegister.Register(ref _points, _log); _log.NormalLog(string.Format("ModbusTCPClientHanderTask:Initing=>Inited ")); return(true); } catch (Exception e) { _log.ErrorLog(string.Format("ModbusTCPClientHanderTask Init fail:{0}", e.Message)); return(false); } }
private void ElementSearchOutputFilePathbutton_Click(object sender, RoutedEventArgs e) { string sFileStyle = "XML | *.xml"; string UIKey = "ElementSearchOutputFilePathBox"; string UIKey1 = "OutPutDatasteBox"; string sOutFilePath = UIdictionary[UIKey].MyString; bool bOpenEnable = Outputfile(ref sOutFilePath, sFileStyle); UIdictionary[UIKey1].MyString = ""; try { if (bOpenEnable) { BaseFactory factory = new BaseFactory(CreateConvertParameter()); ElementSearchData elmentSearchData = (ElementSearchData)factory.CreatDataClass("ElementSearchData"); CreateDataMath <ElementSeacrhStruct, ConveyorRow> elmentSearchMath = elmentSearchData.CreateElements; List <ElementSeacrhStruct> lelmentSearchData = elmentSearchData.CreateList(elmentSearchMath); ElementSearchXml elementSearchXml = new ElementSearchXml(); elementSearchXml.Elements = lelmentSearchData; UIdictionary[UIKey1].MyString = DataConvert.ToString(lelmentSearchData); UIdictionary[UIKey].MyString = sOutFilePath; XmlSerialiaztion.XmlSerial(sOutFilePath, elementSearchXml); } } catch (Exception ex) { MessageBox.Show("Build Element Search Data Error: " + ex.Message); } GC.Collect(); }
private void SorteIOOutputFilePathbutton_Click(object sender, RoutedEventArgs e) { string sFileStyle = "Excel(.csv) | *.csv"; string UIKey = "SorteIOOutputFilePathBox"; string UIKey1 = "OutPutDatasteBox"; string UIKey2 = "SorteIOInputFilePathBox"; string sOutFilePath = UIdictionary[UIKey].MyString; string sInFilePath = UIdictionary[UIKey2].MyString; bool bOpenEnable = Outputfile(ref sOutFilePath, sFileStyle); UIdictionary[UIKey1].MyString = ""; try { if (bOpenEnable & sInFilePath != "") { DataTable dt = XmlSerialiaztion.XmlDeserial <SignalMonitor>(sInFilePath).ToDataTable(); UIdictionary[UIKey].MyString = sOutFilePath; //ExcelFunction.ExcelWrite(sFilePath, dt); CsvFunction.CsvWirte(sOutFilePath, dt); UIdictionary[UIKey1].MyString = DataConvert.ToString(dt); } } catch (Exception ex) { MessageBox.Show("Build OPC Data Error: " + ex.Message); } GC.Collect(); }
/// <summary> /// Merge the config files,such as :ALarm_TextList,OPCinfo. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MergeOutputFilePathbutton_Click(object sender, RoutedEventArgs e) { string sFileStyle = "XML | *.xml"; string UIKey = "MergeOutputFilePathBox"; string UIKey1 = "OutPutDatasteBox"; string UIKey2 = "WorkraButton"; string UIKey3 = "ElementSearchraButton"; string sFilePath = UIdictionary[UIKey].MyString; bool? btypeWorkbook = UIdictionary[UIKey2].Mybool; bool? btypeElementSearch = UIdictionary[UIKey3].Mybool; bool bOpenEnable = Outputfile(ref sFilePath, sFileStyle); UIdictionary[UIKey1].MyString = ""; try { if (bOpenEnable) { UIdictionary[UIKey1].MyString = "Merge Datas Successful"; UIdictionary[UIKey].MyString = sFilePath; if (btypeWorkbook == true) { XmlSerialiaztion.XmlSerial(sFilePath, Merge <Workbook>(sPaths)); } else if (btypeElementSearch == true) { XmlSerialiaztion.XmlSerial(sFilePath, Merge <ElementSearchXml>(sPaths)); } } } catch (Exception ex) { MessageBox.Show("Merge files Error: " + ex.Message); } }
/// <summary> /// WPF XAML数据输出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void XMLOutputbutton_Click(object sender, RoutedEventArgs e) { string sFileStyle = "WPF (.Xaml)|*.Xaml"; string UIKey = "XMLOutPutFilePathteBox"; string UIKey1 = "OutPutDatasteBox"; string UIKey2 = "L1raButton"; string UIKey3 = "L2raButton"; string UIKey4 = "TeBlackraButton"; string UIKey5 = "ElementradioButton"; string UIKey6 = "ViewNameteBox"; string sFilePath = UIdictionary[UIKey].MyString; UIdictionary[UIKey1].MyString = ""; try { bool bOpenEnable = Outputfile(ref sFilePath, sFileStyle); if (bOpenEnable == true) { BaseFactory factory = new BaseFactory(); factory.BaseParameter = CreateConvertParameter(); XamlData Data = (XamlData)factory.CreatDataClass("XamlData"); CreateDataMath <BgElementCommonXaml, ConveyorRow> bgXmalMath; CreateDataMath <BgTextBlock, ConveyorRow> blockTextMath; List <BgElementCommonXaml> bgXamlGroup = new List <BgElementCommonXaml>(); List <BgTextBlock> textBlockGroup = new List <BgTextBlock>(); if (UIdictionary[UIKey2].Mybool == true) { bgXmalMath = Data.CreatL1CommonXaml12307; bgXamlGroup = Data.CreateList(bgXmalMath); } else if (UIdictionary[UIKey3].Mybool == true) { if (UIdictionary[UIKey5].Mybool == true) { bgXmalMath = Data.CreatL2CommonXaml; bgXamlGroup = Data.CreateList(bgXmalMath); } else if (UIdictionary[UIKey4].Mybool == true) { blockTextMath = Data.CreatTextBlock; textBlockGroup = Data.CreateList(blockTextMath); } } ElementXaml elementXaml = new ElementXaml(bgXamlGroup, textBlockGroup, UIdictionary[UIKey6].MyString); XmlSerialiaztion.XmlSerial(@sFilePath, elementXaml); UIdictionary[UIKey].MyString = sFilePath; UIdictionary[UIKey1].MyString = "Build Xaml Successful!"; //System.IO.File.WriteAllText(@sFilePath, UIdictionary[UIKey1].MyString, Encoding.UTF8); } } catch (Exception ex) { MessageBox.Show("Build XML Data Error: " + ex.Message); } GC.Collect(); }
private void ConfOutputbutton_Click(object sender, RoutedEventArgs e) { string sFileStyle = "Excel(.xml) | *.xml"; string UIKey = "ConfOutPutFilePathteBox"; string UIKey1 = "OutPutDatasteBox"; string UIKey2 = "OPCInforaButton"; string UIKey3 = "AlarmListradioButton"; string sFilePath = UIdictionary[UIKey].MyString; bool bOpenEnable = Outputfile(ref sFilePath, sFileStyle); UIdictionary[UIKey1].MyString = ""; try { if (bOpenEnable) { BaseFactory factory = new BaseFactory(); factory.BaseParameter = CreateConvertParameter(); factory.bOPCIfo = (bool)UIdictionary[UIKey2].Mybool; factory.bConvAlarm = (bool)UIdictionary[UIKey3].Mybool; CreateDataMath <List <string>, ConveyorRow> createMath; ConfigData dConfigData; List <List <string> > lls = new List <List <string> >(); //ConfigData dConfigData = (ConfigData)factory.CreatDataClass("ConfigData"); if (UIdictionary[UIKey2].Mybool == true) { string[] sListColName = { "Tag Name", "Type", "Channel", "Device", "DataType" }; factory.sListColName = sListColName.ToList(); dConfigData = (ConfigData)factory.CreatDataClass("ConfigData"); createMath = dConfigData.CreateOPCInfoRows; lls = dConfigData.CreateList(createMath); } if (UIdictionary[UIKey3].Mybool == true) { string[] sListColName = { "SignalName", "AckType", "AlarmTag", "PartName", "Alarm Description", "AlarmGroup", "AlarmType", "AlarmCategory", "Delayed", "ConditionName", "Priority", "GeneralComment","Level1View", "Level2View", "Resetable", "ResetBit", "ALNumber", "CCTVRecording", "ElementID", "ResetSignal", "ExtraTagList", "CISData", "Technical" }; factory.sListColName = sListColName.ToList(); dConfigData = (ConfigData)factory.CreatDataClass("ConfigData"); createMath = dConfigData.CreateAlarmListRows; lls = dConfigData.CreateList(createMath); } UIdictionary[UIKey].MyString = sFilePath; //ExcelFunction.ExcelWrite(sFilePath, dt); //XmlFuction xmlFuction = new XmlFuction(); //xmlFuction.XmlWrite(sFilePath, dt); XmlSerialiaztion.XmlSerial(sFilePath, new Workbook(lls)); UIdictionary[UIKey1].MyString = "Build Datas Successful"; } } catch (Exception ex) { MessageBox.Show("Build OPC Data Error: " + ex.Message); } GC.Collect(); }
private T Merge <T>(string[] spaths) where T : IOperation <T>, new() { int i = 0; T files = new T(); foreach (string s in sPaths) { T flie = XmlSerialiaztion.XmlDeserial <T>(s); files.Add(flie); i++; } return(files); }
public virtual bool BuildPoints() { var workBook = XmlSerialiaztion.XmlDeserial <XMLWorkbook>(_baseconfig.SignalListFilePath, _log); if (workBook == null) { _log.ErrorLog("BuildPoints:Points List data read Error!!"); return(false); } var pointsFactory = new PointsCollcetFactory(workBook, _log); _serverTask.Points = pointsFactory.CreatePoints(_serverName); return(true); }
public virtual bool BuildPoints() { if (_baseconfig.SignalListFilePath == "") { _log.ErrorLog("BuildPoints:Points List data read Error,Path is null!!"); return(false); } var workBook = XmlSerialiaztion.XmlDeserial <XMLWorkbook>(_baseconfig.SignalListFilePath, _log); if (workBook == null) { _log.ErrorLog("BuildPoints:Points List data read Error!!"); return(false); } var pointsFactory = new PointsCollcetFactory(workBook, _log); var points = pointsFactory.CreatePoints(_clientName); PointsRegister.Register(ref points, _log); _clientTask.Points = points; return(true); }
public bool OnInit() { _log.NormalLog(string.Format("ModbusServerHanderTask:Init=>Initing")); try { _config = ReaderXMLUtil.ReadXMLConfig <ModbusServerConfig>("../../../../conf/Configuration.xml", ModbusServerConfig.ReadConfig, "setup", "ModbusTCPServerHandlerTask")[0]; if (_config.SignalListFilePath == "") { _log.ErrorLog("ModbusServerHanderTask Init fail: signal file path is null!"); return(false); } _workbook = XmlSerialiaztion.XmlDeserial <XMLWorkbook>(_config.SignalListFilePath, _log); if (_workbook == default(XMLWorkbook)) { _log.ErrorLog("ModbusServerHanderTask Init fail:Read signal file fail!"); return(false); } _points = PointsCollcetCreate.CreateMoudbus(_workbook, _log); ModbusPointsRegister.Register(_points, _log); _timeout = new TimeOut("ModbusServerHanderTask", _config.TimeOut, _log); _server = new ModbusTCPServer(new EthernetSetUp(_config.IpAddress, _config.Port), _timeout, _log, _config.MaxConnect, _config.SalveId, SocketServers.SocketServerType.SaeaServer); if (_server.Init()) { _log.NormalLog(string.Format("ModbusServerHanderTask:Initing=>Inited")); return(true); } else { return(false); } } catch (Exception e) { _log.ErrorLog(string.Format("ModbusServerHanderTask Init fail:{0}", e.Message)); return(false); } }