- 浏览: 24015 次
- 性别:
- 来自: 苏州
-
文章分类
最新评论
-
sanyaocun000:
你好,按照您的做法,到时可以的会转到客户端的登录界面,可为什么 ...
CAS Server 3.5.1 之自定义登录页 -
sunrui0451:
为什么按你配置的会,跳到cas页的login页里呢?
CAS Server 3.5.1 之自定义登录页 -
afeifqh:
我的也可以获取lt。但是服务端发布到服务器上cas用https ...
CAS Server 3.5.1 之自定义登录页 -
fangxia123:
你好,我按照您说的做了,后台数据get-lt::::true都 ...
CAS Server 3.5.1 之自定义登录页 -
fangxia123:
你好,我按照您说的做了,后台数据get-lt::::true都 ...
CAS Server 3.5.1 之自定义登录页
参考http://denger.iteye.com/blog/809170
参考https://wiki.jasig.org/display/CAS/Using+CAS+without+the+Login+Screen
做如下修改
1.修改ProvideLoginTicketAction类 增加 lt 参数
2.CAS的XML配置文件 cas-servlet.xml
3.修改跳转页面 viewRedirectToRequestor.jsp
4.web-flow.xml修改
5.修改AuthenticationViaFormAction类,可以修改源码,也可以Spring进cas-servlet.xml ,修改位置见下面代码
6.default_views.properties修改
增加自定义的跳转页面
修改增加 <transition on="errorForRemoteRequestor" to="viewRedirectToRequestor" />
工具类:
参考https://wiki.jasig.org/display/CAS/Using+CAS+without+the+Login+Screen
做如下修改
1.修改ProvideLoginTicketAction类 增加 lt 参数
2.CAS的XML配置文件 cas-servlet.xml
3.修改跳转页面 viewRedirectToRequestor.jsp
4.web-flow.xml修改
5.修改AuthenticationViaFormAction类,可以修改源码,也可以Spring进cas-servlet.xml ,修改位置见下面代码
6.default_views.properties修改
<bean id="provideLoginTicketAction" class="com.woniu.cas.ProvideLoginTicketAction" p:ticketIdGenerator-ref="loginTicketUniqueIdGenerator"/>
package com.woniu.cas; import javax.servlet.http.HttpServletRequest; import javax.validation.constraints.NotNull; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jasig.cas.CentralAuthenticationService; import org.jasig.cas.authentication.principal.Service; import org.jasig.cas.ticket.TicketException; import org.jasig.cas.util.UniqueTicketIdGenerator; import org.jasig.cas.web.support.WebUtils; import org.springframework.webflow.action.AbstractAction; import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.RequestContext; /** * * * */ public class ProvideLoginTicketAction extends AbstractAction{ /** 3.5.1 - Login tickets SHOULD begin with characters "LT-" */ private static final String PREFIX = "LT"; /** Logger instance */ private final Log logger = LogFactory.getLog(getClass()); @NotNull private UniqueTicketIdGenerator ticketIdGenerator; public final String generate(final RequestContext context) { final String loginTicket = this.ticketIdGenerator.getNewTicketId(PREFIX); this.logger.debug("Generated login ticket " + loginTicket); WebUtils.putLoginTicket(context, loginTicket); return "generated"; } public void setTicketIdGenerator(final UniqueTicketIdGenerator generator) { this.ticketIdGenerator = generator; } @Override protected Event doExecute(RequestContext context) throws Exception { final HttpServletRequest request = WebUtils.getHttpServletRequest(context); if (request.getParameter("get-lt") != null && request.getParameter("get-lt").equalsIgnoreCase("true")) { final String loginTicket = this.ticketIdGenerator.getNewTicketId(PREFIX); this.logger.debug("Generated login ticket " + loginTicket); WebUtils.putLoginTicket(context, loginTicket); return result("loginTicketRequested"); } return result("continue"); } }
<%@ page contentType="text/html; charset=UTF-8"%> <%@ page import="com.woniu.cas.CasUtility"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <% String separator = ""; // 需要输入 login-at 参数,当生成lt后或登录失败后则重新跳转至 原登录页,并传入参数 lt 和 error_message String referer = request.getParameter("login-at"); referer = CasUtility.resetUrl(referer); if (referer != null && referer.length() > 0) { separator = (referer.indexOf("?") > -1) ? "&" : "?"; %> <html> <title>cas get login ticket</title> <head> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script> var redirectURL = "<%=referer + separator%>lt=${loginTicket}&execution=${flowExecutionKey}"; alert(redirectURL); <spring:hasBindErrors name="credentials"> var errorMsg = '<c:forEach var="error" items="${errors.allErrors}"><spring:message code="${error.code}" text="${error.defaultMessage}" /></c:forEach>'; redirectURL += '&error_message=' + encodeURIComponent (errorMsg); </spring:hasBindErrors> window.location.href = redirectURL; </script> </head> <body></body> </html> <% } else { %> <script>window.location.href = "/member/login";</script> <% } %>
增加自定义的跳转页面
<action-state id="provideLoginTicket"> <evaluate expression="provideLoginTicketAction"/> <transition on="loginTicketRequested" to ="viewRedirectToRequestor" /> <transition on="continue" to="ticketGrantingTicketExistsCheck" /> </action-state> <view-state id="viewRedirectToRequestor" view="casRedirectToRequestorView" model="credentials"> <binder> <binding property="username" /> <binding property="password" /> </binder> <on-entry> <set name="viewScope.commandName" value="'credentials'" /> </on-entry> <transition on="submit" bind="true" validate="true" to="realSubmit"> <set name="flowScope.credentials" value="credentials" /> <evaluate expression="authenticationViaFormAction.doBind(flowRequestContext, flowScope.credentials)" /> </transition> </view-state>
修改增加 <transition on="errorForRemoteRequestor" to="viewRedirectToRequestor" />
<action-state id="realSubmit"> <evaluate expression="authenticationViaFormAction.submit(flowRequestContext, flowScope.credentials, messageContext)" /> <!-- To enable LPPE on the 'warn' replace the below transition with: <transition on="warn" to="passwordPolicyCheck" /> CAS will attempt to transition to the 'warn' when there's a 'renew' parameter and there exists a ticketGrantingId and a service for the incoming request. --> <transition on="warn" to="warn" /> <!-- To enable LPPE on the 'success' replace the below transition with: <transition on="success" to="passwordPolicyCheck" /> --> <transition on="success" to="sendTicketGrantingTicket" /> <transition on="error" to="generateLoginTicket" /> <transition on="errorForRemoteRequestor" to="viewRedirectToRequestor" /> <transition on="accountDisabled" to="casAccountDisabledView" /> <transition on="mustChangePassword" to="casMustChangePassView" /> <transition on="accountLocked" to="casAccountLockedView" /> <transition on="badHours" to="casBadHoursView" /> <transition on="badWorkstation" to="casBadWorkstationView" /> <transition on="passwordExpired" to="casExpiredPassView" /> </action-state>
package com.woniu.cas; /* * Licensed to Jasig under one or more contributor license * agreements. See the NOTICE file distributed with this work * for additional information regarding copyright ownership. * Jasig licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a * copy of the License at the following location: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import org.jasig.cas.CentralAuthenticationService; import org.jasig.cas.authentication.handler.AuthenticationException; import org.jasig.cas.authentication.principal.Credentials; import org.jasig.cas.authentication.principal.Service; import org.jasig.cas.ticket.TicketException; import org.jasig.cas.web.bind.CredentialsBinder; import org.jasig.cas.web.support.WebUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.binding.message.MessageBuilder; import org.springframework.binding.message.MessageContext; import org.springframework.util.StringUtils; import org.springframework.web.util.CookieGenerator; import org.springframework.webflow.execution.RequestContext; /** * Action to authenticate credentials and retrieve a TicketGrantingTicket for * those credentials. If there is a request for renew, then it also generates * the Service Ticket required. * * @author Scott Battaglia * @version $Revision$ $Date$ * @since 3.0.4 */ public class AuthenticationViaFormAction { /** * Binder that allows additional binding of form object beyond Spring * defaults. */ private CredentialsBinder credentialsBinder; /** Core we delegate to for handling all ticket related tasks. */ @NotNull private CentralAuthenticationService centralAuthenticationService; @NotNull private CookieGenerator warnCookieGenerator; protected Logger logger = LoggerFactory.getLogger(getClass()); public final void doBind(final RequestContext context, final Credentials credentials) throws Exception { final HttpServletRequest request = WebUtils.getHttpServletRequest(context); if (this.credentialsBinder != null && this.credentialsBinder.supports(credentials.getClass())) { this.credentialsBinder.bind(request, credentials); } } public final String submit(final RequestContext context, final Credentials credentials, final MessageContext messageContext) throws Exception { // Validate login ticket final String authoritativeLoginTicket = WebUtils.getLoginTicketFromFlowScope(context); final String providedLoginTicket = WebUtils.getLoginTicketFromRequest(context); System.out.println(authoritativeLoginTicket+","+providedLoginTicket); if (!authoritativeLoginTicket.equals(providedLoginTicket)) { System.out.println("providedLoginTicket ERROR"); this.logger.warn("Invalid login ticket " + providedLoginTicket); final String code = "INVALID_TICKET"; messageContext.addMessage( new MessageBuilder().error().code(code).arg(providedLoginTicket).defaultText(code).build()); return "error"; } final String ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context); final Service service = WebUtils.getService(context); if (StringUtils.hasText(context.getRequestParameters().get("renew")) && ticketGrantingTicketId != null && service != null) { try { final String serviceTicketId = this.centralAuthenticationService.grantServiceTicket(ticketGrantingTicketId, service, credentials); WebUtils.putServiceTicketInRequestScope(context, serviceTicketId); putWarnCookieIfRequestParameterPresent(context); return "warn"; } catch (final TicketException e) { if (isCauseAuthenticationException(e)) { populateErrorsInstance(e, messageContext); return getAuthenticationExceptionEventId(e); } this.centralAuthenticationService.destroyTicketGrantingTicket(ticketGrantingTicketId); if (logger.isDebugEnabled()) { logger.debug("Attempted to generate a ServiceTicket using renew=true with different credentials", e); } } } try { WebUtils.putTicketGrantingTicketInRequestScope(context, this.centralAuthenticationService.createTicketGrantingTicket(credentials)); putWarnCookieIfRequestParameterPresent(context); return "success"; } catch (final TicketException e) { populateErrorsInstance(e, messageContext); String referer = context.getRequestParameters().get("login-at"); if (!org.apache.commons.lang.StringUtils.isBlank(referer)) { System.out.println("errorForRemoteRequestor!!!!!!!!!!!!!!!!!!!"); return "errorForRemoteRequestor"; } return "error"; // if (isCauseAuthenticationException(e)) // return getAuthenticationExceptionEventId(e); // return "error"; } } private void populateErrorsInstance(final TicketException e, final MessageContext messageContext) { System.out.println("populateErrorsInstance"); try { messageContext.addMessage(new MessageBuilder().error().code(e.getCode()).defaultText(e.getCode()).build()); } catch (final Exception fe) { logger.error(fe.getMessage(), fe); } } private void putWarnCookieIfRequestParameterPresent(final RequestContext context) { System.out.println("putWarnCookieIfRequestParameterPresent"); final HttpServletResponse response = WebUtils.getHttpServletResponse(context); if (StringUtils.hasText(context.getExternalContext().getRequestParameterMap().get("warn"))) { this.warnCookieGenerator.addCookie(response, "true"); } else { this.warnCookieGenerator.removeCookie(response); } } private AuthenticationException getAuthenticationExceptionAsCause(final TicketException e) { return (AuthenticationException) e.getCause(); } private String getAuthenticationExceptionEventId(final TicketException e) { final AuthenticationException authEx = getAuthenticationExceptionAsCause(e); if (this.logger.isDebugEnabled()) this.logger.debug("An authentication error has occurred. Returning the event id " + authEx.getType()); return authEx.getType(); } private boolean isCauseAuthenticationException(final TicketException e) { return e.getCause() != null && AuthenticationException.class.isAssignableFrom(e.getCause().getClass()); } public final void setCentralAuthenticationService(final CentralAuthenticationService centralAuthenticationService) { this.centralAuthenticationService = centralAuthenticationService; } /** * Set a CredentialsBinder for additional binding of the HttpServletRequest * to the Credentials instance, beyond our default binding of the * Credentials as a Form Object in Spring WebMVC parlance. By the time we * invoke this CredentialsBinder, we have already engaged in default binding * such that for each HttpServletRequest parameter, if there was a JavaBean * property of the Credentials implementation of the same name, we have set * that property to be the value of the corresponding request parameter. * This CredentialsBinder plugin point exists to allow consideration of * things other than HttpServletRequest parameters in populating the * Credentials (or more sophisticated consideration of the * HttpServletRequest parameters). * * @param credentialsBinder the credentials binder to set. */ public final void setCredentialsBinder(final CredentialsBinder credentialsBinder) { this.credentialsBinder = credentialsBinder; } public final void setWarnCookieGenerator(final CookieGenerator warnCookieGenerator) { this.warnCookieGenerator = warnCookieGenerator; } }
<bean id="authenticationViaFormAction" class=" com.woniu.cas.AuthenticationViaFormAction" p:centralAuthenticationService-ref="centralAuthenticationService" p:warnCookieGenerator-ref="warnCookieGenerator"/>
工具类:
package com.woniu.cas; public class CasUtility { /** * Removes the previously attached GET parameters "lt" and "error_message" * to be able to send new ones. * * @param casUrl * @return */ public static String resetUrl(String casUrl) { String cleanedUrl; String[] paramsToBeRemoved = new String[] { "lt", "error_message", "get-lt" }; cleanedUrl = removeHttpGetParameters(casUrl, paramsToBeRemoved); return cleanedUrl; } /** * Removes selected HTTP GET parameters from a given URL * * @param casUrl * @param paramsToBeRemoved * @return */ public static String removeHttpGetParameters(String casUrl, String[] paramsToBeRemoved) { String cleanedUrl = casUrl; if (casUrl != null) { // check if there is any query string at all if (casUrl.indexOf("?") == -1) { return casUrl; } else { // determine the start and end position of the parameters to be // removed int startPosition, endPosition; boolean containsOneOfTheUnwantedParams = false; for (String paramToBeErased : paramsToBeRemoved) { startPosition = -1; endPosition = -1; if (cleanedUrl.indexOf("?" + paramToBeErased + "=") > -1) { startPosition = cleanedUrl.indexOf("?" + paramToBeErased + "=") + 1; } else if (cleanedUrl.indexOf("&" + paramToBeErased + "=") > -1) { startPosition = cleanedUrl.indexOf("&" + paramToBeErased + "=") + 1; } if (startPosition > -1) { int temp = cleanedUrl.indexOf("&", startPosition); endPosition = (temp > -1) ? temp + 1 : cleanedUrl .length(); // remove that parameter, leaving the rest untouched cleanedUrl = cleanedUrl.substring(0, startPosition) + cleanedUrl.substring(endPosition); containsOneOfTheUnwantedParams = true; } } // wenn nur noch das Fragezeichen vom query string übrig oder am // schluss ein "&", dann auch dieses entfernen if (cleanedUrl.endsWith("?") || cleanedUrl.endsWith("&")) { cleanedUrl = cleanedUrl.substring(0, cleanedUrl.length() - 1); } // parameter mehrfach angegeben wurde... if (!containsOneOfTheUnwantedParams) return casUrl; else cleanedUrl = removeHttpGetParameters(cleanedUrl, paramsToBeRemoved); } } return cleanedUrl; } }
6.default_views.properties修改 ### Redirect with login ticket view casRedirectToRequestorView.(class)=org.springframework.web.servlet.view.JstlView casRedirectToRequestorView.url=/WEB-INF/view/jsp/default/ui/viewRedirectToRequestor.jsp
评论
5 楼
sanyaocun000
2013-11-18
你好,按照您的做法,到时可以的会转到客户端的登录界面,可为什么点击登录后跳转到认证服务器的登录页面呢?
4 楼
sunrui0451
2013-10-21
为什么按你配置的会,跳到cas页的login页里呢?
3 楼
afeifqh
2013-09-27
我的也可以获取lt。但是服务端发布到服务器上cas用https方式的时候,获取到lt,点击登录就跳转到了cas的默认登陆页去了。 但是在我本地开启as服务端却可以(本地采用http)。
不支持服务器用https方式么?
不支持服务器用https方式么?
2 楼
fangxia123
2013-03-15
你好,我按照您说的做了,后台数据get-lt::::true都可以获取到,lt也有值,可是在点登录按钮后却是跳转到cas的登录页面去了,这是为什么???

1 楼
fangxia123
2013-03-15
你好,我按照您说的做了,后台数据get-lt::::true都可以获取到,lt也有值,可是在点登录按钮后却是跳转到cas的登录页面去了,这是为什么???
相关推荐
首先,我们来看`cas-server-3.5.1`部分。这是CAS服务器端的核心组件,负责处理用户的认证请求和响应。3.5.1版本可能包含以下关键模块: 1. **Web应用程序**:基于Servlet的Web应用,运行在Tomcat、Jetty等Servlet...
这个"cas-server-3.5.1-release.zip"文件包含了CAS服务器3.5.1版本的源码、文档和其他相关资源,允许开发者进行定制化部署和扩展。 在CAS 3.5.1版本中,主要关注以下几个关键知识点: 1. **单一登录机制**:CAS的...
### Exchange Server 2010 安装及CAS服务器配置 #### 一、Exchange Server 2010 安装前的准备工作 在正式安装Exchange Server 2010之前,需要确保网络环境符合一定的标准,并对现有环境进行充分评估。 1. **评估...
陕西省2025年初中学业水平考试实验操作考试试题及评分细则.zip
内容概要:本文详细介绍了如何将Halcon与C#相结合进行机器视觉开发。首先解释了选择Halcon联合C#的原因,强调了两者的互补优势。接着通过多个具体案例展示了如何将Halcon的经典例子转化为C#代码,包括图像读取与显示、阈值分割、形状匹配、图像采集等方面的内容。文中还特别提到了一些常见问题及其解决方案,如内存管理、坐标系转换、线程安全等。此外,作者提供了许多实用技巧,如使用扩展方法处理Halcon的数据类型、封装相机操作类、优化异常处理等。最后,作者分享了一些实战经验,包括环境配置、性能优化、交互设计等方面的建议。 适合人群:具有一定C#编程基础,对机器视觉感兴趣的开发人员。 使用场景及目标:帮助C#开发人员更好地理解和掌握Halcon的使用方法,提高视觉开发效率,减少开发过程中的常见错误和技术难题。 其他说明:文中提供的所有案例代码均已整理在GitHub的HalconSharpToolkit项目中,按功能模块划分,便于学习和参考。
内容概要:本文详细介绍了西门子S7-1200 PLC在污水处理项目中的应用,涵盖模拟量处理、设备轮换、Modbus通讯以及事件记录等多个方面。文中展示了如何利用博途V17进行程序设计,包括具体的SCL代码实例,如液位检测的滑动窗口滤波法、提升泵的轮换逻辑、Modbus TCP对变频器的控制以及报警信息管理等。此外,还分享了一些实用技巧,如防止信号跳变、避免设备过度磨损、确保通讯稳定性和提高报警记录效率的方法。 适合人群:从事工业自动化领域的工程师和技术人员,尤其是熟悉西门子PLC和博途软件的从业者。 使用场景及目标:适用于污水处理项目的PLC编程和系统集成,旨在提高系统的稳定性和可靠性,减少维护成本并优化设备性能。 其他说明:文中不仅提供了详细的代码示例,还分享了许多来自实际项目的经验教训,帮助读者更好地理解和应用相关技术。
内容概要:本文详细介绍了改进的带约束粒子群算法(IPSO)在MATLAB环境下的实现细节。首先探讨了IPSO算法中接口设计的独特之处,即通过定义目标函数和约束条件的接口,使算法能够灵活应对不同类型的优化问题。接着阐述了非线性惯性权重和学习因子的设计理念,解释了它们如何帮助算法在搜索过程中更好地平衡全局探索和局部开发。最后讨论了基于MATLAB类编程的优势,强调了此类编程方式带来的代码复用性和维护便捷性。此外,文中还提供了丰富的代码片段作为示例,展示了IPSO算法的具体实现步骤。 适合人群:对优化算法感兴趣的科研人员、工程师以及希望深入了解粒子群算法并应用于实际项目的开发者。 使用场景及目标:适用于需要高效解决带有复杂约束条件的优化问题的场合,如工程设计、物流规划等领域。目标是利用IPSO算法更快地找到全局最优解,同时确保满足所有约束条件。 其他说明:文中不仅分享了理论知识,还包括了许多实用的编码技巧,有助于读者快速掌握IPSO算法的应用方法。
内容概要:本文介绍了一段基于分布式ADMM算法的MATLAB代码,用于电力系统优化调度,尤其关注碳排放交易的影响。代码首先对电力系统进行分区,接着构建DC-DOPF最优潮流问题,考虑碳排放交易的成本,并利用ADMM算法求解。文中详细解释了各个关键步骤,如系统分区、目标函数设计、碳排放交易成本计算以及ADMM算法的具体实现。此外,代码还包括了多种优化技术和实用技巧,如自适应惩罚因子调整、边界条件处理等,确保算法的有效性和实用性。 适用人群:适用于对电力系统优化调度感兴趣的科研人员、工程师和技术爱好者,尤其是希望深入了解分布式算法和碳排放交易机制的人群。 使用场景及目标:①研究电力系统优化调度的新方法和技术;②探讨碳排放交易对电力系统调度策略的影响;③提高电力系统运行效率和环保性能。 其他说明:代码不仅提供了详细的注释和模块化设计,还展示了丰富的可视化结果,便于理解和进一步研究。同时,文中提到了一些实际应用案例,证明了该方法的有效性和优越性。
内容概要:本文档是一份计算机软考初级程序员的经典面试题汇编,涵盖了面向对象编程的四大特征(抽象、继承、封装、多态),并详细探讨了Java编程中的诸多核心概念,如基本数据类型与引用类型的区别、String和StringBuffer的差异、异常处理机制、Servlet的生命周期及其与CGI的区别、集合框架中ArrayList、Vector和LinkedList的特性对比、EJB的实现技术及其不同Bean类型的区别、Collection和Collections的差异、final、finally和finalize的作用、线程同步与异步的区别、抽象类和接口的区别、垃圾回收机制、JSP和Servlet的工作原理及其异同等。此外,还介绍了WebLogic服务器的相关配置、EJB的激活机制、J2EE平台的构成和服务、常见的设计模式(如工厂模式)、Web容器和EJB容器的功能、JNDI、JMS、JTA等J2EE核心技术的概念。 适合人群:正在备考计算机软考初级程序员的考生,或希望加深对Java编程及Web开发理解的初、中级开发人员。 使用场景及目标:①帮助考生系统复习Java编程语言的基础知识和高级特性;②为实际项目开发提供理论指导,提升编程技能;③为面试准备提供参考,帮助求职者更好地应对技术面试。 其他说明:文档不仅涉及Java编程语言的核心知识点,还包括了Web开发、企业级应用开发等方面的技术要点,旨在全面提高读者的专业素养和技术水平。文档内容详实,适合有一定编程基础的学习者深入学习和研究。
Java常用API详解
基于python的智能网联车辆和人工驾驶车辆混合行驶异质交通流特性研究+源码,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用 基于python的智能网联车辆和人工驾驶车辆混合行驶异质交通流特性研究+源码,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用~ 基于python的智能网联车辆和人工驾驶车辆混合行驶异质交通流特性研究+源码,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用 基于python的智能网联车辆和人工驾驶车辆混合行驶异质交通流特性研究+源码,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用 基于python的智能网联车辆和人工驾驶车辆混合行驶异质交通流特性研究+源码,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用
计算机视觉微调 PyTorch 版
内容概要:本文深入研究了光储系统在弱电网环境下虚拟同步发电机(VSG)的稳定性问题。文章首先介绍了弱电网特性带来的挑战,如频率耦合导致的稳定性复杂化,并提出基于谐波状态空间(HSS)理论的多时间尺度VSG模型。通过构建8阶状态空间模型,作者详细分析了功率环、电压环和电流动态,并利用归一化参数灵敏度分析揭示了关键控制参数(如虚拟惯量J、虚拟阻尼Dp等)对系统稳定性的影响。此外,文中提供了详细的Python代码实现HSS建模、稳定性分析和参数灵敏度分析,最终在Matlab/Simulink平台上验证了模型的精确度。; 适用人群:电气工程领域的研究人员、研究生以及从事新能源发电系统设计和控制的工程师。; 使用场景及目标:①理解弱电网条件下光储-VSG系统的稳定性问题;②掌握基于HSS理论的建模方法;③学会通过特征值分析和参数灵敏度分析优化控制系统参数;④验证所提方法的有效性并应用于实际工程设计。; 其他说明:本文不仅提供了理论分析,还给出了详细的代码实现,便于读者复现实验结果。建议读者在学习过程中结合代码进行实践,并根据具体应用场景调整系统参数。此外,文中提出的模型和方法还可以进一步扩展到其他类型的电力电子系统中。
内容概要:本文详细介绍了利用MATLAB和CPLEX求解器实现的电热综合能源市场双层出清模型。该模型分为上下两层,上层旨在最大化能源集线器的收益,下层则致力于最小化电力和热力市场的生产和出清成本。文中不仅提供了详细的代码示例,还解释了各个模块的功能及其背后的理论依据,如MPEC(数学规划与均衡约束)、KKT条件的应用等。此外,文章强调了代码的模块化设计和良好的注释,使得新手能够轻松理解和修改代码。最终,通过与参考文献的对比,证明了模型的有效性和准确性。 适用人群:适用于对综合能源系统优化感兴趣的初学者和有一定经验的研究人员。 使用场景及目标:①帮助研究人员理解电热综合能源市场的运作机制;②为开发更复杂的能源市场模型提供基础;③通过实际案例和数据验证模型的正确性和实用性。 其他说明:文章还提到了一些高级应用和技术细节,如储能参数调整对市场策略的影响、极端天气条件下不同能源设备的表现差异等。
内容概要:本文详细介绍了霓虹灯广告屏PLC控制系统的完整设计与实现。系统由8根灯管和24只流水灯组成,能够实现灯管顺序点亮/熄灭(正序、反序)和流水灯组间隔点亮并移动的效果。设计涵盖了I/O分配、接线图设计、梯形图编程以及仿真调试。文章还提供了基于Python的代码模拟,通过多线程技术实现了灯管和流水灯的控制逻辑,展示了系统启动、停止、模式设置等功能。此外,文中给出了实际PLC编程的伪代码,强调了梯形图编程的关键步骤。 适合人群:具有一定电气工程或自动化控制基础的技术人员,特别是对PLC编程和霓虹灯控制系统感兴趣的工程师或学生。 使用场景及目标:①了解霓虹灯广告屏PLC控制系统的具体设计与实现;②掌握PLC编程的基本方法,包括梯形图编程和定时器、计数器的应用;③学习如何使用Python模拟PLC控制逻辑,帮助理解和测试控制系统的运行机制。 阅读建议:本文不仅提供了详细的理论设计,还包括具体的代码实现,建议读者在阅读过程中结合代码进行实践,理解每个控制逻辑的具体实现方式,并尝试修改参数或增加新功能来加深理解。
少儿编程scratch项目源代码文件案例素材-scratch 冲刺.zip
内容概要:本文档主要介绍了WebUI可视化的技术基础准备,涵盖HTML/CSS基础语法、JavaScript核心功能以及前后端交互原理。HTML部分讲解了文档的基本结构和常用标签,CSS部分则阐述了基础语法及其三种应用方式,JavaScript部分着重于基础概念和DOM操作。此外,文档还介绍了Python与前端的交互流程,以Flask框架为例展示了前后端通信的具体实现。最后,通过实操任务和个人简介页面、简单计算器的制作来巩固所学知识,并提供了常见错误排查的方法和学习进度自测题目。 适合人群:对Web开发感兴趣的初学者或有一定编程基础但缺乏Web开发经验的学习者。 使用场景及目标:①帮助读者掌握HTML/CSS/JavaScript的基础知识,能够独立创建简单的Web页面;②理解前后端交互机制,学会使用Flask搭建简单的后端服务并与前端进行数据交互;③通过实操练习提高实际动手能力,解决常见的开发问题。 其他说明:文档不仅提供了理论知识,还包含大量实例代码和实操任务,建议读者跟随文档逐步实践,遇到问题时可以参考常见错误排查部分,确保学习效果。同时,学习进度自测题目可以帮助读者检验自己的掌握程度,以便及时调整学习计划。
内容概要:本文详细介绍了如何使用Matlab/Simulink搭建七自由度车辆模型并加入主动悬架控制系统。七自由度车辆模型涵盖了车身在垂直、俯仰、侧倾方向的运动以及四个车轮的垂直运动。文中解释了模型的基础构成、主动悬架的作用机制、参数调整方法以及具体的实现步骤。此外,还提供了关于路面不平度信号生成、模型搭建、参数设置、主动控制算法(如PID和LQR)、仿真运行和结果可视化的具体指导。通过这种方式,研究人员可以更好地理解和优化车辆在复杂路况下的动态响应。 适合人群:汽车工程领域的研究人员和技术人员,特别是那些希望深入了解车辆动力学和主动悬架控制系统的专业人士。 使用场景及目标:适用于车辆动力学研究、新车型研发、底盘控制策略验证等场景。目标是提高车辆行驶的稳定性和乘坐舒适性,同时为车辆设计和性能优化提供支持。 其他说明:文中提到的模型在Matlab 2016a及以上版本中效果最佳,且强调了参数调整和仿真的重要性。通过实际案例展示了如何应对常见的仿真挑战,如代数环问题和数值不稳定情况。
项目资源包含:可运行源码+sql文件+; python3.8+django+mysql5.7+html+jieba+lxml+selenium 适用人群:学习不同技术领域的小白或进阶学习者;可作为课程设计、大作业、工程实训或初期项目立项。 第一步:创建数据库,数据库名:split_drug 第二步:执行SQL语句,打开split_drug.sql文件,运行该文件中的SQL语句 第三步:源码文件为split_drug.zip,修改源代码中的settings.py文件,改成自己的mysql数据库用户名和密码 第四步:运行命令:python manage.py runserver 第五步:打开浏览器查看http://127.0.0.1:8000
内容概要:本文详细介绍了如何在MATLAB中安装和使用超效率SBM-DEA模型工具箱,涵盖从安装步骤、基础代码示例到高级应用技巧。主要内容包括:安装工具箱的具体步骤,确保安装Optimization Toolbox;处理期望产出与非期望产出的超效率SBM模型的基础代码及其参数配置;Malmquist指数分解的操作方法,用于分析技术效率和技术进步的变化。文中还提供了多个实际操作案例,如处理30家工厂的数据以及跨期效率变化分析。此外,针对常见的错误和注意事项进行了提示,如数据预处理、维度匹配和内存管理等。 适合人群:从事数据分析、经济研究、效率评估等领域,具有一定MATLAB基础的研究人员和工程师。 使用场景及目标:适用于需要进行效率分析、技术进步评估、政策效果评价等场景。目标是帮助用户快速掌握超效率SBM-DEA模型的应用,提高数据分析的准确性和可靠性。 其他说明:建议初学者先使用工具箱提供的示例数据练习,熟悉后再应用于实际项目。对于复杂数据集,建议进行充分的数据预处理,以避免模型计算错误。