quartz的使用(二)

ROS环境下UR机械臂与Realsense相机手眼标定实战指南 本文提供了在ROS环境下,对UR机械臂与Realsense相机进行手眼标定的完整实战指南。详细介绍了从环境搭建、软件包安装、硬件配置到分步数据采集与计算的完整流程,并分享了常见的避坑技巧与精度优化方法,旨在帮助开发者高效、准确地完成标定,为后续的机器人视觉应用奠定坚实基础。 阅读详情


1.   MyMethodInvokingBean

package cn.xue.Scheduler.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Scheduler;
import org.quartz.StatefulJob;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.util.MethodInvoker;

public class MyMethodInvokingBean implements FactoryBean, BeanNameAware, InitializingBean
{
	private Log logger = LogFactory.getLog(getClass());

	/**
	 * The JobDetail produced by the <code>afterPropertiesSet</code> method of this Class will be assigned to the Group specified by this property.  Default: Scheduler.DEFAULT_GROUP 
	 * @see #afterPropertiesSet()
	 * @see Scheduler#DEFAULT_GROUP
	 */
	private String group = Scheduler.DEFAULT_GROUP;

	/**
	 * Indicates whether or not the Bean Method should be invoked by more than one Scheduler at the specified time (like when deployed to a cluster, and/or when there are multiple Spring ApplicationContexts in a single JVM<i> - Tomcat 5.5 creates 2 or more instances of the DispatcherServlet (a pool), which in turn creates a separate Spring ApplicationContext for each instance of the servlet</i>) 
	 * <p>
	 * Used by <code>afterPropertiesSet</code> to set the JobDetail.jobClass to MethodInvokingJob.class or StatefulMethodInvokingJob.class when true or false, respectively.  Default: true 
	 * @see #afterPropertiesSet()
	 */
	private boolean concurrent = true;
	
	/** Used to set the JobDetail.durable property.  Default: false
	 * <p>Durability - if a job is non-durable, it is automatically deleted from the scheduler once there are no longer any active triggers associated with it.
	 * @see <a href="http://www.opensymphony.com/quartz/wikidocs/TutorialLesson3.html">http://www.opensymphony.com/quartz/wikidocs/TutorialLesson3.html</a> 
	 * @see #afterPropertiesSet() 
	 */
	private boolean durable = false;
	
	/**
	 * Used by <code>afterPropertiesSet</code> to set the JobDetail.volatile property.  Default: false
	 * <p>Volatility - if a job is volatile, it is not persisted between re-starts of the Quartz scheduler.
	 * <p>I set the default to false to be the same as the default for a Quartz Trigger.  An exception is thrown 
	 * when the Trigger is non-volatile and the Job is volatile.  If you want volatility, then you must set this property, and the Trigger's volatility property, to true.
	 * @see <a href="http://www.opensymphony.com/quartz/wikidocs/TutorialLesson3.html">http://www.opensymphony.com/quartz/wikidocs/TutorialLesson3.html</a>
	 * @see #afterPropertiesSet() 
	 */
	private boolean volatility = false;
	
	/** 
	 * Used by <code>afterPropertiesSet</code> to set the JobDetail.requestsRecovery property.  Default: false<BR>
	 * <p>RequestsRecovery - if a job "requests recovery", and it is executing during the time of a 'hard shutdown' of the scheduler (i.e. the process it is running within crashes, or the machine is shut off), then it is re-executed when the scheduler is started again. In this case, the JobExecutionContext.isRecovering() method will return true. 
	 * @see <a href="http://www.opensymphony.com/quartz/wikidocs/TutorialLesson3.html">http://www.opensymphony.com/quartz/wikidocs/TutorialLesson3.html</a> 
	 * @see #afterPropertiesSet() 
	 */
	private boolean shouldRecover = false;
	
	/**
	 * A list of names of JobListeners to associate with the JobDetail object created by this FactoryBean.
	 *
	 * @see #afterPropertiesSet() 
	 **/
	private String[] jobListenerNames;
	
	/** The name assigned to this bean in the Spring ApplicationContext.
	 * Used by <code>afterPropertiesSet</code> to set the JobDetail.name property.
	 * @see afterPropertiesSet()
	 * @see JobDetail#setName(String)
	 **/
	private String beanName;
	
	/**
	 * The JobDetail produced by the <code>afterPropertiesSet</code> method, and returned by the <code>getObject</code> method of the Spring FactoryBean interface.
	 * @see #afterPropertiesSet()
	 * @see #getObject()
	 * @see FactoryBean
	 **/
	private JobDetail jobDetail;
	
	/**
	 * The name of the Class to invoke.
	 **/
	private String targetClass;

	/**
	 * The Object to invoke.
	 * <p>
	 * {@link #targetClass} or targetObject must be set, but not both.
	 * <p>
	 * This object must be Serializable when {@link #concurrent} is set to false.
	 */
	private Object targetObject;
	
	/**
	 * The instance method to invoke on the Class or Object identified by the targetClass or targetObject property, respectfully.
	 * <p>
	 * targetMethod or {@link #staticMethod} should be set, but not both. 
	 **/
	private String targetMethod;
	
	/**
	 * The static method to invoke on the Class or Object identified by the targetClass or targetObject property, respectfully.
	 * <p>
	 * {@link #targetMethod} or staticMethod should be set, but not both. 
	 */
	private String staticMethod;

	/**
	 * Method arguments provided to the {@link #targetMethod} or {@link #staticMethod} specified.
	 * <p>
	 * All arguments must be Serializable when {@link #concurrent} is set to false.
	 * <p>
	 * I strongly urge you not to provide arguments until Quartz 1.6.1 has been released if you are using a JDBCJobStore with
	 * Microsoft SQL Server. There is a bug in version 1.6.0 that prevents Quartz from Serializing the Objects in the JobDataMap
	 * to the database.  The workaround is to set the property "org.opensymphony.quaryz.useProperties = true" in your quartz.properties file,
	 * which tells Quartz not to serialize Objects in the JobDataMap, but to instead expect all String compliant values.
	 */
	private Object[] arguments;

	/**
	 * Get the targetClass property.
	 * @see #targetClass
	 * @return targetClass
	 */
	public String getTargetClass()
	{
		return targetClass;
	}

	/**
	 * Set the targetClass property.
	 * @see #targetClass
	 */
	public void setTargetClass(String targetClass)
	{
		this.targetClass = targetClass;
	}

	/**
	 * Get the targetMethod property.
	 * @see #targetMethod
	 * @return targetMethod
	 */
	public String getTargetMethod()
	{
		return targetMethod;
	}

	/**
	 * Set the targetMethod property.
	 * @see #targetMethod
	 */
	public void setTargetMethod(String targetMethod)
	{
		this.targetMethod = targetMethod;
	}

	/**
	 * @return jobDetail - The JobDetail that is created by the afterPropertiesSet method of this FactoryBean
	 * @see #jobDetail
	 * @see #afterPropertiesSet()
	 * @see FactoryBean#getObject()
	 */
	public Object getObject() throws Exception
	{
		return jobDetail;
	}

	/**
	 * @return JobDetail.class
	 * @see FactoryBean#getObjectType()
	 */
	public Class getObjectType()
	{
		return JobDetail.class;
	}

	/**
	 * @return true
	 * @see FactoryBean#isSingleton()
	 */
	public boolean isSingleton()
	{
		return true;
	}

	/**
	 * Set the beanName property.
	 * @see #beanName
	 * @see BeanNameAware#setBeanName(String)
	 */
	public void setBeanName(String beanName)
	{
		this.beanName = beanName;
	}

	/**
	 * Invoked by the Spring container after all properties have been set.
	 * <p>
	 * Sets the <code>jobDetail</code> property to a new instance of JobDetail
	 * <ul>
	 * <li>jobDetail.name is set to <code>beanName</code><br>
	 * <li>jobDetail.group is set to <code>group</code><br>
	 * <li>jobDetail.jobClass is set to MethodInvokingJob.class or StatefulMethodInvokingJob.class depending on whether the <code>concurrent</code> property is set to true or false, respectively.<br>
	 * <li>jobDetail.durability is set to <code>durable</code>
	 * <li>jobDetail.volatility is set to <code>volatility</code>
	 * <li>jobDetail.requestsRecovery is set to <code>shouldRecover</code>
	 * <li>jobDetail.jobDataMap["targetClass"] is set to <code>targetClass</code>
	 * <li>jobDetail.jobDataMap["targetMethod"] is set to <code>targetMethod</code>
	 * <li>Each JobListener name in <code>jobListenerNames</code> is added to the <code>jobDetail</code> object.
	 * </ul>
	 * <p>
	 * Logging occurs at the DEBUG and INFO levels; 4 lines at the DEBUG level, and 1 line at the INFO level.
	 * <ul>
	 * <li>DEBUG: start
	 * <li>DEBUG: Creating JobDetail <code>{beanName}</code>
	 * <li>DEBUG: Registering JobListener names with JobDetail object <code>{beanName}</code>
	 * <li>INFO: Created JobDetail: <code>{jobDetail}</code>; targetClass: <code>{targetClass}</code>; targetMethod: <code>{targetMethod}</code>;
	 * <li>DEBUG: end
	 * </ul>
	 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
	 * @see JobDetail
	 * @see #jobDetail
	 * @see #beanName
	 * @see #group
	 * @see MethodInvokingJob
	 * @see StatefulMethodInvokingJob
	 * @see #durable
	 * @see #volatility
	 * @see #shouldRecover
	 * @see #targetClass
	 * @see #targetMethod
	 * @see #jobListenerNames 
	 */
	public void afterPropertiesSet() throws Exception
	{
		try
		{
			logger.debug("start");
			
			logger.debug("Creating JobDetail "+beanName);
			jobDetail = new JobDetail();
			jobDetail.setName(beanName);
			jobDetail.setGroup(group);
			jobDetail.setJobClass(concurrent ? MethodInvokingJob.class : StatefulMethodInvokingJob.class);
			jobDetail.setDurability(durable);
			jobDetail.setVolatility(volatility);
			jobDetail.setRequestsRecovery(shouldRecover);
			if(targetClass!=null)
				jobDetail.getJobDataMap().put("targetClass", targetClass);
			if(targetObject!=null)
				jobDetail.getJobDataMap().put("targetObject", targetObject);
			if(targetMethod!=null)
				jobDetail.getJobDataMap().put("targetMethod", targetMethod);
			if(staticMethod!=null)
				jobDetail.getJobDataMap().put("staticMethod", staticMethod);
			if(arguments!=null)
				jobDetail.getJobDataMap().put("arguments", arguments);
			logger.debug("Registering JobListener names with JobDetail object "+beanName);
			if (this.jobListenerNames != null) {
				for (int i = 0; i < this.jobListenerNames.length; i++) {
					this.jobDetail.addJobListener(this.jobListenerNames[i]);
				}
			}
			logger.info("Created JobDetail: "+jobDetail+"; targetClass: "+targetClass+"; targetObject: "+targetObject+"; targetMethod: "+targetMethod+"; staticMethod: "+staticMethod+"; arguments: "+arguments+";");
		}
		finally
		{
			logger.debug("end");
		}
	}

	/**
	 * Setter for the concurrent property.
	 * 
	 * @param concurrent
	 * @see #concurrent
	 */
	public void setConcurrent(boolean concurrent)
	{
		this.concurrent = concurrent;
	}

	/**
	 * setter for the durable property.
	 * 
	 * @param durable
	 * 
	 * @see #durable
	 */
	public void setDurable(boolean durable)
	{
		this.durable = durable;
	}

	/**
	 * setter for the group property.
	 * 
	 * @param group
	 * 
	 * @see #group
	 */
	public void setGroup(String group)
	{
		this.group = group;
	}

	/**
	 * setter for the {@link #jobListenerNames} property.
	 * 
	 * @param jobListenerNames
	 * @see #jobListenerNames
	 */
	public void setJobListenerNames(String[] jobListenerNames)
	{
		this.jobListenerNames = jobListenerNames;
	}

	/**
	 * setter for the {@link #shouldRecover} property.
	 * 
	 * @param shouldRecover
	 * @see #shouldRecover
	 */
	public void setShouldRecover(boolean shouldRecover)
	{
		this.shouldRecover = shouldRecover;
	}

	/**
	 * setter for the {@link #volatility} property.
	 * 
	 * @param volatility
	 * @see #volatility
	 */
	public void setVolatility(boolean volatility)
	{
		this.volatility = volatility;
	}

	/**
	 * This is a cluster safe Job designed to invoke a method on any bean defined within the same Spring
	 * ApplicationContext.
	 * <p>
	 * The only entries this Job expects in the JobDataMap are "targetClass" and "targetMethod".<br>
	 * - It uses the value of the <code>targetClass</code> entry to get the desired bean from the Spring ApplicationContext.<br>
	 * - It uses the value of the <code>targetMethod</code> entry to determine which method of the Bean (identified by targetClass) to invoke.
	 * <p>
	 * It uses the static ApplicationContext in the MethodInvokingJobDetailFactoryBean,
	 * which is ApplicationContextAware, to get the Bean with which to invoke the method.
	 * <p>
	 * All Exceptions thrown from the execute method are caught and wrapped in a JobExecutionException.
	 * 
	 * @see MyMethodInvokingBean#applicationContext
	 * @see #execute(JobExecutionContext)
	 * 
	 * @author Stephen M. Wick
	 */
	public static class MethodInvokingJob implements Job
	{
		protected Log logger = LogFactory.getLog(getClass());
		
		/**
		 * When invoked by a Quartz scheduler, <code>execute</code> invokes a method on a Class or Object in the JobExecutionContext provided.
		 * <p>
		 * <b>Implementation</b><br>
		 * The Class is identified by the "targetClass" entry in the JobDataMap of the JobExecutionContext provided.  If targetClass is specified, then targetMethod must be a static method.<br>
		 * The Object is identified by the 'targetObject" entry in the JobDataMap of the JobExecutionContext provided.  If targetObject is provided, then targetClass will be overwritten.  This Object must be Serializable when <code>concurrent</code> is set to false.<br>
		 * The method is identified by the "targetMethod" entry in the JobDataMap of the JobExecutionContext provided.<br>
		 * The "staticMethod" entry in the JobDataMap of the JobExecutionContext can be used to specify a Class and Method in one entry (ie: "example.ExampleClass.someStaticMethod")<br>
		 * The method arguments (an array of Objects) are identified by the "arguments" entry in the JobDataMap of the JobExecutionContext.  All arguments must be Serializable when <code>concurrent</code> is set to false.
		 * <p>
		 * Logging is provided at the DEBUG and INFO levels; 8 lines at the DEBUG level, and 1 line at the INFO level.
		 * @see Job#execute(JobExecutionContext)
		 */
		public void execute(JobExecutionContext context) throws JobExecutionException
		{
			try
			{
				logger.debug("start");
				String targetClass = context.getMergedJobDataMap().getString("targetClass");
				//logger.debug("targetClass is "+targetClass);
				Class targetClassClass = null;
				if(targetClass!=null){
					targetClassClass = Class.forName(targetClass); // Could throw ClassNotFoundException
				}
				Object targetObject = context.getMergedJobDataMap().get("targetObject");
				ApplicationContext ac = (ApplicationContext)context.getScheduler().getContext().get("applicationContext");

				//logger.debug("targetObject is "+targetObject);
				String targetMethod = context.getMergedJobDataMap().getString("targetMethod");
				//logger.debug("targetMethod is "+targetMethod);
				String staticMethod = context.getMergedJobDataMap().getString("staticMethod");
				//logger.debug("staticMethod is "+staticMethod);
				Object[] arguments = (Object[])context.getMergedJobDataMap().get("arguments");
				//logger.debug("arguments are "+arguments);
				arguments=new Object[1];
				arguments[0]=ac;
					
				//logger.debug("creating MethodInvoker");
				MethodInvoker methodInvoker = new MethodInvoker();
				methodInvoker.setTargetClass(targetClassClass);
				methodInvoker.setTargetObject(targetObject);
				methodInvoker.setTargetMethod(targetMethod);
				methodInvoker.setStaticMethod(staticMethod);
				methodInvoker.setArguments(arguments);
				methodInvoker.prepare();
				//logger.info("Invoking: "+methodInvoker.getPreparedMethod().toGenericString());
				methodInvoker.invoke();

			}
			catch(Exception e)
			{
				throw new JobExecutionException(e);
			}
			finally
			{
				logger.debug("end");
			}
		}
	}

	public static class StatefulMethodInvokingJob extends MethodInvokingJob implements StatefulJob
	{
		// No additional functionality; just needs to implement StatefulJob.
	}

	public Object[] getArguments()
	{
		return arguments;
	}

	public void setArguments(Object[] arguments)
	{
		this.arguments = arguments;
	}

	public String getStaticMethod()
	{
		return staticMethod;
	}

	public void setStaticMethod(String staticMethod)
	{
		this.staticMethod = staticMethod;
	}

	public void setTargetObject(Object targetObject)
	{
		this.targetObject = targetObject;
	}
}


2.   SchedulerManager

 

package cn.xue.Scheduler.service;

import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
import org.quartz.TriggerUtils;
import org.quartz.impl.calendar.AnnualCalendar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;

@Component("schedulerManager")
public class SchedulerManager {
	
	private SchedulerFactoryBean schedulerFactoryBean;
	@Autowired
	public void setSchedulerFactoryBean(SchedulerFactoryBean schedulerFactoryBean) {
		this.schedulerFactoryBean = schedulerFactoryBean;
	}
	public void addCalendarJob(Long l) throws ParseException, SchedulerException{
		String jobName=l+"add_Job";
		String triggerName=l+"add_Trigger";
		
        Scheduler scheduler = schedulerFactoryBean.getScheduler(); 
        JobDetail jobDetail = scheduler.getJobDetail(jobName, Scheduler.DEFAULT_GROUP);
		if(jobDetail==null){
			AnnualCalendar holidays = new AnnualCalendar();  //①法定节日是以每年为周期的,所以使用AnnualCalendar
			Calendar laborDay = new GregorianCalendar();  //②五一劳动节
			laborDay.add(Calendar.MONTH,5);
			laborDay.add(Calendar.DATE,1);
			holidays.setDayExcluded(laborDay, true);     //②-1:排除的日期,如果设置为false则为包含
			Calendar nationalDay = new GregorianCalendar();  //③国庆节
			nationalDay.add(Calendar.MONTH,10);
			nationalDay.add(Calendar.DATE,1);
			holidays.setDayExcluded(nationalDay, true);	//③-1:排除该日期
			
			scheduler.addCalendar("holidays", holidays, false, false);	//④向Scheduler注册日历
			
			Date runDate = TriggerUtils.getDateOf(0,0, 10, 1, 4);	//⑤4月1号 上午10点
			JobDetail job = new JobDetail(jobName, Scheduler.DEFAULT_GROUP, MyJob1.class);
			SimpleTrigger trigger = new SimpleTrigger(triggerName, Scheduler.DEFAULT_GROUP, runDate, null, SimpleTrigger.REPEAT_INDEFINITELY, 60L * 60L * 1000L);
			trigger.setCalendarName("holidays");	//⑥让Trigger应用指定的日历规则
			
			scheduler.scheduleJob(job, trigger);
			scheduler.start();
		}
		/*
		      由于节日是每年重复的,所以使用org.quartz.Calendar的AnnualCalendar实现类,通过②、③的代码,指定五一和国庆两个节日并通过AnnualCalendar#setDayExcluded(Calendar day, boolean exclude)方法添加这两个日期。
		  exclude为true时表示排除指定的日期,如果为false时表示包含指定的日期。
		    在定制好org.quartz.Calendar后,还需要通过Scheduler#addCalendar(String calName, Calendar calendar, boolean replace, boolean updateTriggers)进行注册,
		    如果updateTriggers为true,Scheduler中已引用Calendar的Trigger将得到更新,如④所示。
		  在⑥处,我们让一个Trigger指定使用Scheduler中代表节日的Calendar,这样Trigger就会避开五一和国庆这两个特殊日子了。
		*/
	}
	
	public void addJob(Long l) throws ParseException, SchedulerException{
		String jobName=l+"add_Job";
		String triggerName=l+"add_Trigger";
		
        Scheduler scheduler = schedulerFactoryBean.getScheduler(); 
        JobDetail jobDetail = scheduler.getJobDetail(jobName, Scheduler.DEFAULT_GROUP);
		if(jobDetail==null){
            jobDetail = new JobDetail(jobName, Scheduler.DEFAULT_GROUP,MyJob1.class);  
            jobDetail.getJobDataMap().put("xueyong", l);   
			Trigger trigger=new CronTrigger(triggerName,Scheduler.DEFAULT_GROUP, "0/5 * * * * ?" );
  
            scheduler.scheduleJob(jobDetail, trigger);     //注册并进行调度     
            scheduler.start();
		}
	}
	
	//移除某一个项目的某一个周期性活动的job
	public  void removeJob(Long l) throws SchedulerException{
		String jobName=l+"add_Job";
		String triggerName=l+"add_Trigger";
		 
		 Scheduler scheduler = schedulerFactoryBean.getScheduler(); 
		 scheduler.pauseTrigger(triggerName,Scheduler.DEFAULT_GROUP);//停止触发器
		 scheduler.unscheduleJob(triggerName,Scheduler.DEFAULT_GROUP);//移除触发器
		 scheduler.deleteJob(jobName,Scheduler.DEFAULT_GROUP);//删除任务
	}

	//修改job的触发时间
	public  void modifyJobTime(Long l ) throws SchedulerException, ParseException{
		String jobName=l+"add_Job";
		String triggerName=l+"add_Trigger";
		
		Scheduler scheduler = schedulerFactoryBean.getScheduler(); //获取一个调度器实例
		JobDetail jobDetail = scheduler.getJobDetail(jobName,Scheduler.DEFAULT_GROUP);
		if(jobDetail != null){	//update time
			CronTrigger cronTrigger = (CronTrigger)scheduler.getTrigger(triggerName,Scheduler.DEFAULT_GROUP);
			cronTrigger.setCronExpression( "0/20 * * * * ?" );
			
			scheduler.resumeTrigger(triggerName,Scheduler.DEFAULT_GROUP);  //重启触发器
			scheduler.rescheduleJob(cronTrigger.getName(), cronTrigger.getGroup(), cronTrigger);
		}
	}
}

3.  MyJob1

package cn.xue.Scheduler.service;

import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerContext;
import org.quartz.SchedulerException;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.quartz.QuartzJobBean;
import cn.xue.docModel.dao.LoopbkmkTreeDao;

public class MyJob1 extends QuartzJobBean  {

	@Override
	protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        JobDataMap dataMap = context.getJobDetail().getJobDataMap();   
        String jobName = context.getJobDetail().getName();
		String jobGroup = context.getJobDetail().getGroup();
		Long projectID =  (Long)dataMap.get("xueyong");   
		//获取JobExecutionContext中的service对象  
        try {
			SchedulerContext schCtx = context.getScheduler().getContext();     
			ApplicationContext appCtx = (ApplicationContext)schCtx.get("applicationContext"); //获取Spring中的上下文  
			LoopbkmkTreeDao loopbkmkTreeDao= (LoopbkmkTreeDao)appCtx.getBean("loopbkmkTreeDao");
		
			System.out.println(projectID+"****777*****"+loopbkmkTreeDao.getAll().size());
		} catch (SchedulerException e1) {
			e1.printStackTrace();
		} 
	} 
};

/*
Cron 表达式包括以下 7 个字段:
* 秒
* 分
* 小时
* 月内日期
* 月
* 周内日期
* 年(可选字段)

特殊字符
Cron 触发器利用一系列特殊字符,如下所示:
●星号(*):可用在所有字段中,表示对应时间域的每一个时刻,例如,*在分钟字段时,表示“每分钟”;
●问号(?):该字符只在日期和星期字段中使用,它通常指定为“无意义的值”,相当于点位符;
●减号(-):表达一个范围,如在小时字段中使用“10-12”,则表示从10到12点,即10,11,12;
●逗号(,):表达一个列表值,如在星期字段中使用“MON,WED,FRI”,则表示星期一,星期三和星期五;
●斜杠(/):x/y表达一个等步长序列,x为起始值,y为增量步长值。如在分钟字段中使用0/15,则表示为0,15,30和45秒,而5/15在分钟字段中表示5,20,35,50,你也可以使用0/y;
●L:该字符只在日期和星期字段中使用,代表“Last”的意思,但它在两个字段中意思不同。L在日期字段中,表示这个月份的最后一天,如一月的31号,非闰年二月的28号;如果L用在星期中,
	则表示星期六,等同于7。但是,如果L出现在星期字段里,而且在前面有一个数值X,则表示“这个月的最后X天”,例如,6L表示该月的最后星期五;
●W:该字符只能出现在日期字段里,是对前导日期的修饰,表示离该日期最近的工作日。例如15W表示离该月15号最近的工作日,如果该月15号是星期六,则匹配14号星期五;如果15日是星期日,
	则匹配16号星期一;如果15号是星期二,那结果就是15号星期二。但必须注意关联的匹配日期不能够跨月,如你指定1W,如果1号是星期六,结果匹配的是3号星期一,而非上个月最后的那天。W字符串只能指定单一日期,而不能指定日期范围;
●LW组合:在日期字段可以组合使用LW,它的意思是当月的最后一个工作日;
●井号(#):该字符只能在星期字段中使用,表示当月某个工作日。如6#3表示当月的第三个星期五(6表示星期五,#3表示当前的第三个),而4#5表示当月的第五个星期三,假设当月没有第五个星期三,忽略不触发;
● C:该字符只在日期和星期字段中使用,代表“Calendar”的意思。它的意思是计划所关联的日期,如果日期没有被关联,则相当于日历中所有日期。例如5C在日期字段中就相当于日历5日以后的第一天。1C在星期字段中相当于星期日后的第一天。
Cron表达式对特殊字符的大小写不敏感,对代表星期的缩写英文大小写也不敏感。

*/

/*
字段 允许值 允许的特殊字符
秒 0-59 , - * /
分 0-59 , - * /
小时 0-23 , - * /
日期 1-31 , - * ? / L W C
月份 1-12 或者 JAN-DEC , - * /
星期 1-7 或者 SUN-SAT , - * ? / L C #
年(可选) 留空, 1970-2099 , - * /

表达式意义
"0 0 12 * * ?" 每天中午12点触发
"0 15 10 ? * *" 每天上午10:15触发
"0 15 10 * * ?" 每天上午10:15触发
"0 15 10 * * ? *" 每天上午10:15触发
"0 15 10 * * ? 2005" 2005年的每天上午10:15触发
"0 * 14 * * ?" 在每天下午2点到下午2:59期间的每1分钟触发
"0 0/5 14 * * ?" 在每天下午2点到下午2:55期间的每5分钟触发
"0 0/5 14,18 * * ?" 在每天下午2点到2:55期间和下午6点到6:55期间的每5分钟触发
"0 0-5 14 * * ?" 在每天下午2点到下午2:05期间的每1分钟触发
"0 10,44 14 ? 3 WED" 每年三月的星期三的下午2:10和2:44触发
"0 15 10 ? * MON-FRI" 周一至周五的上午10:15触发
"0 15 10 15 * ?" 每月15日上午10:15触发
"0 15 10 L * ?" 每月最后一日的上午10:15触发
"0 15 10 ? * 6L" 每月的最后一个星期五上午10:15触发
"0 15 10 ? * 6L 2002-2005" 2002年至2005年的每月的最后一个星期五上午10:15触发
"0 15 10 ? * 6#3" 每月的第三个星期五上午10:15触发

晚上11点到早上8点之间每两个小时,早上八点
0 23-7/2,8 * * *
每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点
0 11 4 * 1-3
1月1日早上4点
0 4 1 1 *

*/

/*
有些子表达式能包含一些范围或列表 
例如:子表达式(天(星期))可以为 “MON-FRI”,“MON,WED,FRI”,“MON-WED,SAT” 
“*”字符代表所有可能的值 
因此,“*”在子表达式(月)里表示每个月的含义,“*”在子表达式(天(星期))表示星期的每一天 

“/”字符用来指定数值的增量 
例如:在子表达式(分钟)里的“0/15”表示从第0分钟开始,每15分钟 
         在子表达式(分钟)里的“3/20”表示从第3分钟开始,每20分钟(它和“3,23,43”)的含义一样 
“?”字符仅被用于天(月)和天(星期)两个子表达式,表示不指定值 
当2个子表达式其中之一被指定了值以后,为了避免冲突,需要将另一个子表达式的值设为“?” 
“L” 字符仅被用于天(月)和天(星期)两个子表达式,它是单词“last”的缩写 
但是它在两个子表达式里的含义是不同的。 
在天(月)子表达式中,“L”表示一个月的最后一天 
在天(星期)自表达式中,“L”表示一个星期的最后一天,也就是SAT 
如果在“L”前有具体的内容,它就具有其他的含义了 
例如:“6L”表示这个月的倒数第6天,“FRIL”表示这个月的最一个星期五 
注意:在使用“L”参数时,不要指定列表或范围,因为这会导致问题 

字段   允许值   允许的特殊字符 
秒    0-59    , - * / 
分    0-59    , - * / 
小时    0-23    , - * / 
日期    1-31    , - * ? / L W C 
月份    1-12 或者 JAN-DEC    , - * / 
星期    1-7 或者 SUN-SAT    , - * ? / L C # 
年(可选)    留空, 1970-2099    , - * / 

*/


 

YOLOv8【第十二章:数据增强与数据工程篇·第10节】主动学习(Active Learning):如何挑选最有价值的样本进行标注! 🏆 本文收录于 《YOLOv8实战:从入门到深度优化》 专栏。该专栏系统复现并梳理全网各类 YOLOv8 改进与实战案例(当前已覆盖分类 / 检测 / 分割 / 追踪 / 关键点 / OBB 检测等方向),坚持持续更新 + 深度解析,质量分长期稳定在 97 分以上,可视为当前市面上 覆盖较全、更新较快、实战导向极强 的 YOLO 改进系列内容之一。 阅读详情

相关推荐

电价预测的Transformer实战:从注意力机制到超长序列建模

本文深入探讨了Transformer模型在电价预测领域的实战应用,对比了其与LSTM在处理长序列依赖和误差累积问题上的优劣。文章详细解析了自注意力机制的原理,并提供了处理超长序列的位置编码方法、构建专用预测模型的完整PyTorch代码,以及防止信息泄露的关键技巧。通过实战对比,展示了Transformer在并行计算、长距离建模和预测精度上的显著优势,并分享了应对极端波动和提升模型效率的高级优化策略。

f6g7h8i9j的博客 552

Quartz配置信息

1. Quartz主要配置 属性名称 是否必选 类型 默认值 说明 org.quartz.scheduler.instanceName 否 String QuartzScheduler Schedule调度器的实体名字 org.quartz.scheduler.instanceId 否 String NON_CLUSTERED Schedule调度器的实体的Id,必须唯一。 1. 当你想生成intanceId的时候可以设置为AUTO 2. 当你想从系统属性org.quartz.sched

SheldonChang的博客 1534

基于TI C2000的CCS安装与工程创建完整示例

手把手演示基于TI C2000系列的CCS安装过程及首个工程创建步骤,涵盖环境配置与常见问题处理,助力快速上手嵌入式开发,ccs安装和工程搭建不再难。

weixin_42476987的博客 979

【已解决】There is no setter for property XXX

两端代码只有property的大小写换了,原因就是因为这个PersonChange中我定义的时候都是小写,在property中定义也要换成跟实体类对应的。不是大哥,它报没有setter方法的错误我看得懂啊,但是明明set方法我写了。问题原因:这是我之前的resultMap,就是它在报错。逛了一圈CSDN,都没有一个好的回答。

a474416564的博客 1048

Frida实战:如何逆向分析某电商App的doCommandNative函数(附完整Hook脚本)

本文详细介绍了如何使用Frida逆向分析电商App中的doCommandNative函数,涵盖动态注册识别、SO加固对抗及高级Hook脚本编写等实战技巧。通过完整Hook脚本示例,帮助安全研究人员深入理解JNICLibrary的关键函数逆向分析方法,提升移动应用安全研究能力。

weixin_29327977的博客 627

Virtuoso 中的tech file 详细说明

工艺文件(Techfile)是集成电路设计中的核心配置文件,定义了从晶圆制造到版图验证全流程所需的工艺规则和图层属性。在Cadence Virtuoso平台中,Techfile作为连接设计与制造的桥梁,主要包含以下内容: 图层体系定义 金属层、介质层、多晶硅层等物理图层的编号、名称和显示属性 图层用途(DRAW、MASK等)及图层-用途组合(LPP)的优先级 设计规则约束 几何尺寸规则(最小线宽/间距) 包围和延伸规则 密度规则和特殊工艺规则(如天线效应) 器件定义 MOS管、电阻等器件的图层构成 电学参数

u013620135的博客 8195

quartz常见问题

一、配置job的xml里的时间格式: 从源码JobSchedulingDataProcessor类中可以看出:格式例如(2012-03-31T05:55:00)     /**      * XML Schema dateTime datatype format.      *      * See http://www.w3.org/TR/2001/REC-xmlschema-2-2

Davin_(幸福在于感悟).......... 6168

Joule 终于会说 ABAP 了:从 ADT 提效到 ABAP AI SDK + ISLM 自建企业级 AI 场景的落地路线

生成结构化摘要(故障现象、初步原因、处理动作、备件消耗)自动给出建议分类(电气、机械、软件、网络)把摘要回写到工单抬头,方便后续统计与知识沉淀如果你用 CAP 来做这类服务,通常会在 Node.js 层封装一个对 AI Hub 的调用,再通过 OData 或 Event 把结果写回 SAP。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 360

SpringBoot整合quartz

配置额外的xml文件(spring的xml) 在启动类中配置读取文件的注解 @SpringBootApplication @ImportResource(&amp;quot;spring.xml&amp;quot;) 石英钟quartz 4个核心组件 1 JobDetail : 管理一个/一组/多组真正执行的任务; 2 Job:我们需要编写的真正任务的执行代码 3 Trigger: 触发器,根据配置的时间表达式完成各种任务的定时触...

Arno的博客 457

STM32+FreeRTOS环境下LwIP协议栈移植详解

本文详细介绍了在STM32F407ZGT6平台上移植轻量级TCP/IP协议栈LwIP的过程。使用FreeRTOS操作系统和LAN8720A以太网PHY芯片,通过STM32CubeMX生成基础工程配置。重点包括LwIP源码的获取与工程集成、关键配置文件的编写(如lwipopts.h)、操作系统适配层sys_arch.c的实现,以及以太网接口驱动ethernetif.c的移植。文章特别强调内存管理、中断优先级、硬件校验和等关键配置项的注意事项,为基于STM32和LwIP的嵌入式网络开发提供了实用参考。

电脑管家 768

22、嵌入式软件随机延迟生成与加密算法防护技术

本文探讨了嵌入式软件中的随机延迟生成方法与块密码软件实现的高阶掩码及洗牌技术。重点介绍了浮动均值延迟生成方法,其在8位AVR平台上的实现效率为Θ(1),显著提升了抗相关功率分析(CPA)攻击的能力,相比传统方法更安全且轻量。同时,分析了高阶掩码与洗牌技术结合的方案,通过理论建模量化其对高级差分功率分析(DPA)攻击的抵抗能力,并以AES为例展示了该方案的应用流程。最后对比了不同防护技术在安全性与开销之间的权衡,为实际应用中选择合适的安全策略提供了依据。未来可进一步优化实现效率并融合多种防护手段以应对复杂安全

fern8的博客 94

Quartz的使用(二)

SimpleTrigger 可以满足的调度需求是:在具体的时间点执行一次,或者在具体的时间点执行,并且以指定的间隔重复执行若干次。指定从某一个时间开始,以一定的时间间隔(单位是毫秒、秒、分、时)执行的任务。它的属性: 1、repeatInterval 重复间隔 2、repeatCount 重复次数。实际执行次数是 repeatCount+1。因为在startTime的时候一定会执行一次。重复次

u014785687的博客 2301

C#与天文观测:Celestia模拟星空的奇幻之旅

Celestia就像一艘穿梭在星海中的小飞船,带领我们遨游宇宙。C#则是这艘飞船的智能导航系统,用代码指挥它飞向任何我们向往的星球或星系。首先,下载并安装Celestia,熟悉其基本操作和功能。创建一个星空目标列表,包括不同的恒星、行星和星系。// 示例:定义观察目标列表new SpaceObject("太阳"),new SpaceObject("月球"),new SpaceObject("火星")

java专栏 1468

Quartz 使用(二) — quartz.properties配置

  quartz.properties #org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore #============================================================================ # Configure ThreadPool (与spring整合后,使用spr...

zl_momomo的博客 6149

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

quartz Cron使用二

转自: https://www.cnblogs.com/superman66/p/4565723.html CronTrigger CronTriggers往往比SimpleTrigger更有用,如果您需要基于日历的概念,而非SimpleTrigger完全指定的时间间隔,复发的发射工作的时间表。 CronTrigger,你可以指定触发的时间表如“每星期五中午”,或“每个工作日9:30时”,甚至“...

ernesto的博客 181

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

quartz使用(二)

quartz中的job 的具体说明: job可分为无状态和有状态。它们之间的重大区别就是:两个或多个有状态的 JobDetail 实例不能并发执行。说的是你创建并注册了一个有状态 JobDetail 到 Scheduler 上。你还建立了两个 Trigger 来触发这个 Job:一个每五分钟触发,另一个也是每五分钏触发。假如这两个 Trigger 试图在同一时刻触发 Job,框架是不允许

摩羯座 508

quartz使用(二)任务的删除,停止,暂停,启动

在上一篇文章中,介绍了quartz简单的使用方法,没有看过的可以查看https://editor.csdn.net/md/?articleId=102677404 这一篇介绍关于任务的启动停止这些操作,废话不多说。 任务启动停止 启动任务 void start() throws SchedulerException; // 启动任务 停止任务 void shutdown() t...

毅香雪海的博客 1万+

springboot集成quartz(二)基本使用

前文我们已经基本了解了Quartz中的一些基础概念Quartz基础 现在我们来看看如何在springboot使用quartz 引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-...

kevin的博客 706

Quartz(二)简单的使用

1.定义Job package cn.itcast.quartz.example; import java.util.Date; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quar

Java面试辅导-海龟老师 457

Quartz基本使用(二)

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34392843的博客 154

Quartz2D简单使用(二)

一:绘制文字 // // YXtextView.m // Quartz2D简单使用(二) // // Created by yeyuanxiang on 16/6/28. // Copyright © 2016年 KuYu. All rights reserved. // #import "YXtextView.h" @implementation YXtextView // O

y_csdnblog_xx的博客 434

Spring中使用Quartz(二)

http://yefriendly.iteye.com/blog/404389 续Spring中使用Quartz(一) 注意:CronTriggerBean的cronExpression属性指定格式:至少6个时间元素,上面表示每天的15:37-38分执行1次任务。 时间元素(按照顺序): 秒(0-59): 分(0-59): 小时(0-23)...

weixin_33809981的博客 68

Spring 整合 Quartz使用学习(二)Quartz 框架核心接口介绍

    quartz核心接口一览     Scheduler    Job    JobDetail    Trigger    JobDataMap   详解如下:   1、Job    作业是一个执行任务的简单java类。任务可以是任何java代码。只需你实现org.quartz.Job接口,并将你需要执行的任务代码写在execute()方法中即可。当Quartz确定该是作...

食梦鱼儿 232

Quartz学习笔记(二)-C#Quartz的简单使用

Quartz的简单使用-QuartzHelper:登录后复制 /** *┌──────────────────────────────────────────────────────────────┐ *│ 描 述:Quartz的简单使用 *│ 介 绍: *│ 组成: *│ ...

weixin_36931481的博客 433

quartz的使用(二.基本过程)

1.关于各个要素的创建,SchedulerFactoryBean,CronTriggerFactoryBean及JobDetailFactoryBean全部实现spring中的FactoryBean<CronTrigger>, BeanNameAware, InitializingBean用于生成各自的实例 1.1.JobDetailFactoryBean 使用JobDetail...

weixin_34192816的博客 168
上一篇: quartz的使用(一)
下一篇: quartz的使用(三)
java20100406
博客等级 码龄16年 23粉丝 62原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址