/***********************************************************************
Copyright (c) 2007-2010, AgileSC,Inc.China
All rights reserved.
************************************************************************/
package com.asc.das.webservice.impl;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.sql.Clob;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import org.codehaus.xfire.transport.http.XFireServletController;
import org.codehaus.xfire.util.Base64;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.hibernate.Hibernate;
import com.asc.dg.DataGatherManager;
import com.asc.dg.frame.sys.IFileManager;
import com.asc.das.orgmanager.bean.BaseDataProp;
import com.asc.das.orgmanager.bean.BaseDataType;
import com.asc.das.orgmanager.bean.BaseOrg;
import com.asc.das.orgmanager.bean.BaseOrgParam;
import com.asc.das.orgmanager.dao.BaseDataPropDao;
import com.asc.das.orgmanager.dao.BaseDataTypeDao;
import com.asc.das.orgmanager.dao.BaseOrgDao;
import com.asc.das.orgmanager.dao.BaseOrgParamDao;
import com.asc.das.sysmanager.bean.SysClientMonitor;
import com.asc.das.sysmanager.bean.SysSoftUpdateInfo;
import com.asc.das.sysmanager.bean.SysSoftVersion;
import com.asc.das.sysmanager.bean.SysUploadrec;
import com.asc.das.sysmanager.dao.SysClientMonitorDao;
import com.asc.das.sysmanager.dao.SysSoftUpdateInfoDao;
import com.asc.das.sysmanager.dao.SysSoftVersionDao;
import com.asc.das.sysmanager.dao.SysUploadrecDao;
import com.asc.das.sysmanager.service.MDGLoginService;
import com.asc.das.sysmanager.service.SoftUpgradeService;
import com.asc.das.webservice.IClientWebService;
import com.asc.das.webservice.MsgInfo;
import com.asc.sys.sysparam.dao.SysParamDao;
import com.asc.sys.user.bean.SysUser;
/**
* 对客户端的WebService接口
*
* @author Kevin A125
* @version v1.0.0 创建时间 2010-2-3 上午10:24:00
*/
public class ClientWebServiceImpl implements IClientWebService {
private static String LOGIN_FAIL_MSG = "login failed.";
private MDGLoginService MDGLoginService;
private SysUser currentUser;
private SysUploadrecDao sysUploadrecaDao;
private DataGatherManager dgManager;
private BaseOrgParamDao baseOrgParamDao;
private BaseDataTypeDao baseDataTypeDao;
private SysSoftUpdateInfoDao sysSoftUpdateInfoDao;
private SysSoftVersionDao softWareVersionDao;
private SoftUpgradeService softUpgradeService;
private SysParamDao sysParamDao;
private SysClientMonitorDao sysClientMonitorDao;
public void setMDGLoginService(MDGLoginService loginService) {
MDGLoginService = loginService;
}
public void setSysSoftUpdateInfoDao(
SysSoftUpdateInfoDao sysSoftUpdateInfoDao) {
this.sysSoftUpdateInfoDao = sysSoftUpdateInfoDao;
}
public void setSysUploadrecaDao(SysUploadrecDao sysUploadrecaDao) {
this.sysUploadrecaDao = sysUploadrecaDao;
}
public void setDgManager(DataGatherManager dgManager) {
this.dgManager = dgManager;
}
public void setBaseOrgParamDao(BaseOrgParamDao baseOrgParamDao) {
this.baseOrgParamDao = baseOrgParamDao;
}
public void setBaseDataTypeDao(BaseDataTypeDao baseDataTypeDao) {
this.baseDataTypeDao = baseDataTypeDao;
}
public void setSoftWareVersionDao(SysSoftVersionDao softWareVersionDao) {
this.softWareVersionDao = softWareVersionDao;
}
public void setSoftUpgradeService(SoftUpgradeService softUpgradeService) {
this.softUpgradeService = softUpgradeService;
}
public void setSysParamDao(SysParamDao sysParamDao) {
this.sysParamDao = sysParamDao;
}
public void setSysClientMonitorDao(SysClientMonitorDao sysClientMonitorDao) {
this.sysClientMonitorDao = sysClientMonitorDao;
}
public String callFunction(String params) {
MsgInfo inputMsg = null;
try {
inputMsg = new MsgInfo(params);
String username = inputMsg.getUserName();
String password = inputMsg.getPassword();
// 先登录
if (!login(username, password)) {
return failMsg(LOGIN_FAIL_MSG).toString();
}
// 判别功能,执行
if (IClientWebService.FUNC_LOGIN.equals(inputMsg.getFunction())) {
return doLogin(inputMsg).toString();
} else if (IClientWebService.FUNC_GET_PARAM.equals(inputMsg
.getFunction())) {
return doGetParam(inputMsg).toString();
} else if (IClientWebService.FUNC_GET_DATATYPEINFO.equals(inputMsg
.getFunction())) {
return doGetDataTypeInfo(inputMsg).toString();
} else if (IClientWebService.FUNC_UPLOAD_FILE.equals(inputMsg
.getFunction())) {
return doUploadFile(inputMsg).toString();
} else if (IClientWebService.FUNC_UPLOAD_NOTIFY.equals(inputMsg
.getFunction())) {
return doUploadNotify(inputMsg).toString();
} else if (IClientWebService.FUNC_UPLOAD_CONFIG.equals(inputMsg
.getFunction())) {
return doSetParam(inputMsg).toString();
} else if (IClientWebService.FUNC_LISTEN_CLIENT.equals(inputMsg
.getFunction())) {
return doGetClient(inputMsg).toString();
} else if (IClientWebService.FUNC_UPGRADE_FINISH.equals(inputMsg
.getFunction())) {
return doUpgradeFinish(inputMsg).toString();
} else {
return failMsg("the called function not exist.").toString();
}
}
catch (Exception e) {
inputMsg = null;
e.printStackTrace();
}
finally{
inputMsg = null;
}
return null;
}
/**
* 1,监听客户端是否还在运行,和客户端现在是不是需要升级 2,错误日志的上传
*
* @param inputMsg
* @return
*/
private MsgInfo doGetClient(MsgInfo inputMsg) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
MsgInfo outMsg = new MsgInfo("");
Date date = new Date();
String version = "";
List<String[]> paramList = inputMsg.getParamList();
for (int i = 0; i < paramList.size(); i++) {
String[] tempArray = paramList.get(i);
if ("version".equals(tempArray[0])) {
version = tempArray[1];
}
}
//记录客户端监控消息
try{
SysClientMonitor scm = new SysClientMonitor();
scm.setBaseOrg(this.currentUser.getBaseOrg());
scm.setSysUser(this.currentUser);
scm.setMonitorTime(new Date());
sysClientMonitorDao.save(scm);
}catch (Exception e){
e.printStackTrace();
}
//客户端监控
String address = XFireServletController.getRequest().getHeader("X-Forwarded-For");
if (address == null || isIpAddress(address)) {
address = XFireServletController.getRequest().getRemoteAddr();
}
BaseOrgParam orgParam = baseOrgParamDao.get(this.currentUser.getBaseOrg().getOrgId());
orgParam.setLastrefreshtime(date);
orgParam.setClientIpAddr(address);
orgParam.setClientVersion(version);
baseOrgParamDao.update(orgParam);
//获取升级信息
try {
SysSoftVersion sysSoftVersion =softUpgradeService.upgradeSofrVersion(orgParam.getOrgId(), version);
if(null!=sysSoftVersion){
String softFtp=sysParamDao.getSysUpgradeSoftFtp();
String fTPaddress="";
String username="";
String password="";
if(null!=softFtp&&!("".equals(softFtp))){
String []arrayTemp=softFtp.split(";");
if(null!=arrayTemp&&!("".equals(arrayTemp))){
String temp="";
for(int i=0;i<arrayTemp.length;i++){
temp=arrayTemp[i];
if(null!=temp&&!("".equals(temp))){
if(temp.startsWith("fTPaddress=")){
fTPaddress=temp.split("fTPaddress=")[1];
}
if(temp.startsWith("username=")){
username=temp.split("username=")[1];
}
if(temp.startsWith("password=")){
password=temp.split("password=")[1];
}
}
}
}
}
List<String[]> outparamList = new ArrayList<String[]>();
outparamList.add(new String[] { "FTPaddress", fTPaddress});
outparamList.add(new String[] { "username", username});
outparamList.add(new String[] { "password", password });
outMsg.setOtherReturnParam(outparamList);
outMsg.setResult(true);
}else{
outMsg.setResult(false);
return outMsg;
}
} catch (Exception e) {
e.printStackTrace();
return failMsg("get upgradeinfo fail.");
}
return outMsg;
}
/**
* 进行系统登录,每个服务都要先登录,才能使用
*
* @param username
* @param password
* @return
*/
private boolean login(String username, String password) {
SysUser user = MDGLoginService.checkAuthUser(username, password);
if (user != null) {
this.currentUser = user;
return true;
}
return false;
}
/**
* 返回失败消息
*
* @return
*/
private MsgInfo failMsg(String sMsg) {
MsgInfo msg = new MsgInfo("");
msg.setResult(false);
msg.setErrMsg(sMsg);
return msg;
}
private MsgInfo succSimpleMsg() {
MsgInfo msg = new MsgInfo("");
msg.setResult(true);
return msg;
}
/**
* 系统登录服务
*
* @param msg
* 消息对象
* @return
*/
private MsgInfo doLogin(MsgInfo msg) {
MsgInfo outMsg = new MsgInfo("");
outMsg.setResult(true);
List<String[]> paramList = new ArrayList<String[]>();
paramList.add(new String[] { "orgcode",
this.currentUser.getBaseOrg().getAscCode() });
paramList.add(new String[] { "orgname",
this.currentUser.getBaseOrg().getOrgName() });
outMsg.setOtherReturnParam(paramList);
return outMsg;
}
/**
* 获取系统配置服务
*
* @param msg
* @return
*/
private MsgInfo doGetParam(MsgInfo msg) {
MsgInfo outMsg = new MsgInfo("");
String dgParam = "";
try {
BaseOrgParam param = baseOrgParamDao.get(this.currentUser.getBaseOrg().getOrgId());
//在客户端未设置一对多时,默认使用配置文件中的第一个作为配置
// List<BaseCollectParam> collectParams = param.getParams();
// collectParams.get(0).getDgParams();
Clob clob = param.getDgParams();
dgParam = clob.getSubString(1, (int) clob.length());
} catch (Exception e) {
e.printStackTrace();
return failMsg("get param from database fail.");
}
if(dgParam == null){
dgParam="";
}
Document doc = null;
try {
doc = DocumentHelper.parseText(dgParam);
doc.setXMLEncoding("GBK");
} catch (Exception e) {
e.printStackTrace();
return failMsg("set xml encoding fail.");
}
// outMsg.setResult(true);
// outMsg.setData(new String(Base64.decode(dgParam)));
//System.out.println(doc.asXML());
outMsg.sMsg.append(doc.asXML());
return outMsg;
}
/**
* 设置系统配置
*
* @param msg
* @return
*/
private MsgInfo doSetParam(MsgInfo msg) {
MsgInfo outMsg = new MsgInfo("");
String data = null;
try {
List<String[]> paramList = msg.getParamList();
for (int i = 0; i < paramList.size(); i++) {
String[] tempArray = paramList.get(i);
if ("data".equals(tempArray[0])) {
data = new String(Base64.decode(tempArray[1]));
}
}
} catch (Exception e) {
e.printStackTrace();
return failMsg("parse uploadconfig pamameter fail.");
}
BaseOrgParam param = baseOrgParamDao.get(this.currentUser.getBaseOrg().getOrgId());
Clob xmlParam = Hibernate.createClob(data);
//在客户端未设置一对多时,默认使用配置文件中的第一个作为配置
// BaseCollectParam collectParam = param.getParams().get(0);
// collectParam.setDgParams(xmlParam);
param.setDgParams(xmlParam);
baseOrgParamDao.saveOrUpdate(param);
return outMsg;
}
/**
* 获取数据映射配置服务
*
* @param msg
* @return
*/
private MsgInfo doGetDataTypeInfo(MsgInfo msg) {
MsgInfo outMsg = new MsgInfo("");
Document doc = DocumentHelper.createDocument();
Element root = doc.addElement("datatypes");
String sql = " select to_char(c.ct_id), to_char(a.datatype_id), a.datatype_name, a.datatype_code, b.prefix,"
+ " to_char(d.prop_id), d.prop_name, d.prop_code, to_char(d.isrequred), to_char(d.key_prop), to_char(d.timestamp_prop)"
+ " from base_datatype a, base_org b, base_collect_param c, base_dataprop d"
+ " where a.org_id = b.org_id and b.org_id = c.ct_id and a.datatype_id = d.datatype_id "
+ " and c.org_id = " + this.currentUser.getBaseOrg().getOrgId()
+ " order by c.ct_id, a.datatype_id, d.prop_id";
List<Object[]> list = baseDataTypeDao.findBySql(sql);
if (list != null && list.size() > 0) {
Object[] ObjArr = null;
Element eDataType = null;
Element ePropsType = null;
String currDataTypeId = "-1";
String lastDataTypeId = "-1";
String idProp = "";
String timeProp = "";
for(int i = 0; i < list.size(); i++){
ObjArr = list.get(i);
currDataTypeId = (String)ObjArr[1];
if(!currDataTypeId.equals(lastDataTypeId)){
if(!"-1".equals(lastDataTypeId)){
Element eId = eDataType.addElement("idprop");
eId.setText(idProp);
Element eStamp = eDataType.addElement("timestampprop");
eStamp.setText(timeProp);
}
eDataType = root.addElement("datatype");
eDataType.addAttribute("name", (String)ObjArr[3]);
eDataType.addAttribute("displayname", (String)ObjArr[2]);
eDataType.addAttribute("code", (String)ObjArr[4]);
ePropsType = eDataType.addElement("props");
}
Element ePropType = null;
ePropType = ePropsType.addElement("prop");
ePropType.addAttribute("name", (String)ObjArr[7]);
ePropType.addAttribute("displayname", (String)ObjArr[6]);
if("1".equals((String)ObjArr[8])){
ePropType.addAttribute("required", "true");
}
if("1".equals((String)ObjArr[9])){
idProp = (String)ObjArr[7];
}
if("1".equals((String)ObjArr[10])){
timeProp = (String)ObjArr[7];
}
lastDataTypeId = currDataTypeId;
}
Element eId = eDataType.addElement("idprop");
eId.setText(idProp);
Element eStamp = eDataType.addElement("timestampprop");
eStamp.setText(timeProp);
}
doc.setXMLEncoding("GBK");
// outMsg.setResult(true);
// outMsg.setData(doc.asXML());
//System.out.println(doc.asXML());
outMsg.sMsg.append(doc.asXML());
return outMsg;
}
/**
* 上传文件服务
*
* @param msg
* @return
*/
private MsgInfo doUploadFile(MsgInfo msg) {
String data = null;
String filename = null;
String filesize = null;
String iscrypt = null;
String iszip = null;
String appname = null;
String orgcode = null;
String md5 = null;
try {
List<String[]> paramList = msg.getParamList();
for (int i = 0; i < paramList.size(); i++) {
String[] tempArray = paramList.get(i);
if ("data".equals(tempArray[0])) {
data = tempArray[1];
}
if ("filename".equals(tempArray[0])) {
filename = tempArray[1];
}
if ("filesize".equals(tempArray[0])) {
filesize = tempArray[1];
}
if ("iscrypt".equals(tempArray[0])) {
iscrypt = tempArray[1];
}
if ("iszip".equals(tempArray[0])) {
iszip = tempArray[1];
}
if ("appname".equals(tempArray[0])) {
appname = tempArray[1];
}
if ("orgcode".equals(tempArray[0])) {
orgcode = tempArray[1];
}
if ("md5".equals(tempArray[0])) {
md5 = tempArray[1];
}
}
} catch (Exception e) {
e.printStackTrace();
return failMsg("parse uploadfile pamameter fail.");
}
// 判断文件大小是否正确
if (filesize != null && !"".equals(filesize)) {
if (Integer.parseInt(filesize) != Base64.decode(data).length) {
return failMsg("the size of file is different from the parameter filesize");
}
}
long orgid = this.currentUser.getBaseOrg().getOrgId();
byte[] unzipTemp = null;
byte[] decryptTemp = null;
IFileManager fileManager = dgManager.getFileManager();
try {
// 解密
if (iscrypt.equals(IClientWebService.ENCRYPT)) {
SecretKeySpec skeySpec = new SecretKeySpec("AgilesClientLons"
.getBytes(), "AES");
// System.out.println(skeySpec.getEncoded().length);
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
decryptTemp = cipher.doFinal(Base64.decode(data));
} else {
decryptTemp = Base64.decode(data);
}
// 解压
if (iszip.equals(IClientWebService.ZIP)) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipInputStream zis = new ZipInputStream(
new ByteArrayInputStream(decryptTemp));
ZipEntry zip = zis.getNextEntry();
byte[] buff = new byte[1024];
String name = null;
while (zip != null) {
name = zip.getName();
int len = 0;
while ((len = zis.read(buff)) != -1) {
baos.write(buff, 0, len);
}
zis.read(buff, 0, zis.available());
fileManager.addWebServiceData(orgid, name, baos
.toByteArray(), appname, true);
zip = zis.getNextEntry();
}
} else {
unzipTemp = decryptTemp;
fileManager.addWebServiceData(orgid, filename, unzipTemp,
appname, true);
}
} catch (Exception e) {
e.printStackTrace();
return failMsg("upload file fail.");
}
return succSimpleMsg();
}
/**
* 上传日志服务
*
* @param msg
* @return
* @throws ParseException
*/
private MsgInfo doUploadNotify(MsgInfo msg) {
String action = null;
String actionresult = null;
String filename = null;
String md5 = null;
String uploadtype = null;
String localtime = null;
String filesize = null;
SimpleDateFormat Formator = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
List<SysUploadrec> recList = null;
SysUploadrec rec = null;
BaseOrg baseOrg = null;
try {
List<String[]> paramList = msg.getParamList();
for (int i = 0; i < paramList.size(); i++) {
String[] tempArray = paramList.get(i);
if ("action".equals(tempArray[0])) {
action = tempArray[1];
}
if ("actionresult".equals(tempArray[0])) {
actionresult = tempArray[1];
}
if ("filename".equals(tempArray[0])) {
filename = tempArray[1];
}
if ("md5".equals(tempArray[0])) {
md5 = tempArray[1];
}
if ("uploadtype".equals(tempArray[0])) {
uploadtype = tempArray[1];
}
if ("localtime".equals(tempArray[0])) {
localtime = tempArray[1];
}
if ("filesize".equals(tempArray[0])) {
filesize = tempArray[1];
}
}
} catch (Exception e) {
e.printStackTrace();
return failMsg("parse uploadnotify pamameter fail.");
}
try {
if (IClientWebService.ACTION_BEGIN.equals(action)) {
rec = new SysUploadrec();
rec.setSellOrg(this.currentUser.getBaseOrg());
rec.setSysUser(this.currentUser);
rec.setUploaddate(new Date());
rec.setFilename(filename);
rec.setChannel(uploadtype);
rec.setMd5(md5);
rec.setBegintime(new Date());
rec.setLocalbegintime(Formator.parse(localtime));
rec.setUploadstate(Long.parseLong(actionresult));
rec.setUploadtimes(0L);
sysUploadrecaDao.save(rec);
} else {
recList = sysUploadrecaDao.find(
"from SysUploadrec o where o.sellOrg = ? and o.sysUser=? and o.md5 = ? order by o.uploaddate desc",
new Object[] { this.currentUser.getBaseOrg(), this.currentUser, md5 });
if (recList != null && recList.size() > 0) {
rec = recList.get(0);
rec.setFilesize(Long.parseLong(filesize));
rec.setLocalendtime(Formator.parse(localtime));
rec.setUploadstate(Long.parseLong(actionresult));
if(IClientWebService.ACTION_RETRY.endsWith(action)){
rec.setUploadtimes(rec.getUploadtimes() + 1);
}
if (IClientWebService.ACTION_END.endsWith(action)) {
rec.setEndtime(new Date());
}
sysUploadrecaDao.update(rec);
}
}
} catch (Exception e) {
e.printStackTrace();
return failMsg("Add upload log to database fail.");
}
return succSimpleMsg();
}
/**
* 升级状态通知
*
* @param msg
* @return
* @throws ParseException
*/
private MsgInfo doUpgradeFinish(MsgInfo msg) {
String success = null;
try {
List<String[]> paramList = msg.getParamList();
for (int i = 0; i < paramList.size(); i++) {
String[] tempArray = paramList.get(i);
if ("success".equals(tempArray[0])) {
success = tempArray[1];
}
}
} catch (Exception e) {
e.printStackTrace();
return failMsg("parse upgradefinish pamameter fail.");
}
try{
SysSoftVersion softVersion = softWareVersionDao.getNewVersion();
if(softVersion != null){
SysSoftUpdateInfo sysSoftUpdateInfo = sysSoftUpdateInfoDao.getByVersionAndOrg(
this.currentUser.getBaseOrg().getOrgId(), softVersion.getId());
if(null!=sysSoftUpdateInfo){
if(RESULT_SUCCESS.equals(success)){
sysSoftUpdateInfo.setUpgradeSuccTime(new Date());
sysSoftUpdateInfo.setStatus(2L);
sysSoftUpdateInfoDao.update(sysSoftUpdateInfo);
BaseOrgParam orgParam = baseOrgParamDao.get(this.currentUser.getBaseOrg().getOrgId());
orgParam.setClientVersion(softVersion.getVersion());
baseOrgParamDao.update(orgParam);
}
sysSoftUpdateInfoDao.update(sysSoftUpdateInfo);
}
}
} catch (Exception e) {
e.printStackTrace();
return failMsg("notify upgradefinish fail.");
}
return succSimpleMsg();
}
public static Boolean isIpAddress(String s){
String regex = "(((2[0-4]\\d)|(25[0-5]))|(1\\d{2})|([1-9]\\d)|(\\d))[.](((2[0-4]\\d)|(25[0-5]))|(1\\d{2})|([1-9]\\d)|(\\d))[.](((2[0-4]\\d)|(25[0-5]))|(1\\d{2})|([1-9]\\d)|(\\d))[.](((2[0-4]\\d)|(25[0-5]))|(1\\d{2})|([1-9]\\d)|(\\d))";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(s);
return m.matches();
}
}
分享到:
相关推荐
安装步骤: 1.逍遥商城系统需要PHP+mysql运行环境,可以在windows或linux下运行,具体的php和mysql的版本没有特殊要求,兼容范围还是比较广的,推荐php5.6以上,mysql5.0以上。 2.把文件夹所有文件解压缩在站点目录中, 2.执行http://127.0.0.1/install/index.php进行安装 3.安装完成后,把install目录删掉。
wordpress可视化数据采集Scrapes插件,WP博客网站自动采集发布 支持 PHP7.4,PHP8.0 及以上不支持 上传插件到 wp-content/plugins 目录,然后解压 不需要写采集规则,傻瓜式操作,只需要对方的网址域名,在后台动动鼠标即可。
STM32F103使用NRF2401通过ACK响应双向通讯(HAL库) 简单的应用。
Libmodbus 是一个用于 Modbus 协议的开源库,提供了丰富的函数接口,可方便实现设备间的 Modbus 通信,支持多种平台,能轻松移植到不同系统中,有助于开发人员快速构建 Modbus 相关应用程序。我已编译好windows x86 版本的dll
内容概要:本文详细介绍了LabVIEW在汽车EPS转向器海纳传感器标定中的应用,重点探讨了如何通过LabVIEW解决传统标定方法中存在的数据采集实时性不足、标定过程缺乏自动化、数据分析难度大的问题。文中展示了具体的代码实现,包括数据采集、分析、校准和报告生成等功能模块,并通过实际案例展示了该系统的高效性和准确性。此外,文章还讨论了一些常见的调试问题及其解决方案,如通信握手逻辑、信号异常检测、温度补偿等。 适合人群:从事汽车电子、传感器标定及相关领域的工程师和技术人员。 使用场景及目标:适用于需要提高传感器标定效率和精度的企业和个人。目标是通过LabVIEW的应用,实现传感器标定的自动化和智能化,从而提升产品质量和生产效率。 其他说明:文章强调了LabVIEW在处理复杂标定任务中的灵活性和强大功能,提供了多个实用的技术细节和实践经验,对于希望深入了解LabVIEW在工业应用中的开发者非常有价值。
内容概要:本文深入探讨了Simulink If模块在嵌入式系统开发中的强大功能,特别是在汽车电子和工业自动化领域的应用。主要介绍了两种核心技术:一是DBC文件的自动导入生成模型及代码,二是硬件信号的导入生成模型及代码。DBC文件的自动导入能够快速构建CAN总线通信模型,简化信号解析和报文处理,生成的代码可以直接应用于AUTOSAR架构,实现ASW和BSW的无缝对接。硬件信号导入功能则允许开发者轻松地将硬件设备产生的信号集成到Simulink模型中,自动生成带有滤波和其他预处理功能的代码,适用于实时数据采集和控制算法实现。 适合人群:从事嵌入式系统开发、汽车电子、工业自动化等相关领域的工程师和技术人员。 使用场景及目标:① 快速搭建基于DBC文件的CAN总线通信模型,提高开发效率;② 实现硬件信号的实时处理和控制,优化数据采集和信号处理流程;③ 自动生成符合AUTOSAR标准的高质量代码,减少手动编码错误。 其他说明:文中提供了多个Matlab代码示例,展示了具体的操作步骤和生成代码的结构,帮助读者更好地理解和应用这些功能。同时,文中还分享了一些实用技巧,如DBC文件的功能模块拆分、硬件信号的时间戳对齐以及代码生成的优化设置等。
流变学仿真方法:流变学仿真参数设置.zip
内容概要:本文详细介绍了0-1背包问题的两种动态规划解法,包括二维DP数组和优化后的一维滚动DP数组方法。首先定义了最大物品数量和背包容量等常量,接着通过两个数组分别存储每个物品的重量和价值。文中给出的代码实现了完整的算法逻辑:初始化边界条件,迭代更新状态转移方程,最终计算出能够放入背包的最大价值。此外还提供了回溯功能,可以找出具体的最优解组合。为了提高空间效率,文章进一步解释了一维滚动数组的使用方法,并附有完整的C++代码实现。 适合人群:计算机科学专业学生或有一定编程基础、对算法设计与分析感兴趣的读者。 使用场景及目标:①学习经典的动态规划问题解决思路;②理解如何通过状态转移方程来优化复杂度;③掌握二维DP向一维DP转换的技术手段以节省内存开销。 阅读建议:建议读者先理解0-1背包问题的基本概念,再逐步深入研究两种不同的解法,注意对比两者之间的异同点,特别是空间复杂度方面的改进。同时可以通过修改输入数据来测试不同情况下的运行结果,加深对算法的理解。
该资源为natsort-3.0.0.tar.gz,欢迎下载使用哦!
内容概要:本文详细介绍了求解一维抛物热传导方程的各种经典数值方法,包括显式欧拉法、隐式欧拉法、Crank-Nicolson格式(即梯形公式)、二阶BDF格式以及不同的差分格式(如五点差分、九点差分和紧差分)。每种方法不仅给出了理论公式的推导,还提供了完整的MATLAB源码实现,并附有详细的代码解释和数值例子的数据图解分析。通过对不同方法的比较,展示了它们在稳定性和精度方面的优劣。 适合人群:具备一定数学和编程基础的学生、科研人员及工程师。 使用场景及目标:适用于需要解决热传导问题的研究项目,帮助使用者理解并选择合适的数值方法进行仿真计算,优化求解过程。 其他说明:文中强调了边界条件处理的重要性,并建议初学者从简单的Dirichlet边界条件入手练习。此外,还提到了一些常见的陷阱,如MATLAB矩阵索引与物理空间坐标的错位问题,提醒开发者注意这些问题以确保正确性。
一个人的经历信息和个人简介
内容概要:本文详细介绍了三菱FX3U PLC的圆弧插补程序,涵盖从中断扫描初始化、U型插补主程序、移动控制函数到急停复位程序的具体实现方法。通过具体的代码示例,展示了如何利用U型插补指令和服务调用来实现精确的圆弧轨迹控制。此外,文中还讨论了插补过程中的一些关键技术点,如中断优先级设置、插补结果存储、角度参数设置以及误差补偿等。同时,提供了关于脉冲输出、坐标计算和方向控制的实际操作技巧,强调了脉冲当量换算的重要性,并分享了一些调试经验和注意事项。 适合人群:从事工业自动化、运动控制领域的工程师和技术人员,特别是那些对PLC编程有一定基础并希望深入了解三菱FX3U PLC圆弧插补功能的人群。 使用场景及目标:适用于需要进行高精度圆弧轨迹控制的应用场景,如CNC控制系统、机器人运动控制等。目标是帮助读者掌握三菱FX3U PLC的圆弧插补编程技能,提高其在实际项目中的应用能力。 其他说明:文中提供的程序实例不仅有助于理解三菱FX3U PLC的工作原理,还能作为实际项目的参考模板。建议读者在实践中不断优化和完善相关程序,以适应不同的应用场景。
内容概要:本文详细介绍了在一个60吨/小时的反渗透+混床纯水项目中,如何利用西门子200 Smart PLC和Smart Line触摸屏进行系统设计与优化。主要内容涵盖硬件架构搭建(如CPU SR40、AI模块、TM模块)、模拟量处理(如电导率、压力、流量等信号的采集与转换)、数据滤波(如滑动平均值算法)、时钟同步(如自动和手动校准)、用户权限管理(如多级权限设置)、报警处理(如状态位轮询和异或运算)以及混床再生控制(如PID指令和状态机编程)。此外,还涉及了一些实用技巧,如数据追溯功能、报警弹窗中的应急处置指引、隐藏的debug模式等。 适合人群:从事工业自动化控制领域的工程师和技术人员,尤其是熟悉西门子PLC和触摸屏编程的人群。 使用场景及目标:适用于需要深入了解和掌握西门子200 Smart PLC在水处理项目中的具体应用和优化方法的专业人士。目标是提高系统稳定性、可靠性和易用性,确保水处理过程高效、精准地运行。 其他说明:文中提供了大量具体的程序代码片段和实践经验分享,对于实际项目实施具有很高的参考价值。同时,作者强调了细节处理的重要性,如模拟量的精确转换、报警系统的完善设计等,这些都是保障系统正常运行的关键因素。
找了一大圈终于找到了,有些e xing博主发的还有密码和要米,本资源真实可用
增压转换器和涡轮机的功率为1千瓦。它们适合风速高达12 m/s。涡轮机参考旋转速度150转/分
卷积神经网络(CNN)项目源码-基于CNN的行为姿态识别代码
jspm酒店客房预定管理系统
内容概要:本文详细介绍了如何利用西门子博途(TIA Portal)平台,在HMI(人机界面)中实现高效的IO状态监控和动态页面切换。主要内容包括:PLC端使用SCL语言创建结构化IO状态数组并进行动态更新;HMI端通过下拉菜单和动态绑定技术实现单页多设备IO状态的快速切换。文中还提供了具体的代码示例和技术细节,如符号寻址的应用、数组索引的注意事项以及常见的错误规避方法。 适合人群:从事工业自动化控制系统开发的技术人员,特别是熟悉西门子PLC编程和HMI开发的工程师。 使用场景及目标:适用于需要对多个设备或模块进行集中监控的工业现场,能够显著减少HMI画面制作时间和维护成本,提高系统的灵活性和可扩展性。 其他说明:文中提到的方法已在实际项目中得到验证,特别是在处理大量IO点的情况下表现出色。同时强调了良好的架构设计对于系统长期维护的重要性。
内容概要:本文详细介绍了MATLAB在图像检索领域的多种方法和技术,包括词袋模型、颜色特征、形状特征、Hu不变矩和LBP纹理特征。通过具体的代码实例,展示了如何利用这些方法进行图像特征提取和相似度计算。词袋模型借鉴文本处理思想,通过SIFT特征和聚类构建视觉词典;颜色特征主要通过颜色直方图表示图像颜色分布;形状特征则利用Hu不变矩实现平移、旋转和尺度不变性;LBP纹理特征用于描述图像的局部纹理信息。每种方法都有其独特的应用场景和优势。 适合人群:从事图像处理、计算机视觉研究的技术人员,尤其是有一定MATLAB基础的研究人员和开发者。 使用场景及目标:适用于需要高效、精确图像检索的场合,如商品搜索、医学影像分析、安防监控等领域。通过掌握这些方法,能够提高图像检索的速度和准确性,满足不同业务需求。 其他说明:文中不仅提供了详细的理论解释,还附带了大量实用的MATLAB代码片段,帮助读者快速理解和应用这些技术。同时强调了在实际应用中选择合适特征组合的重要性,避免过度依赖单一算法。
内容概要:本文详细介绍了如何使用STC15W104单片机实现2262/1527编码的无线遥控解码器。该解码器具备自动学习遥控器编码、掉电记忆数据以及四路输出控制的功能。硬件方面,P3.2连接315M接收模块,P5.4-P5.7作为输出接口,使用片内EEPROM进行数据存储。软件部分涵盖了定时器配置、中断处理、解码状态机的设计以及EEPROM的操作方法。文中还分享了一些实用的经验和注意事项,如接收模块的上拉电阻设置、学习模式的按键防抖处理等。 适合人群:具有一定单片机开发经验的技术人员,尤其是对无线遥控解码感兴趣的开发者。 使用场景及目标:适用于需要将传统2262/1527编码遥控器集成到智能家居系统或其他自动化控制系统中的场合。主要目标是提供一种低成本、高性能的解决方案,能够稳定可靠地解码并响应多种类型的遥控信号。 其他说明:文中提供了完整的代码片段和技术细节,帮助读者更好地理解和实现相关功能。此外,作者还提到了一些常见的陷阱和优化建议,有助于提高系统的稳定性和兼容性。