code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
package com.zmops.iot.web.proxy.dto; import lombok.Data; /** * @author yefei **/ @Data public class ProxyMonitorInfo { private int hostStatusEnable; private int hostStatusDisable; private int hostStatusTotal; private int itemStatusEnable; private int itemStatusDisable; private int itemStatusUnSupport; private int itemStatusTotal; private int triggerStatusEnable; private int triggerStatusDisable; private int triggerStatusTotal; private String nvps; private String proxyId; private String proxyName; public int getHostStatusTotal() { return this.hostStatusEnable + this.hostStatusDisable; } public int getItemStatusTotal() { return this.itemStatusEnable + this.itemStatusDisable + itemStatusUnSupport; } public int getTriggerStatusTotal() { return this.triggerStatusEnable + this.triggerStatusDisable; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/proxy/dto/ProxyMonitorInfo.java
Java
gpl-3.0
921
package com.zmops.iot.web.proxy.dto; import lombok.Data; /** * @author yefei **/ @Data public class ZbxProxyInfo { private String proxyid; private String lastaccess; private String auto_compress; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/proxy/dto/ZbxProxyInfo.java
Java
gpl-3.0
218
package com.zmops.iot.web.proxy.dto; import lombok.Data; /** * @author yefei **/ @Data public class ZbxServerInfo { private String count; private Attributes attributes; @Data public static class Attributes{ private String proxyid; private int status; private int state; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/proxy/dto/ZbxServerInfo.java
Java
gpl-3.0
323
package com.zmops.iot.web.proxy.dto.param; import com.zmops.iot.web.sys.dto.param.BaseQueryParam; import lombok.Data; /** * @author yefei **/ @Data public class ProxyParam extends BaseQueryParam { private String name; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/proxy/dto/param/ProxyParam.java
Java
gpl-3.0
231
package com.zmops.iot.web.proxy.service; import cn.hutool.core.util.IdUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.dtflys.forest.Forest; import com.dtflys.forest.config.ForestConfiguration; import com.dtflys.forest.http.ForestRequest; import com.zmops.iot.core.auth.context.LoginContextHolder; import com.zmops.iot.domain.proxy.Proxy; import com.zmops.iot.domain.proxy.query.QProxy; import com.zmops.iot.model.page.Pager; import com.zmops.iot.util.LocalDateTimeUtils; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.proxy.dto.ProxyDto; import com.zmops.iot.web.proxy.dto.ProxyMonitorInfo; import com.zmops.iot.web.proxy.dto.ZbxProxyInfo; import com.zmops.iot.web.proxy.dto.ZbxServerInfo; import com.zmops.iot.web.proxy.dto.param.ProxyParam; import com.zmops.zeus.driver.service.ZbxProxy; import io.ebean.DB; import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; /** * @author yefei * <p> * 产品 物模型 服务 **/ @Service public class ProxyService { @Autowired ZbxProxy zbxProxy; /** * 代理服务分页列表 * * @param proxyParam * @return */ public Pager<ProxyDto> getProxyByPage(ProxyParam proxyParam) { QProxy qProxy = new QProxy(); if (ToolUtil.isNotEmpty(proxyParam.getName())) { qProxy.name.contains(proxyParam.getName()); } Long tenantId = LoginContextHolder.getContext().getUser().getTenantId(); if (null != tenantId) { qProxy.tenantId.eq(tenantId); } qProxy.orderBy(" create_time desc"); List<ProxyDto> productServiceDtoList = qProxy.setFirstRow((proxyParam.getPage() - 1) * proxyParam.getMaxRow()) .setMaxRows(proxyParam.getMaxRow()).asDto(ProxyDto.class).findList(); if (ToolUtil.isNotEmpty(productServiceDtoList)) { List<String> collect = productServiceDtoList.parallelStream().map(ProxyDto::getZbxId).collect(Collectors.toList()); String s = zbxProxy.get(collect.toString()); List<ZbxProxyInfo> zbxProxyInfoList = JSONObject.parseArray(s, ZbxProxyInfo.class); Map<String, ZbxProxyInfo> map = zbxProxyInfoList.parallelStream().collect(Collectors.toMap(ZbxProxyInfo::getProxyid, o -> o)); productServiceDtoList.forEach(proxyDto -> { if (map.get(proxyDto.getZbxId()) != null) { ZbxProxyInfo zbxProxyInfo = map.get(proxyDto.getZbxId()); proxyDto.setLastAccess(LocalDateTimeUtils.convertTimeToString(Integer.parseInt(zbxProxyInfo.getLastaccess()), "yyyy-MM-dd HH:mm:ss")); proxyDto.setAutoCompress("1".equals(zbxProxyInfo.getAuto_compress()) ? "是" : "否"); } }); } return new Pager<>(productServiceDtoList, qProxy.findCount()); } /** * 代理服务列表 * * @param proxyParam * @return */ public List<Proxy> list(ProxyParam proxyParam) { QProxy qProxy = new QProxy(); if (ToolUtil.isNotEmpty(proxyParam.getName())) { qProxy.name.contains(proxyParam.getName()); } Long tenantId = LoginContextHolder.getContext().getUser().getTenantId(); if (null != tenantId) { qProxy.tenantId.eq(tenantId); } qProxy.orderBy(" create_time desc"); return qProxy.findList(); } /** * 代理服务创建 * * @param proxyDto * @return */ @Transactional(rollbackFor = Exception.class) public ProxyDto create(ProxyDto proxyDto) { Long id = IdUtil.getSnowflake().nextId(); String result = zbxProxy.proxyCreate(id + ""); String zbxId = JSON.parseObject(result, Proxyids.class).getProxyids()[0]; proxyDto.setId(id); proxyDto.setZbxId(zbxId); Proxy proxy = new Proxy(); ToolUtil.copyProperties(proxyDto, proxy); DB.save(proxy); return proxyDto; } /** * 代理服务修改 * * @param proxyDto * @return */ public ProxyDto update(ProxyDto proxyDto) { Proxy proxy = new Proxy(); ToolUtil.copyProperties(proxyDto, proxy); DB.update(proxy); return proxyDto; } /** * 代理服务删除 * * @param ids * @return */ public void delete(List<Long> ids) { List<String> zbxIds = new QProxy().select(QProxy.alias().zbxId).id.in(ids).findSingleAttributeList(); if (ToolUtil.isNotEmpty(zbxIds)) { zbxProxy.proxyDelete(zbxIds); } new QProxy().id.in(ids).delete(); } public Object monitorInfo() { List<Proxy> proxyList = list(new ProxyParam()); if (ToolUtil.isEmpty(proxyList)) { return new HashMap<>(0); } Map<String, ProxyMonitorInfo> proxyMonitorInfoMap = new ConcurrentHashMap<>(); String host = "127.0.0.1"; String zbxApiToken = ForestConfiguration.configuration().getVariableValue("zbxApiToken").toString(); // String body = "{\"request\":\"queue.get\",\"type\":\"details\",\"sid\":\"" + zbxApiToken + "\",\"limit\":10}"; // Forest.post("/zabbix/monitor").host(host).port(12800).contentTypeJson().addBody(body).executeAsMap(); // body = "{\"request\":\"queue.get\",\"type\":\"overview by proxy\",\"sid\":\"" + zbxApiToken + "\"}"; // objectObjectMap = Forest.post("/zabbix/monitor").host(host).port(12800).contentTypeJson().addBody(body).executeAsMap(); // body = "{\"request\":\"queue.get\",\"type\":\"overview\",\"sid\":\"" + zbxApiToken + "\"}"; // objectObjectMap = Forest.post("/zabbix/monitor").host(host).port(12800).contentTypeJson().addBody(body).executeAsMap(); ForestRequest<?> forestRequest = Forest.post("/zabbix/monitor").host(host).port(12800).contentTypeJson(); String body = "{\"request\":\"status.get\",\"type\":\"full\",\"sid\":\"" + zbxApiToken + "\"}"; Map<Object, Object> objectObjectMap = forestRequest.addBody(body).executeAsMap(); formatStr(objectObjectMap.get("data").toString(), proxyMonitorInfoMap, proxyList); // body = "{\"request\":\"status.get\",\"type\":\"ping\",\"sid\":\"" + zbxApiToken + "\"}"; // objectObjectMap = Forest.post("/zabbix/monitor").host(host).port(12800).contentTypeJson().addBody(body).executeAsMap(); return proxyMonitorInfoMap.values(); } public void formatStr(String data, Map<String, ProxyMonitorInfo> proxyMonitorInfoMap, List<Proxy> proxyList) { if (ToolUtil.isEmpty(data)) { return; } proxyList.forEach(proxy -> { ProxyMonitorInfo proxyMonitorInfo = new ProxyMonitorInfo(); proxyMonitorInfo.setProxyId(proxy.getZbxId()); proxyMonitorInfo.setProxyName(proxy.getName()); proxyMonitorInfoMap.put(proxy.getZbxId(), proxyMonitorInfo); }); formatHosts(data, proxyMonitorInfoMap); formatItems(data, proxyMonitorInfoMap); // formatTriggers(data, proxyMonitorInfoMap); formatNvps(data, proxyMonitorInfoMap); } private void formatNvps(String data, Map<String, ProxyMonitorInfo> proxyMonitorInfoMap) { List<ZbxServerInfo> stats = JSONObject.parseArray(JSONObject.parseObject(data).getString("required performance"), ZbxServerInfo.class); for (ZbxServerInfo performance : stats) { String proxyid = performance.getAttributes().getProxyid(); if ("0".equals(proxyid)) { continue; } proxyMonitorInfoMap.get(proxyid).setNvps(String.format("%.2f", Float.parseFloat(performance.getCount()))); } } // private void formatTriggers(String data, Map<String, ProxyMonitorInfo> proxyMonitorInfoMap) { // List<ZbxServerInfo> stats = JSONObject.parseArray(JSONObject.parseObject(data).getString("trigger stats"), ZbxServerInfo.class); // // for (ZbxServerInfo triggerStat : stats) { // String proxyid = triggerStat.getAttributes().getProxyid(); // if ("0".equals(proxyid)) { // continue; // } // if (triggerStat.getAttributes().getStatus() == 0) { // proxyMonitorInfoMap.get(proxyid).setTriggerStatusEnable(triggerStat.getCount()); // } else { // proxyMonitorInfoMap.get(proxyid).setTriggerStatusDisable(triggerStat.getCount()); // } // } // } private void formatItems(String data, Map<String, ProxyMonitorInfo> proxyMonitorInfoMap) { List<ZbxServerInfo> stats = JSONObject.parseArray(JSONObject.parseObject(data).getString("item stats"), ZbxServerInfo.class); for (ZbxServerInfo itemsStat : stats) { String proxyid = itemsStat.getAttributes().getProxyid(); if ("0".equals(proxyid)) { continue; } if (itemsStat.getAttributes().getStatus() == 0) { if (itemsStat.getAttributes().getState() == 0) { proxyMonitorInfoMap.get(proxyid).setItemStatusEnable(Integer.parseInt(itemsStat.getCount())); } else { proxyMonitorInfoMap.get(proxyid).setItemStatusUnSupport(Integer.parseInt(itemsStat.getCount())); } } else { proxyMonitorInfoMap.get(proxyid).setItemStatusDisable(Integer.parseInt(itemsStat.getCount())); } } } public void formatHosts(String data, Map<String, ProxyMonitorInfo> proxyMonitorInfoMap) { List<ZbxServerInfo> hostStats = JSONObject.parseArray(JSONObject.parseObject(data).getString("host stats"), ZbxServerInfo.class); for (ZbxServerInfo hostStat : hostStats) { String proxyid = hostStat.getAttributes().getProxyid(); if ("0".equals(proxyid)) { continue; } if (hostStat.getAttributes().getStatus() == 0) { proxyMonitorInfoMap.get(proxyid).setHostStatusEnable(Integer.parseInt(hostStat.getCount())); } else { proxyMonitorInfoMap.get(proxyid).setHostStatusDisable(Integer.parseInt(hostStat.getCount())); } } } @Data static class Proxyids { private String[] proxyids; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/proxy/service/ProxyService.java
Java
gpl-3.0
10,718
package com.zmops.iot.web.schedule; public enum MisfireStrategyEnum { /** * do nothing */ DO_NOTHING("Do nothing"), /** * fire once now */ FIRE_ONCE_NOW("Fire once now"); private final String title; MisfireStrategyEnum(String title) { this.title = title; } public String getTitle() { return title; } public static MisfireStrategyEnum match(String name, MisfireStrategyEnum defaultItem) { for (MisfireStrategyEnum item : MisfireStrategyEnum.values()) { if (item.name().equals(name)) { return item; } } return defaultItem; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/schedule/MisfireStrategyEnum.java
Java
gpl-3.0
677
package com.zmops.iot.web.schedule; /** * 调度任务类型 */ public enum ScheduleTypeEnum { NONE("None"), /** * schedule by cron */ CRON("Cron"); private final String title; ScheduleTypeEnum(String title) { this.title = title; } public String getTitle() { return title; } public static ScheduleTypeEnum match(String name, ScheduleTypeEnum defaultItem) { for (ScheduleTypeEnum item : ScheduleTypeEnum.values()) { if (item.name().equals(name)) { return item; } } return defaultItem; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/schedule/ScheduleTypeEnum.java
Java
gpl-3.0
628
package com.zmops.iot.web.schedule; import com.zmops.iot.domain.schedule.Task; import com.zmops.iot.enums.CommonStatus; import com.zmops.iot.web.schedule.config.ScheduleConfig; import com.zmops.iot.schedule.cron.CronExpression; import io.ebean.DB; import lombok.extern.slf4j.Slf4j; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; /** * @author nantian created at 2021/11/12 10:54 */ @Slf4j public class TaskScheduleImpl { private final ScheduleConfig scheduleConfig; public TaskScheduleImpl(ScheduleConfig scheduleConfig) { this.scheduleConfig = scheduleConfig; } public static final long PRE_READ_MS = 5000; // pre read private Thread scheduleThread; private Thread ringThread; private volatile boolean scheduleThreadToStop = false; private volatile boolean ringThreadToStop = false; private static final Map<Integer, List<String>> ringData = new ConcurrentHashMap<>(); public void start() { scheduleThread = new Thread(() -> { try { TimeUnit.MILLISECONDS.sleep(5000 - System.currentTimeMillis() % 1000); } catch (InterruptedException e) { if (!scheduleThreadToStop) { log.error(e.getMessage(), e); } } int preReadCount = (scheduleConfig.getTriggerPoolFastMax() + scheduleConfig.getTriggerPoolSlowMax()) * 20; while (!scheduleThreadToStop) { long start = System.currentTimeMillis(); boolean preReadSuc = true; try { DB.beginTransaction(); long nowTime = System.currentTimeMillis(); List<Task> taskList = DB.findNative(Task.class, "SELECT T.ID, T.remark, T.trigger_status, T.trigger_next_time, T.schedule_type, T.schedule_conf " + " FROM task_info AS T " + " WHERE T.trigger_status = '"+ CommonStatus.ENABLE.getCode() +"' " + " and t.trigger_next_time <= :nextTime " + " ORDER BY ID ASC " + " LIMIT :preReadCount") .setParameter("nextTime", nowTime + PRE_READ_MS) .setParameter("preReadCount", preReadCount) .findList(); if (taskList.size() > 0) { for (Task task : taskList) { if (nowTime > task.getTriggerNextTime() + PRE_READ_MS) { MisfireStrategyEnum misfireStrategyEnum = MisfireStrategyEnum.match(task.getMisfireStrategy(), MisfireStrategyEnum.DO_NOTHING); if (MisfireStrategyEnum.FIRE_ONCE_NOW == misfireStrategyEnum) { TaskTriggerPool.trigger(task.getId(), TriggerTypeEnum.MISFIRE, -1, task.getExecutorParam(), null); } refreshNextValidTime(task, new Date()); } else if (nowTime > task.getTriggerNextTime()) { TaskTriggerPool.trigger(task.getId(), TriggerTypeEnum.CRON, -1, task.getExecutorParam(), null); refreshNextValidTime(task, new Date()); if (CommonStatus.ENABLE.getCode().equals(task.getTriggerStatus()) && nowTime + PRE_READ_MS > task.getTriggerNextTime()) { int ringSecond = (int) ((task.getTriggerNextTime() / 1000) % 60); pushTimeRing(ringSecond, task.getExecutorParam()); refreshNextValidTime(task, new Date(task.getTriggerNextTime())); } } else { int ringSecond = (int) ((task.getTriggerNextTime() / 1000) % 60); pushTimeRing(ringSecond, task.getExecutorParam()); refreshNextValidTime(task, new Date(task.getTriggerNextTime())); } } DB.updateAll(taskList); } else { preReadSuc = false; } } catch (Exception e) { if (!scheduleThreadToStop) { log.error("JobScheduleHelper error: {}", e.getMessage()); } } finally { DB.commitTransaction(); } long cost = System.currentTimeMillis() - start; if (cost < 1000) { // scan-overtime, not wait try { TimeUnit.MILLISECONDS.sleep((preReadSuc ? 1000 : PRE_READ_MS) - System.currentTimeMillis() % 1000); } catch (InterruptedException e) { if (!scheduleThreadToStop) { log.error(e.getMessage(), e); } } } } log.info("JobScheduleHelper#scheduleThread stop"); }); scheduleThread.setDaemon(true); scheduleThread.setName("JobScheduleHelper#scheduleThread"); scheduleThread.start(); ringThread = new Thread(() -> { while (!ringThreadToStop) { try { TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis() % 1000); } catch (InterruptedException e) { if (!ringThreadToStop) { log.error(e.getMessage(), e); } } try { List<String> ringItemData = new ArrayList<>(); int nowSecond = Calendar.getInstance().get(Calendar.SECOND); // 避免处理耗时太长,跨过刻度,向前校验一个刻度; for (int i = 0; i < 2; i++) { List<String> tmpData = ringData.remove((nowSecond + 60 - i) % 60); if (tmpData != null) { ringItemData.addAll(tmpData); } } log.debug("time-ring beat : " + nowSecond + " = " + Collections.singletonList(ringItemData)); if (ringItemData.size() > 0) { for (String param : ringItemData) { TaskTriggerPool.trigger(0, TriggerTypeEnum.CRON, -1, param, null); } ringItemData.clear(); } } catch (Exception e) { if (!ringThreadToStop) { log.error("JobScheduleHelper#ringThread error:{}", e.getMessage()); } } } log.info("JobScheduleHelper#ringThread stop"); }); ringThread.setDaemon(true); ringThread.setName("admin JobScheduleHelper#ringThread"); ringThread.start(); } private void refreshNextValidTime(Task task, Date fromTime) throws Exception { Date nextValidTime = generateNextValidTime(task, fromTime); if (nextValidTime != null) { task.setTriggerLastTime(task.getTriggerNextTime()); task.setTriggerNextTime(nextValidTime.getTime()); } else { task.setTriggerStatus(CommonStatus.DISABLE.getCode()); task.setTriggerLastTime(0L); task.setTriggerNextTime(0L); log.warn("refreshNextValidTime fail for job: jobId={}, scheduleType={}, scheduleConf={}", task.getId(), task.getScheduleType(), task.getScheduleConf()); } } private void pushTimeRing(int ringSecond, String executeParam) { List<String> ringItemData = ringData.computeIfAbsent(ringSecond, k -> new ArrayList<String>()); ringItemData.add(executeParam); } /** * 停止任务调度 */ public void toStop() { scheduleThreadToStop = true; try { TimeUnit.SECONDS.sleep(1); // wait } catch (InterruptedException e) { log.error(e.getMessage(), e); } if (scheduleThread.getState() != Thread.State.TERMINATED) { scheduleThread.interrupt(); try { scheduleThread.join(); } catch (InterruptedException e) { log.error(e.getMessage(), e); } } boolean hasRingData = false; if (!ringData.isEmpty()) { for (int second : ringData.keySet()) { List<String> tmpData = ringData.get(second); if (tmpData != null && tmpData.size() > 0) { hasRingData = true; break; } } } if (hasRingData) { try { TimeUnit.SECONDS.sleep(8); } catch (InterruptedException e) { log.error(e.getMessage(), e); } } ringThreadToStop = true; try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { log.error(e.getMessage(), e); } if (ringThread.getState() != Thread.State.TERMINATED) { ringThread.interrupt(); try { ringThread.join(); } catch (InterruptedException e) { log.error(e.getMessage(), e); } } log.info("JobScheduleHelper stop"); } /** * 根据表达式,获取下次任务调度执行时间 * * @param task * @param fromTime * @return * @throws Exception */ public static Date generateNextValidTime(Task task, Date fromTime) throws Exception { ScheduleTypeEnum scheduleTypeEnum = ScheduleTypeEnum.match(task.getScheduleType(), null); if (ScheduleTypeEnum.CRON == scheduleTypeEnum) { return new CronExpression(task.getScheduleConf()).getNextValidTimeAfter(fromTime); } return null; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/schedule/TaskScheduleImpl.java
Java
gpl-3.0
10,343
package com.zmops.iot.web.schedule; import com.zmops.iot.web.device.service.SceneScheduleProcessor; import com.zmops.iot.web.schedule.config.ScheduleConfig; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Component; /** * @author nantian created at 2021/11/12 22:35 */ @Component public class TaskStarter implements InitializingBean, DisposableBean { private TaskTriggerPool triggerPool; private TaskScheduleImpl schedule; @Autowired SceneScheduleProcessor sceneScheduleProcessor; @Autowired private ApplicationEventPublisher publisher; @Override public void destroy() throws Exception { schedule.toStop(); triggerPool.stop(); } @Override public void afterPropertiesSet() throws Exception { ScheduleConfig scheduleConfig = new ScheduleConfig(); triggerPool = new TaskTriggerPool(scheduleConfig, publisher); triggerPool.start(); schedule = new TaskScheduleImpl(scheduleConfig); schedule.start(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/schedule/TaskStarter.java
Java
gpl-3.0
1,249
package com.zmops.iot.web.schedule; import com.zmops.iot.web.event.applicationEvent.SceneEvent; import com.zmops.iot.web.event.applicationEvent.dto.SceneEventData; import com.zmops.iot.web.schedule.config.ScheduleConfig; import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationEventPublisher; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; /** * @author nantian created at 2021/11/12 22:10 */ @Slf4j public class TaskTriggerPool { private ThreadPoolExecutor fastTriggerPool = null; private ThreadPoolExecutor slowTriggerPool = null; private ApplicationEventPublisher publisher; private final ScheduleConfig scheduleConfig; public TaskTriggerPool(ScheduleConfig scheduleConfig, ApplicationEventPublisher publisher) { this.scheduleConfig = scheduleConfig; this.publisher = publisher; helper = this; } public void start() { fastTriggerPool = new ThreadPoolExecutor( 10, scheduleConfig.getTriggerPoolFastMax(), 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(1000), r -> new Thread(r, "JobTriggerPoolHelper-fastTriggerPool-" + r.hashCode())); slowTriggerPool = new ThreadPoolExecutor( 10, scheduleConfig.getTriggerPoolSlowMax(), 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(2000), r -> new Thread(r, "JobTriggerPoolHelper-slowTriggerPool-" + r.hashCode())); } public void stop() { fastTriggerPool.shutdownNow(); slowTriggerPool.shutdownNow(); } private volatile long minTim = System.currentTimeMillis() / 60000; private final ConcurrentMap<Integer, AtomicInteger> jobTimeoutCountMap = new ConcurrentHashMap<>(); public void addTrigger(final int jobId, final TriggerTypeEnum triggerType, final int failRetryCount, final String executorParam, final String addressList) { ThreadPoolExecutor triggerPool_ = fastTriggerPool; AtomicInteger jobTimeoutCount = jobTimeoutCountMap.get(jobId); if (jobTimeoutCount != null && jobTimeoutCount.get() > 10) { // job-timeout 10 times in 1 min triggerPool_ = slowTriggerPool; } triggerPool_.execute(() -> { long start = System.currentTimeMillis(); try { log.info("jobid : {},executeParam : {}", jobId,executorParam); publisher.publishEvent(new SceneEvent(this,new SceneEventData(executorParam))); } catch (Exception e) { log.error(e.getMessage(), e); } finally { long minTim_now = System.currentTimeMillis() / 60000; if (minTim != minTim_now) { minTim = minTim_now; jobTimeoutCountMap.clear(); } long cost = System.currentTimeMillis() - start; if (cost > 500) { AtomicInteger timeoutCount = jobTimeoutCountMap.putIfAbsent(jobId, new AtomicInteger(1)); if (timeoutCount != null) { timeoutCount.incrementAndGet(); } } } }); } private static TaskTriggerPool helper; public static void trigger(int jobId, TriggerTypeEnum triggerType, int failRetryCount, String executorParam, String addressList) { helper.addTrigger(jobId, triggerType, failRetryCount, executorParam, addressList); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/schedule/TaskTriggerPool.java
Java
gpl-3.0
3,768
package com.zmops.iot.web.schedule; /** * 触发类型 */ public enum TriggerTypeEnum { MANUAL("Manual trigger"), CRON("Cron trigger"), RETRY("Fail retry trigger"), PARENT("Parent job trigger"), MISFIRE("Misfire compensation trigger"); private TriggerTypeEnum(String title) { this.title = title; } private final String title; public String getTitle() { return title; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/schedule/TriggerTypeEnum.java
Java
gpl-3.0
435
package com.zmops.iot.web.schedule.config; import lombok.Data; /** * @author nantian created at 2021/11/12 12:07 */ @Data public class ScheduleConfig { private int triggerPoolFastMax = 200; private int triggerPoolSlowMax = 100; private int logretentiondays = 30; public int getTriggerPoolFastMax() { if (triggerPoolFastMax < 200) { return 200; } return triggerPoolFastMax; } public int getTriggerPoolSlowMax() { if (triggerPoolSlowMax < 100) { return 100; } return triggerPoolSlowMax; } public int getLogretentiondays() { if (logretentiondays < 7) { return -1; // Limit greater than or equal to 7, otherwise close } return logretentiondays; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/schedule/config/ScheduleConfig.java
Java
gpl-3.0
803
/* * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. * * Licensed 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 * * 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. * */ package com.zmops.iot.schedule.cron; import java.io.Serializable; import java.text.ParseException; import java.util.*; /** * Provides a parser and evaluator for unix-like cron expressions. Cron * expressions provide the ability to specify complex time combinations such as * &quot;At 8:00am every Monday through Friday&quot; or &quot;At 1:30am every * last Friday of the month&quot;. * <P> * Cron expressions are comprised of 6 required fields and one optional field * separated by white space. The fields respectively are described as follows: * * <table cellspacing="8"> * <tr> * <th align="left">Field Name</th> * <th align="left">&nbsp;</th> * <th align="left">Allowed Values</th> * <th align="left">&nbsp;</th> * <th align="left">Allowed Special Characters</th> * </tr> * <tr> * <td align="left"><code>Seconds</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>0-59</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>, - * /</code></td> * </tr> * <tr> * <td align="left"><code>Minutes</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>0-59</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>, - * /</code></td> * </tr> * <tr> * <td align="left"><code>Hours</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>0-23</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>, - * /</code></td> * </tr> * <tr> * <td align="left"><code>Day-of-month</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>1-31</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>, - * ? / L W</code></td> * </tr> * <tr> * <td align="left"><code>Month</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>0-11 or JAN-DEC</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>, - * /</code></td> * </tr> * <tr> * <td align="left"><code>Day-of-Week</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>1-7 or SUN-SAT</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>, - * ? / L #</code></td> * </tr> * <tr> * <td align="left"><code>Year (Optional)</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>empty, 1970-2199</code></td> * <td align="left">&nbsp;</th> * <td align="left"><code>, - * /</code></td> * </tr> * </table> * <P> * The '*' character is used to specify all values. For example, &quot;*&quot; * in the minute field means &quot;every minute&quot;. * <P> * The '?' character is allowed for the day-of-month and day-of-week fields. It * is used to specify 'no specific value'. This is useful when you need to * specify something in one of the two fields, but not the other. * <P> * The '-' character is used to specify ranges For example &quot;10-12&quot; in * the hour field means &quot;the hours 10, 11 and 12&quot;. * <P> * The ',' character is used to specify additional values. For example * &quot;MON,WED,FRI&quot; in the day-of-week field means &quot;the days Monday, * Wednesday, and Friday&quot;. * <P> * The '/' character is used to specify increments. For example &quot;0/15&quot; * in the seconds field means &quot;the seconds 0, 15, 30, and 45&quot;. And * &quot;5/15&quot; in the seconds field means &quot;the seconds 5, 20, 35, and * 50&quot;. Specifying '*' before the '/' is equivalent to specifying 0 is * the value to start with. Essentially, for each field in the expression, there * is a set of numbers that can be turned on or off. For seconds and minutes, * the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to * 31, and for months 0 to 11 (JAN to DEC). The &quot;/&quot; character simply helps you turn * on every &quot;nth&quot; value in the given set. Thus &quot;7/6&quot; in the * month field only turns on month &quot;7&quot;, it does NOT mean every 6th * month, please note that subtlety. * <P> * The 'L' character is allowed for the day-of-month and day-of-week fields. * This character is short-hand for &quot;last&quot;, but it has different * meaning in each of the two fields. For example, the value &quot;L&quot; in * the day-of-month field means &quot;the last day of the month&quot; - day 31 * for January, day 28 for February on non-leap years. If used in the * day-of-week field by itself, it simply means &quot;7&quot; or * &quot;SAT&quot;. But if used in the day-of-week field after another value, it * means &quot;the last xxx day of the month&quot; - for example &quot;6L&quot; * means &quot;the last friday of the month&quot;. You can also specify an offset * from the last day of the month, such as "L-3" which would mean the third-to-last * day of the calendar month. <i>When using the 'L' option, it is important not to * specify lists, or ranges of values, as you'll get confusing/unexpected results.</i> * <P> * The 'W' character is allowed for the day-of-month field. This character * is used to specify the weekday (Monday-Friday) nearest the given day. As an * example, if you were to specify &quot;15W&quot; as the value for the * day-of-month field, the meaning is: &quot;the nearest weekday to the 15th of * the month&quot;. So if the 15th is a Saturday, the trigger will fire on * Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the * 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. * However if you specify &quot;1W&quot; as the value for day-of-month, and the * 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not * 'jump' over the boundary of a month's days. The 'W' character can only be * specified when the day-of-month is a single day, not a range or list of days. * <P> * The 'L' and 'W' characters can also be combined for the day-of-month * expression to yield 'LW', which translates to &quot;last weekday of the * month&quot;. * <P> * The '#' character is allowed for the day-of-week field. This character is * used to specify &quot;the nth&quot; XXX day of the month. For example, the * value of &quot;6#3&quot; in the day-of-week field means the third Friday of * the month (day 6 = Friday and &quot;#3&quot; = the 3rd one in the month). * Other examples: &quot;2#1&quot; = the first Monday of the month and * &quot;4#5&quot; = the fifth Wednesday of the month. Note that if you specify * &quot;#5&quot; and there is not 5 of the given day-of-week in the month, then * no firing will occur that month. If the '#' character is used, there can * only be one expression in the day-of-week field (&quot;3#1,6#3&quot; is * not valid, since there are two expressions). * <P> * <!--The 'C' character is allowed for the day-of-month and day-of-week fields. * This character is short-hand for "calendar". This means values are * calculated against the associated calendar, if any. If no calendar is * associated, then it is equivalent to having an all-inclusive calendar. A * value of "5C" in the day-of-month field means "the first day included by the * calendar on or after the 5th". A value of "1C" in the day-of-week field * means "the first day included by the calendar on or after Sunday".--> * <P> * The legal characters and the names of months and days of the week are not * case sensitive. * * <p> * <b>NOTES:</b> * <ul> * <li>Support for specifying both a day-of-week and a day-of-month value is * not complete (you'll need to use the '?' character in one of these fields). * </li> * <li>Overflowing ranges is supported - that is, having a larger number on * the left hand side than the right. You might do 22-2 to catch 10 o'clock * at night until 2 o'clock in the morning, or you might have NOV-FEB. It is * very important to note that overuse of overflowing ranges creates ranges * that don't make sense and no effort has been made to determine which * interpretation CronExpression chooses. An example would be * "0 0 14-6 ? * FRI-MON". </li> * </ul> * </p> * * * @author Sharada Jambula, James House * @author Contributions from Mads Henderson * @author Refactoring from CronTrigger to CronExpression by Aaron Craven * * Borrowed from quartz v2.3.1 * */ public final class CronExpression implements Serializable, Cloneable { private static final long serialVersionUID = 12423409423L; protected static final int SECOND = 0; protected static final int MINUTE = 1; protected static final int HOUR = 2; protected static final int DAY_OF_MONTH = 3; protected static final int MONTH = 4; protected static final int DAY_OF_WEEK = 5; protected static final int YEAR = 6; protected static final int ALL_SPEC_INT = 99; // '*' protected static final int NO_SPEC_INT = 98; // '?' protected static final Integer ALL_SPEC = ALL_SPEC_INT; protected static final Integer NO_SPEC = NO_SPEC_INT; protected static final Map<String, Integer> monthMap = new HashMap<String, Integer>(20); protected static final Map<String, Integer> dayMap = new HashMap<String, Integer>(60); static { monthMap.put("JAN", 0); monthMap.put("FEB", 1); monthMap.put("MAR", 2); monthMap.put("APR", 3); monthMap.put("MAY", 4); monthMap.put("JUN", 5); monthMap.put("JUL", 6); monthMap.put("AUG", 7); monthMap.put("SEP", 8); monthMap.put("OCT", 9); monthMap.put("NOV", 10); monthMap.put("DEC", 11); dayMap.put("SUN", 1); dayMap.put("MON", 2); dayMap.put("TUE", 3); dayMap.put("WED", 4); dayMap.put("THU", 5); dayMap.put("FRI", 6); dayMap.put("SAT", 7); } private final String cronExpression; private TimeZone timeZone = null; protected transient TreeSet<Integer> seconds; protected transient TreeSet<Integer> minutes; protected transient TreeSet<Integer> hours; protected transient TreeSet<Integer> daysOfMonth; protected transient TreeSet<Integer> months; protected transient TreeSet<Integer> daysOfWeek; protected transient TreeSet<Integer> years; protected transient boolean lastdayOfWeek = false; protected transient int nthdayOfWeek = 0; protected transient boolean lastdayOfMonth = false; protected transient boolean nearestWeekday = false; protected transient int lastdayOffset = 0; protected transient boolean expressionParsed = false; public static final int MAX_YEAR = Calendar.getInstance().get(Calendar.YEAR) + 100; /** * Constructs a new <CODE>CronExpression</CODE> based on the specified * parameter. * * @param cronExpression String representation of the cron expression the * new object should represent * @throws ParseException * if the string expression cannot be parsed into a valid * <CODE>CronExpression</CODE> */ public CronExpression(String cronExpression) throws ParseException { if (cronExpression == null) { throw new IllegalArgumentException("cronExpression cannot be null"); } this.cronExpression = cronExpression.toUpperCase(Locale.US); buildExpression(this.cronExpression); } /** * Constructs a new {@code CronExpression} as a copy of an existing * instance. * * @param expression * The existing cron expression to be copied */ public CronExpression(CronExpression expression) { /* * We don't call the other constructor here since we need to swallow the * ParseException. We also elide some of the sanity checking as it is * not logically trippable. */ this.cronExpression = expression.getCronExpression(); try { buildExpression(cronExpression); } catch (ParseException ex) { throw new AssertionError(); } if (expression.getTimeZone() != null) { setTimeZone((TimeZone) expression.getTimeZone().clone()); } } /** * Indicates whether the given date satisfies the cron expression. Note that * milliseconds are ignored, so two Dates falling on different milliseconds * of the same second will always have the same result here. * * @param date the date to evaluate * @return a boolean indicating whether the given date satisfies the cron * expression */ public boolean isSatisfiedBy(Date date) { Calendar testDateCal = Calendar.getInstance(getTimeZone()); testDateCal.setTime(date); testDateCal.set(Calendar.MILLISECOND, 0); Date originalDate = testDateCal.getTime(); testDateCal.add(Calendar.SECOND, -1); Date timeAfter = getTimeAfter(testDateCal.getTime()); return ((timeAfter != null) && (timeAfter.equals(originalDate))); } /** * Returns the next date/time <I>after</I> the given date/time which * satisfies the cron expression. * * @param date the date/time at which to begin the search for the next valid * date/time * @return the next valid date/time */ public Date getNextValidTimeAfter(Date date) { return getTimeAfter(date); } /** * Returns the next date/time <I>after</I> the given date/time which does * <I>not</I> satisfy the expression * * @param date the date/time at which to begin the search for the next * invalid date/time * @return the next valid date/time */ public Date getNextInvalidTimeAfter(Date date) { long difference = 1000; //move back to the nearest second so differences will be accurate Calendar adjustCal = Calendar.getInstance(getTimeZone()); adjustCal.setTime(date); adjustCal.set(Calendar.MILLISECOND, 0); Date lastDate = adjustCal.getTime(); Date newDate; //FUTURE_TODO: (QUARTZ-481) IMPROVE THIS! The following is a BAD solution to this problem. Performance will be very bad here, depending on the cron expression. It is, however A solution. //keep getting the next included time until it's farther than one second // apart. At that point, lastDate is the last valid fire time. We return // the second immediately following it. while (difference == 1000) { newDate = getTimeAfter(lastDate); if(newDate == null) break; difference = newDate.getTime() - lastDate.getTime(); if (difference == 1000) { lastDate = newDate; } } return new Date(lastDate.getTime() + 1000); } /** * Returns the time zone for which this <code>CronExpression</code> * will be resolved. */ public TimeZone getTimeZone() { if (timeZone == null) { timeZone = TimeZone.getDefault(); } return timeZone; } /** * Sets the time zone for which this <code>CronExpression</code> * will be resolved. */ public void setTimeZone(TimeZone timeZone) { this.timeZone = timeZone; } /** * Returns the string representation of the <CODE>CronExpression</CODE> * * @return a string representation of the <CODE>CronExpression</CODE> */ @Override public String toString() { return cronExpression; } /** * Indicates whether the specified cron expression can be parsed into a * valid cron expression * * @param cronExpression the expression to evaluate * @return a boolean indicating whether the given expression is a valid cron * expression */ public static boolean isValidExpression(String cronExpression) { try { new CronExpression(cronExpression); } catch (ParseException pe) { return false; } return true; } public static void validateExpression(String cronExpression) throws ParseException { new CronExpression(cronExpression); } //////////////////////////////////////////////////////////////////////////// // // Expression Parsing Functions // //////////////////////////////////////////////////////////////////////////// protected void buildExpression(String expression) throws ParseException { expressionParsed = true; try { if (seconds == null) { seconds = new TreeSet<Integer>(); } if (minutes == null) { minutes = new TreeSet<Integer>(); } if (hours == null) { hours = new TreeSet<Integer>(); } if (daysOfMonth == null) { daysOfMonth = new TreeSet<Integer>(); } if (months == null) { months = new TreeSet<Integer>(); } if (daysOfWeek == null) { daysOfWeek = new TreeSet<Integer>(); } if (years == null) { years = new TreeSet<Integer>(); } int exprOn = SECOND; StringTokenizer exprsTok = new StringTokenizer(expression, " \t", false); while (exprsTok.hasMoreTokens() && exprOn <= YEAR) { String expr = exprsTok.nextToken().trim(); // throw an exception if L is used with other days of the month if(exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) { throw new ParseException("Support for specifying 'L' and 'LW' with other days of the month is not implemented", -1); } // throw an exception if L is used with other days of the week if(exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) { throw new ParseException("Support for specifying 'L' with other days of the week is not implemented", -1); } if(exprOn == DAY_OF_WEEK && expr.indexOf('#') != -1 && expr.indexOf('#', expr.indexOf('#') +1) != -1) { throw new ParseException("Support for specifying multiple \"nth\" days is not implemented.", -1); } StringTokenizer vTok = new StringTokenizer(expr, ","); while (vTok.hasMoreTokens()) { String v = vTok.nextToken(); storeExpressionVals(0, v, exprOn); } exprOn++; } if (exprOn <= DAY_OF_WEEK) { throw new ParseException("Unexpected end of expression.", expression.length()); } if (exprOn <= YEAR) { storeExpressionVals(0, "*", YEAR); } TreeSet<Integer> dow = getSet(DAY_OF_WEEK); TreeSet<Integer> dom = getSet(DAY_OF_MONTH); // Copying the logic from the UnsupportedOperationException below boolean dayOfMSpec = !dom.contains(NO_SPEC); boolean dayOfWSpec = !dow.contains(NO_SPEC); if (!dayOfMSpec || dayOfWSpec) { if (!dayOfWSpec || dayOfMSpec) { throw new ParseException( "Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.", 0); } } } catch (ParseException pe) { throw pe; } catch (Exception e) { throw new ParseException("Illegal cron expression format (" + e.toString() + ")", 0); } } protected int storeExpressionVals(int pos, String s, int type) throws ParseException { int incr = 0; int i = skipWhiteSpace(pos, s); if (i >= s.length()) { return i; } char c = s.charAt(i); if ((c >= 'A') && (c <= 'Z') && (!s.equals("L")) && (!s.equals("LW")) && (!s.matches("^L-[0-9]*[W]?"))) { String sub = s.substring(i, i + 3); int sval = -1; int eval = -1; if (type == MONTH) { sval = getMonthNumber(sub) + 1; if (sval <= 0) { throw new ParseException("Invalid Month value: '" + sub + "'", i); } if (s.length() > i + 3) { c = s.charAt(i + 3); if (c == '-') { i += 4; sub = s.substring(i, i + 3); eval = getMonthNumber(sub) + 1; if (eval <= 0) { throw new ParseException("Invalid Month value: '" + sub + "'", i); } } } } else if (type == DAY_OF_WEEK) { sval = getDayOfWeekNumber(sub); if (sval < 0) { throw new ParseException("Invalid Day-of-Week value: '" + sub + "'", i); } if (s.length() > i + 3) { c = s.charAt(i + 3); if (c == '-') { i += 4; sub = s.substring(i, i + 3); eval = getDayOfWeekNumber(sub); if (eval < 0) { throw new ParseException( "Invalid Day-of-Week value: '" + sub + "'", i); } } else if (c == '#') { try { i += 4; nthdayOfWeek = Integer.parseInt(s.substring(i)); if (nthdayOfWeek < 1 || nthdayOfWeek > 5) { throw new Exception(); } } catch (Exception e) { throw new ParseException( "A numeric value between 1 and 5 must follow the '#' option", i); } } else if (c == 'L') { lastdayOfWeek = true; i++; } } } else { throw new ParseException( "Illegal characters for this position: '" + sub + "'", i); } if (eval != -1) { incr = 1; } addToSet(sval, eval, incr, type); return (i + 3); } if (c == '?') { i++; if ((i + 1) < s.length() && (s.charAt(i) != ' ' && s.charAt(i + 1) != '\t')) { throw new ParseException("Illegal character after '?': " + s.charAt(i), i); } if (type != DAY_OF_WEEK && type != DAY_OF_MONTH) { throw new ParseException( "'?' can only be specified for Day-of-Month or Day-of-Week.", i); } if (type == DAY_OF_WEEK && !lastdayOfMonth) { int val = daysOfMonth.last(); if (val == NO_SPEC_INT) { throw new ParseException( "'?' can only be specified for Day-of-Month -OR- Day-of-Week.", i); } } addToSet(NO_SPEC_INT, -1, 0, type); return i; } if (c == '*' || c == '/') { if (c == '*' && (i + 1) >= s.length()) { addToSet(ALL_SPEC_INT, -1, incr, type); return i + 1; } else if (c == '/' && ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s .charAt(i + 1) == '\t')) { throw new ParseException("'/' must be followed by an integer.", i); } else if (c == '*') { i++; } c = s.charAt(i); if (c == '/') { // is an increment specified? i++; if (i >= s.length()) { throw new ParseException("Unexpected end of string.", i); } incr = getNumericValue(s, i); i++; if (incr > 10) { i++; } checkIncrementRange(incr, type, i); } else { incr = 1; } addToSet(ALL_SPEC_INT, -1, incr, type); return i; } else if (c == 'L') { i++; if (type == DAY_OF_MONTH) { lastdayOfMonth = true; } if (type == DAY_OF_WEEK) { addToSet(7, 7, 0, type); } if(type == DAY_OF_MONTH && s.length() > i) { c = s.charAt(i); if(c == '-') { ValueSet vs = getValue(0, s, i+1); lastdayOffset = vs.value; if(lastdayOffset > 30) throw new ParseException("Offset from last day must be <= 30", i+1); i = vs.pos; } if(s.length() > i) { c = s.charAt(i); if(c == 'W') { nearestWeekday = true; i++; } } } return i; } else if (c >= '0' && c <= '9') { int val = Integer.parseInt(String.valueOf(c)); i++; if (i >= s.length()) { addToSet(val, -1, -1, type); } else { c = s.charAt(i); if (c >= '0' && c <= '9') { ValueSet vs = getValue(val, s, i); val = vs.value; i = vs.pos; } i = checkNext(i, s, val, type); return i; } } else { throw new ParseException("Unexpected character: " + c, i); } return i; } private void checkIncrementRange(int incr, int type, int idxPos) throws ParseException { if (incr > 59 && (type == SECOND || type == MINUTE)) { throw new ParseException("Increment > 60 : " + incr, idxPos); } else if (incr > 23 && (type == HOUR)) { throw new ParseException("Increment > 24 : " + incr, idxPos); } else if (incr > 31 && (type == DAY_OF_MONTH)) { throw new ParseException("Increment > 31 : " + incr, idxPos); } else if (incr > 7 && (type == DAY_OF_WEEK)) { throw new ParseException("Increment > 7 : " + incr, idxPos); } else if (incr > 12 && (type == MONTH)) { throw new ParseException("Increment > 12 : " + incr, idxPos); } } protected int checkNext(int pos, String s, int val, int type) throws ParseException { int end = -1; int i = pos; if (i >= s.length()) { addToSet(val, end, -1, type); return i; } char c = s.charAt(pos); if (c == 'L') { if (type == DAY_OF_WEEK) { if(val < 1 || val > 7) throw new ParseException("Day-of-Week values must be between 1 and 7", -1); lastdayOfWeek = true; } else { throw new ParseException("'L' option is not valid here. (pos=" + i + ")", i); } TreeSet<Integer> set = getSet(type); set.add(val); i++; return i; } if (c == 'W') { if (type == DAY_OF_MONTH) { nearestWeekday = true; } else { throw new ParseException("'W' option is not valid here. (pos=" + i + ")", i); } if(val > 31) throw new ParseException("The 'W' option does not make sense with values larger than 31 (max number of days in a month)", i); TreeSet<Integer> set = getSet(type); set.add(val); i++; return i; } if (c == '#') { if (type != DAY_OF_WEEK) { throw new ParseException("'#' option is not valid here. (pos=" + i + ")", i); } i++; try { nthdayOfWeek = Integer.parseInt(s.substring(i)); if (nthdayOfWeek < 1 || nthdayOfWeek > 5) { throw new Exception(); } } catch (Exception e) { throw new ParseException( "A numeric value between 1 and 5 must follow the '#' option", i); } TreeSet<Integer> set = getSet(type); set.add(val); i++; return i; } if (c == '-') { i++; c = s.charAt(i); int v = Integer.parseInt(String.valueOf(c)); end = v; i++; if (i >= s.length()) { addToSet(val, end, 1, type); return i; } c = s.charAt(i); if (c >= '0' && c <= '9') { ValueSet vs = getValue(v, s, i); end = vs.value; i = vs.pos; } if (i < s.length() && ((c = s.charAt(i)) == '/')) { i++; c = s.charAt(i); int v2 = Integer.parseInt(String.valueOf(c)); i++; if (i >= s.length()) { addToSet(val, end, v2, type); return i; } c = s.charAt(i); if (c >= '0' && c <= '9') { ValueSet vs = getValue(v2, s, i); int v3 = vs.value; addToSet(val, end, v3, type); i = vs.pos; return i; } else { addToSet(val, end, v2, type); return i; } } else { addToSet(val, end, 1, type); return i; } } if (c == '/') { if ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s.charAt(i + 1) == '\t') { throw new ParseException("'/' must be followed by an integer.", i); } i++; c = s.charAt(i); int v2 = Integer.parseInt(String.valueOf(c)); i++; if (i >= s.length()) { checkIncrementRange(v2, type, i); addToSet(val, end, v2, type); return i; } c = s.charAt(i); if (c >= '0' && c <= '9') { ValueSet vs = getValue(v2, s, i); int v3 = vs.value; checkIncrementRange(v3, type, i); addToSet(val, end, v3, type); i = vs.pos; return i; } else { throw new ParseException("Unexpected character '" + c + "' after '/'", i); } } addToSet(val, end, 0, type); i++; return i; } public String getCronExpression() { return cronExpression; } public String getExpressionSummary() { StringBuilder buf = new StringBuilder(); buf.append("seconds: "); buf.append(getExpressionSetSummary(seconds)); buf.append("\n"); buf.append("minutes: "); buf.append(getExpressionSetSummary(minutes)); buf.append("\n"); buf.append("hours: "); buf.append(getExpressionSetSummary(hours)); buf.append("\n"); buf.append("daysOfMonth: "); buf.append(getExpressionSetSummary(daysOfMonth)); buf.append("\n"); buf.append("months: "); buf.append(getExpressionSetSummary(months)); buf.append("\n"); buf.append("daysOfWeek: "); buf.append(getExpressionSetSummary(daysOfWeek)); buf.append("\n"); buf.append("lastdayOfWeek: "); buf.append(lastdayOfWeek); buf.append("\n"); buf.append("nearestWeekday: "); buf.append(nearestWeekday); buf.append("\n"); buf.append("NthDayOfWeek: "); buf.append(nthdayOfWeek); buf.append("\n"); buf.append("lastdayOfMonth: "); buf.append(lastdayOfMonth); buf.append("\n"); buf.append("years: "); buf.append(getExpressionSetSummary(years)); buf.append("\n"); return buf.toString(); } protected String getExpressionSetSummary(java.util.Set<Integer> set) { if (set.contains(NO_SPEC)) { return "?"; } if (set.contains(ALL_SPEC)) { return "*"; } StringBuilder buf = new StringBuilder(); Iterator<Integer> itr = set.iterator(); boolean first = true; while (itr.hasNext()) { Integer iVal = itr.next(); String val = iVal.toString(); if (!first) { buf.append(","); } buf.append(val); first = false; } return buf.toString(); } protected String getExpressionSetSummary(java.util.ArrayList<Integer> list) { if (list.contains(NO_SPEC)) { return "?"; } if (list.contains(ALL_SPEC)) { return "*"; } StringBuilder buf = new StringBuilder(); Iterator<Integer> itr = list.iterator(); boolean first = true; while (itr.hasNext()) { Integer iVal = itr.next(); String val = iVal.toString(); if (!first) { buf.append(","); } buf.append(val); first = false; } return buf.toString(); } protected int skipWhiteSpace(int i, String s) { for (; i < s.length() && (s.charAt(i) == ' ' || s.charAt(i) == '\t'); i++) { } return i; } protected int findNextWhiteSpace(int i, String s) { for (; i < s.length() && (s.charAt(i) != ' ' || s.charAt(i) != '\t'); i++) { } return i; } protected void addToSet(int val, int end, int incr, int type) throws ParseException { TreeSet<Integer> set = getSet(type); if (type == SECOND || type == MINUTE) { if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) { throw new ParseException( "Minute and Second values must be between 0 and 59", -1); } } else if (type == HOUR) { if ((val < 0 || val > 23 || end > 23) && (val != ALL_SPEC_INT)) { throw new ParseException( "Hour values must be between 0 and 23", -1); } } else if (type == DAY_OF_MONTH) { if ((val < 1 || val > 31 || end > 31) && (val != ALL_SPEC_INT) && (val != NO_SPEC_INT)) { throw new ParseException( "Day of month values must be between 1 and 31", -1); } } else if (type == MONTH) { if ((val < 1 || val > 12 || end > 12) && (val != ALL_SPEC_INT)) { throw new ParseException( "Month values must be between 1 and 12", -1); } } else if (type == DAY_OF_WEEK) { if ((val == 0 || val > 7 || end > 7) && (val != ALL_SPEC_INT) && (val != NO_SPEC_INT)) { throw new ParseException( "Day-of-Week values must be between 1 and 7", -1); } } if ((incr == 0 || incr == -1) && val != ALL_SPEC_INT) { if (val != -1) { set.add(val); } else { set.add(NO_SPEC); } return; } int startAt = val; int stopAt = end; if (val == ALL_SPEC_INT && incr <= 0) { incr = 1; set.add(ALL_SPEC); // put in a marker, but also fill values } if (type == SECOND || type == MINUTE) { if (stopAt == -1) { stopAt = 59; } if (startAt == -1 || startAt == ALL_SPEC_INT) { startAt = 0; } } else if (type == HOUR) { if (stopAt == -1) { stopAt = 23; } if (startAt == -1 || startAt == ALL_SPEC_INT) { startAt = 0; } } else if (type == DAY_OF_MONTH) { if (stopAt == -1) { stopAt = 31; } if (startAt == -1 || startAt == ALL_SPEC_INT) { startAt = 1; } } else if (type == MONTH) { if (stopAt == -1) { stopAt = 12; } if (startAt == -1 || startAt == ALL_SPEC_INT) { startAt = 1; } } else if (type == DAY_OF_WEEK) { if (stopAt == -1) { stopAt = 7; } if (startAt == -1 || startAt == ALL_SPEC_INT) { startAt = 1; } } else if (type == YEAR) { if (stopAt == -1) { stopAt = MAX_YEAR; } if (startAt == -1 || startAt == ALL_SPEC_INT) { startAt = 1970; } } // if the end of the range is before the start, then we need to overflow into // the next day, month etc. This is done by adding the maximum amount for that // type, and using modulus max to determine the value being added. int max = -1; if (stopAt < startAt) { switch (type) { case SECOND : max = 60; break; case MINUTE : max = 60; break; case HOUR : max = 24; break; case MONTH : max = 12; break; case DAY_OF_WEEK : max = 7; break; case DAY_OF_MONTH : max = 31; break; case YEAR : throw new IllegalArgumentException("Start year must be less than stop year"); default : throw new IllegalArgumentException("Unexpected type encountered"); } stopAt += max; } for (int i = startAt; i <= stopAt; i += incr) { if (max == -1) { // ie: there's no max to overflow over set.add(i); } else { // take the modulus to get the real value int i2 = i % max; // 1-indexed ranges should not include 0, and should include their max if (i2 == 0 && (type == MONTH || type == DAY_OF_WEEK || type == DAY_OF_MONTH) ) { i2 = max; } set.add(i2); } } } TreeSet<Integer> getSet(int type) { switch (type) { case SECOND: return seconds; case MINUTE: return minutes; case HOUR: return hours; case DAY_OF_MONTH: return daysOfMonth; case MONTH: return months; case DAY_OF_WEEK: return daysOfWeek; case YEAR: return years; default: return null; } } protected ValueSet getValue(int v, String s, int i) { char c = s.charAt(i); StringBuilder s1 = new StringBuilder(String.valueOf(v)); while (c >= '0' && c <= '9') { s1.append(c); i++; if (i >= s.length()) { break; } c = s.charAt(i); } ValueSet val = new ValueSet(); val.pos = (i < s.length()) ? i : i + 1; val.value = Integer.parseInt(s1.toString()); return val; } protected int getNumericValue(String s, int i) { int endOfVal = findNextWhiteSpace(i, s); String val = s.substring(i, endOfVal); return Integer.parseInt(val); } protected int getMonthNumber(String s) { Integer integer = monthMap.get(s); if (integer == null) { return -1; } return integer; } protected int getDayOfWeekNumber(String s) { Integer integer = dayMap.get(s); if (integer == null) { return -1; } return integer; } //////////////////////////////////////////////////////////////////////////// // // Computation Functions // //////////////////////////////////////////////////////////////////////////// public Date getTimeAfter(Date afterTime) { // Computation is based on Gregorian year only. Calendar cl = new java.util.GregorianCalendar(getTimeZone()); // move ahead one second, since we're computing the time *after* the // given time afterTime = new Date(afterTime.getTime() + 1000); // CronTrigger does not deal with milliseconds cl.setTime(afterTime); cl.set(Calendar.MILLISECOND, 0); boolean gotOne = false; // loop until we've computed the next time, or we've past the endTime while (!gotOne) { //if (endTime != null && cl.getTime().after(endTime)) return null; if(cl.get(Calendar.YEAR) > 2999) { // prevent endless loop... return null; } SortedSet<Integer> st = null; int t = 0; int sec = cl.get(Calendar.SECOND); int min = cl.get(Calendar.MINUTE); // get second................................................. st = seconds.tailSet(sec); if (st != null && st.size() != 0) { sec = st.first(); } else { sec = seconds.first(); min++; cl.set(Calendar.MINUTE, min); } cl.set(Calendar.SECOND, sec); min = cl.get(Calendar.MINUTE); int hr = cl.get(Calendar.HOUR_OF_DAY); t = -1; // get minute................................................. st = minutes.tailSet(min); if (st != null && st.size() != 0) { t = min; min = st.first(); } else { min = minutes.first(); hr++; } if (min != t) { cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, min); setCalendarHour(cl, hr); continue; } cl.set(Calendar.MINUTE, min); hr = cl.get(Calendar.HOUR_OF_DAY); int day = cl.get(Calendar.DAY_OF_MONTH); t = -1; // get hour................................................... st = hours.tailSet(hr); if (st != null && st.size() != 0) { t = hr; hr = st.first(); } else { hr = hours.first(); day++; } if (hr != t) { cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.DAY_OF_MONTH, day); setCalendarHour(cl, hr); continue; } cl.set(Calendar.HOUR_OF_DAY, hr); day = cl.get(Calendar.DAY_OF_MONTH); int mon = cl.get(Calendar.MONTH) + 1; // '+ 1' because calendar is 0-based for this field, and we are // 1-based t = -1; int tmon = mon; // get day................................................... boolean dayOfMSpec = !daysOfMonth.contains(NO_SPEC); boolean dayOfWSpec = !daysOfWeek.contains(NO_SPEC); if (dayOfMSpec && !dayOfWSpec) { // get day by day of month rule st = daysOfMonth.tailSet(day); if (lastdayOfMonth) { if(!nearestWeekday) { t = day; day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); day -= lastdayOffset; if(t > day) { mon++; if(mon > 12) { mon = 1; tmon = 3333; // ensure test of mon != tmon further below fails cl.add(Calendar.YEAR, 1); } day = 1; } } else { t = day; day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); day -= lastdayOffset; Calendar tcal = Calendar.getInstance(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0); tcal.set(Calendar.HOUR_OF_DAY, 0); tcal.set(Calendar.DAY_OF_MONTH, day); tcal.set(Calendar.MONTH, mon - 1); tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR)); int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); int dow = tcal.get(Calendar.DAY_OF_WEEK); if(dow == Calendar.SATURDAY && day == 1) { day += 2; } else if(dow == Calendar.SATURDAY) { day -= 1; } else if(dow == Calendar.SUNDAY && day == ldom) { day -= 2; } else if(dow == Calendar.SUNDAY) { day += 1; } tcal.set(Calendar.SECOND, sec); tcal.set(Calendar.MINUTE, min); tcal.set(Calendar.HOUR_OF_DAY, hr); tcal.set(Calendar.DAY_OF_MONTH, day); tcal.set(Calendar.MONTH, mon - 1); Date nTime = tcal.getTime(); if(nTime.before(afterTime)) { day = 1; mon++; } } } else if(nearestWeekday) { t = day; day = daysOfMonth.first(); Calendar tcal = Calendar.getInstance(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0); tcal.set(Calendar.HOUR_OF_DAY, 0); tcal.set(Calendar.DAY_OF_MONTH, day); tcal.set(Calendar.MONTH, mon - 1); tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR)); int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); int dow = tcal.get(Calendar.DAY_OF_WEEK); if(dow == Calendar.SATURDAY && day == 1) { day += 2; } else if(dow == Calendar.SATURDAY) { day -= 1; } else if(dow == Calendar.SUNDAY && day == ldom) { day -= 2; } else if(dow == Calendar.SUNDAY) { day += 1; } tcal.set(Calendar.SECOND, sec); tcal.set(Calendar.MINUTE, min); tcal.set(Calendar.HOUR_OF_DAY, hr); tcal.set(Calendar.DAY_OF_MONTH, day); tcal.set(Calendar.MONTH, mon - 1); Date nTime = tcal.getTime(); if(nTime.before(afterTime)) { day = daysOfMonth.first(); mon++; } } else if (st != null && st.size() != 0) { t = day; day = st.first(); // make sure we don't over-run a short month, such as february int lastDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); if (day > lastDay) { day = daysOfMonth.first(); mon++; } } else { day = daysOfMonth.first(); mon++; } if (day != t || mon != tmon) { cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.HOUR_OF_DAY, 0); cl.set(Calendar.DAY_OF_MONTH, day); cl.set(Calendar.MONTH, mon - 1); // '- 1' because calendar is 0-based for this field, and we // are 1-based continue; } } else if (dayOfWSpec && !dayOfMSpec) { // get day by day of week rule if (lastdayOfWeek) { // are we looking for the last XXX day of // the month? int dow = daysOfWeek.first(); // desired // d-o-w int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w int daysToAdd = 0; if (cDow < dow) { daysToAdd = dow - cDow; } if (cDow > dow) { daysToAdd = dow + (7 - cDow); } int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); if (day + daysToAdd > lDay) { // did we already miss the // last one? cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.HOUR_OF_DAY, 0); cl.set(Calendar.DAY_OF_MONTH, 1); cl.set(Calendar.MONTH, mon); // no '- 1' here because we are promoting the month continue; } // find date of last occurrence of this day in this month... while ((day + daysToAdd + 7) <= lDay) { daysToAdd += 7; } day += daysToAdd; if (daysToAdd > 0) { cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.HOUR_OF_DAY, 0); cl.set(Calendar.DAY_OF_MONTH, day); cl.set(Calendar.MONTH, mon - 1); // '- 1' here because we are not promoting the month continue; } } else if (nthdayOfWeek != 0) { // are we looking for the Nth XXX day in the month? int dow = daysOfWeek.first(); // desired // d-o-w int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w int daysToAdd = 0; if (cDow < dow) { daysToAdd = dow - cDow; } else if (cDow > dow) { daysToAdd = dow + (7 - cDow); } boolean dayShifted = false; if (daysToAdd > 0) { dayShifted = true; } day += daysToAdd; int weekOfMonth = day / 7; if (day % 7 > 0) { weekOfMonth++; } daysToAdd = (nthdayOfWeek - weekOfMonth) * 7; day += daysToAdd; if (daysToAdd < 0 || day > getLastDayOfMonth(mon, cl .get(Calendar.YEAR))) { cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.HOUR_OF_DAY, 0); cl.set(Calendar.DAY_OF_MONTH, 1); cl.set(Calendar.MONTH, mon); // no '- 1' here because we are promoting the month continue; } else if (daysToAdd > 0 || dayShifted) { cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.HOUR_OF_DAY, 0); cl.set(Calendar.DAY_OF_MONTH, day); cl.set(Calendar.MONTH, mon - 1); // '- 1' here because we are NOT promoting the month continue; } } else { int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w int dow = daysOfWeek.first(); // desired // d-o-w st = daysOfWeek.tailSet(cDow); if (st != null && st.size() > 0) { dow = st.first(); } int daysToAdd = 0; if (cDow < dow) { daysToAdd = dow - cDow; } if (cDow > dow) { daysToAdd = dow + (7 - cDow); } int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); if (day + daysToAdd > lDay) { // will we pass the end of // the month? cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.HOUR_OF_DAY, 0); cl.set(Calendar.DAY_OF_MONTH, 1); cl.set(Calendar.MONTH, mon); // no '- 1' here because we are promoting the month continue; } else if (daysToAdd > 0) { // are we swithing days? cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.HOUR_OF_DAY, 0); cl.set(Calendar.DAY_OF_MONTH, day + daysToAdd); cl.set(Calendar.MONTH, mon - 1); // '- 1' because calendar is 0-based for this field, // and we are 1-based continue; } } } else { // dayOfWSpec && !dayOfMSpec throw new UnsupportedOperationException( "Support for specifying both a day-of-week AND a day-of-month parameter is not implemented."); } cl.set(Calendar.DAY_OF_MONTH, day); mon = cl.get(Calendar.MONTH) + 1; // '+ 1' because calendar is 0-based for this field, and we are // 1-based int year = cl.get(Calendar.YEAR); t = -1; // test for expressions that never generate a valid fire date, // but keep looping... if (year > MAX_YEAR) { return null; } // get month................................................... st = months.tailSet(mon); if (st != null && st.size() != 0) { t = mon; mon = st.first(); } else { mon = months.first(); year++; } if (mon != t) { cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.HOUR_OF_DAY, 0); cl.set(Calendar.DAY_OF_MONTH, 1); cl.set(Calendar.MONTH, mon - 1); // '- 1' because calendar is 0-based for this field, and we are // 1-based cl.set(Calendar.YEAR, year); continue; } cl.set(Calendar.MONTH, mon - 1); // '- 1' because calendar is 0-based for this field, and we are // 1-based year = cl.get(Calendar.YEAR); t = -1; // get year................................................... st = years.tailSet(year); if (st != null && st.size() != 0) { t = year; year = st.first(); } else { return null; // ran out of years... } if (year != t) { cl.set(Calendar.SECOND, 0); cl.set(Calendar.MINUTE, 0); cl.set(Calendar.HOUR_OF_DAY, 0); cl.set(Calendar.DAY_OF_MONTH, 1); cl.set(Calendar.MONTH, 0); // '- 1' because calendar is 0-based for this field, and we are // 1-based cl.set(Calendar.YEAR, year); continue; } cl.set(Calendar.YEAR, year); gotOne = true; } // while( !done ) return cl.getTime(); } /** * Advance the calendar to the particular hour paying particular attention * to daylight saving problems. * * @param cal the calendar to operate on * @param hour the hour to set */ protected void setCalendarHour(Calendar cal, int hour) { cal.set(Calendar.HOUR_OF_DAY, hour); if (cal.get(Calendar.HOUR_OF_DAY) != hour && hour != 24) { cal.set(Calendar.HOUR_OF_DAY, hour + 1); } } /** * NOT YET IMPLEMENTED: Returns the time before the given time * that the <code>CronExpression</code> matches. */ public Date getTimeBefore(Date endTime) { // FUTURE_TODO: implement QUARTZ-423 return null; } /** * NOT YET IMPLEMENTED: Returns the final time that the * <code>CronExpression</code> will match. */ public Date getFinalFireTime() { // FUTURE_TODO: implement QUARTZ-423 return null; } protected boolean isLeapYear(int year) { return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)); } protected int getLastDayOfMonth(int monthNum, int year) { switch (monthNum) { case 1: return 31; case 2: return (isLeapYear(year)) ? 29 : 28; case 3: return 31; case 4: return 30; case 5: return 31; case 6: return 30; case 7: return 31; case 8: return 31; case 9: return 30; case 10: return 31; case 11: return 30; case 12: return 31; default: throw new IllegalArgumentException("Illegal month number: " + monthNum); } } private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, ClassNotFoundException { stream.defaultReadObject(); try { buildExpression(cronExpression); } catch (Exception ignore) { } // never happens } @Override @Deprecated public Object clone() { return new CronExpression(this); } } class ValueSet { public int value; public int pos; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/schedule/cron/CronExpression.java
Java
gpl-3.0
61,163
package com.zmops.iot.web.sys.controller; import com.zmops.iot.core.log.BussinessLog; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.web.auth.Permission; import com.zmops.iot.web.sys.dto.param.DictParam; import com.zmops.iot.web.sys.service.DictService; import com.zmops.iot.web.sys.service.DictTypeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** * 基础字典控制器 */ @RestController @RequestMapping("/dict") public class DictController { @Autowired private DictService dictService; @Autowired private DictTypeService dictTypeService; /** * 新增字典项 */ @Permission(code = "dict") @RequestMapping("/create") @BussinessLog("新增字典项") public ResponseData addItem(@Validated(BaseEntity.Create.class) @RequestBody DictParam dictParam) { return ResponseData.success(dictService.add(dictParam)); } /** * 编辑字典项 */ @Permission(code = "dict") @RequestMapping("/update") @BussinessLog("编辑字典项") public ResponseData editItem(@Validated(BaseEntity.Update.class) @RequestBody DictParam dictParam) { return ResponseData.success(dictService.update(dictParam)); } /** * 删除字典项 * * @author stylefeng */ @Permission(code = "dict") @RequestMapping("/delete") @BussinessLog("删除字典项") public ResponseData delete(@Validated(BaseEntity.MassRemove.class) @RequestBody DictParam dictParam) { dictService.delete(dictParam); return ResponseData.success(); } /** * 获取某个字典类型下的所有字典 */ @Permission(code = "dict") @ResponseBody @RequestMapping("/listDicts") public ResponseData listDicts(@RequestParam("dictTypeId") Long dictTypeId) { return ResponseData.success(dictService.listDicts(dictTypeId)); } /** * 获取某个字典类型下的所有字典 */ @ResponseBody @RequestMapping("/listDictByCode") public ResponseData listDictByCode(@RequestParam("dictTypeCode") String dictTypeCode) { return ResponseData.success(dictService.listDicts(dictTypeCode)); } /** * 获取某个字典类型下的所有字典 */ @ResponseBody @RequestMapping("/groupDictByCode") public ResponseData groupDictByCode(@RequestParam("dictTypeCode") String dictTypeCode) { return ResponseData.success(dictService.groupDictByCode(dictTypeCode)); } /** * 查看详情接口 * */ // @RequestMapping("/detail") // @ResponseBody // public ResponseData detail(DictParam dictParam) { // DictResult dictResult = this.dictService.dictDetail(dictParam.getDictId()); // return ResponseData.success(dictResult); // } /** * 查询列表 * */ // @ResponseBody // @RequestMapping("/list") // public LayuiPageInfo list(DictParam dictParam) { // return this.dictService.findPageBySpec(dictParam); // } /** * 获取某个字典类型下的所有字典 * */ // @ResponseBody // @RequestMapping("/listDictsByCode") // public ResponseData listDictsByCode(@RequestParam("dictTypeCode") String dictTypeCode) { // List<Dict> dicts = this.dictService.listDictsByCode(dictTypeCode); // return new SuccessResponseData(dicts); // } /** * 获取某个类型下字典树的列表,ztree格式 * */ // @RequestMapping(value = "/ztree") // @ResponseBody // public List<ZTreeNode> ztree(@RequestParam("dictTypeId") Long dictTypeId, @RequestParam(value = "dictId", required = false) Long dictId) { // return this.dictService.dictTreeList(dictTypeId, dictId); // } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/DictController.java
Java
gpl-3.0
3,930
package com.zmops.iot.web.sys.controller; import com.zmops.iot.core.log.BussinessLog; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.model.page.Pager; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.web.auth.Permission; import com.zmops.iot.web.sys.dto.param.DictTypeParam; import com.zmops.iot.web.sys.service.DictTypeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * 字典类型表控制器 */ @RestController @RequestMapping("/dictType") public class DictTypeController { @Autowired private DictTypeService dictTypeService; /** * 新增字典 */ @Permission(code = "dict") @RequestMapping("/create") @BussinessLog("新增字典") public ResponseData addItem(@Validated(BaseEntity.Create.class) @RequestBody DictTypeParam dictTypeParam) { return ResponseData.success(dictTypeService.add(dictTypeParam)); } /** * 编辑字典 */ @Permission(code = "dict") @RequestMapping("/update") @BussinessLog("编辑字典") public ResponseData editItem(@Validated(BaseEntity.Update.class) @RequestBody DictTypeParam dictTypeParam) { return ResponseData.success(dictTypeService.update(dictTypeParam)); } /** * 删除字典 */ @Permission(code = "dict") @RequestMapping("/delete") @BussinessLog("删除字典") public ResponseData delete(@Validated(BaseEntity.MassRemove.class) @RequestBody DictTypeParam dictTypeParam) { this.dictTypeService.delete(dictTypeParam); return ResponseData.success(); } /** * 查询列表 */ @Permission(code = "dict") @PostMapping("/getDictTypeByPage") public Pager list(@RequestBody DictTypeParam dictTypeParam) { return dictTypeService.findPageBySpec(dictTypeParam); } // /** // * 查看详情接口 // * // */ // @RequestMapping("/detail") // @ResponseBody // public ResponseData detail(DictTypeParam dictTypeParam) { // DictType detail = this.dictTypeService.getById(dictTypeParam.getDictTypeId()); // return ResponseData.success(detail); // } /** * 查询所有字典 * */ // @ResponseBody // @RequestMapping("/listTypes") // public ResponseData listTypes() { // // QueryWrapper<DictType> objectQueryWrapper = new QueryWrapper<>(); // objectQueryWrapper.select("dict_type_id", "code", "name"); // // List<DictType> list = this.dictTypeService.list(objectQueryWrapper); // return new SuccessResponseData(list); // } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/DictTypeController.java
Java
gpl-3.0
2,913
package com.zmops.iot.web.sys.controller; import com.google.code.kaptcha.Constants; import com.google.code.kaptcha.Producer; import com.zmops.iot.constant.ConstantsContext; import com.zmops.iot.core.util.FileUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import javax.imageio.ImageIO; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.awt.image.BufferedImage; import java.io.IOException; /** * @author nantian created at 2021/7/30 15:25 * <p> * 验证码 */ @Controller @RequestMapping("/kaptcha") public class KaptchaController { @Autowired private Producer producer; @RequestMapping("") public void index(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(); response.setDateHeader("Expires", 0); // Set standard HTTP/1.1 no-cache headers. response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // Set IE extended HTTP/1.1 no-cache headers (use addHeader). response.addHeader("Cache-Control", "post-check=0, pre-check=0"); // Set standard HTTP/1.0 no-cache header. response.setHeader("Pragma", "no-cache"); // return a jpeg response.setContentType("image/jpeg"); // create the text for the image String capText = producer.createText(); // store the text in the session session.setAttribute(Constants.KAPTCHA_SESSION_KEY, capText); // create the image with the text BufferedImage bi = producer.createImage(capText); ServletOutputStream out = null; try { out = response.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } // write the data out try { ImageIO.write(bi, "jpg", out); } catch (IOException e) { e.printStackTrace(); } try { try { out.flush(); } catch (IOException e) { e.printStackTrace(); } } finally { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } /** * 返回图片 */ @RequestMapping("/{pictureId}") public void renderPicture(@PathVariable("pictureId") String pictureId, HttpServletResponse response) { String path = ConstantsContext.getFileUploadPath() + pictureId; try { byte[] bytes = FileUtil.toByteArray(path); response.getOutputStream().write(bytes); } catch (Exception e) { //如果找不到图片就返回一个默认图片 try { response.sendRedirect("/static/img/girl.gif"); } catch (IOException e1) { e1.printStackTrace(); } } } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/KaptchaController.java
Java
gpl-3.0
3,206
package com.zmops.iot.web.sys.controller; import com.zmops.iot.model.page.Pager; import com.zmops.iot.web.auth.Permission; import com.zmops.iot.web.sys.dto.SysOperationLogDto; import com.zmops.iot.web.sys.service.OperationLogService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; /** * @author yefei **/ @RestController @RequestMapping("/log") public class LogController { @Autowired private OperationLogService operationLogService; /** * 查询操作日志列表 */ @Permission(code = "businessLog") @RequestMapping("/getOperationLogByPage") @ResponseBody public Pager<SysOperationLogDto> list(@RequestParam(required = false) Long beginTime, @RequestParam(required = false) Long endTime, @RequestParam(required = false) String logName, @RequestParam(required = false) String logType, @RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "20") int maxRow) { return operationLogService.list(beginTime, endTime, logName, logType, page, maxRow); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/LogController.java
Java
gpl-3.0
1,534
package com.zmops.iot.web.sys.controller; import com.google.code.kaptcha.Constants; import com.zmops.iot.constant.ConstantsContext; import com.zmops.iot.core.auth.context.LoginContextHolder; import com.zmops.iot.core.web.base.BaseController; import com.zmops.iot.model.exception.InvalidKaptchaException; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.model.response.SuccessResponseData; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.auth.AuthService; import com.zmops.iot.web.sys.dto.param.LoginParam; import com.zmops.iot.web.sys.service.SysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.validation.Valid; import java.util.Map; /** * @author nantian created at 2021/7/29 19:55 * <p> * 登陆 */ @Controller public class LoginController extends BaseController { @Autowired private AuthService authService; @Autowired private SysUserService userService; /** * 跳转到主页 */ @RequestMapping(value = "/", method = RequestMethod.GET) public String reindex(Model model) { if (LoginContextHolder.getContext().hasLogin()) { Map<String, Object> userIndexInfo = userService.getUserIndexInfo(); if (userIndexInfo == null) { return "/login"; } else { model.addAllAttributes(userIndexInfo); return "/index"; } } else { return "/index"; } } /** * 跳转到登录页面 */ @RequestMapping(value = "/login", method = RequestMethod.GET) public String login() { if (LoginContextHolder.getContext().hasLogin()) { return REDIRECT + "/"; } else { return "/index"; } } /** * 登录返回用户信息 * * @param loginParam 登陆参数 * @return */ @ResponseBody @RequestMapping(value = "/login", method = RequestMethod.POST) public ResponseData loginVali(@Valid @RequestBody LoginParam loginParam) { String username = loginParam.getUsername(); String password = loginParam.getPassword(); if (ConstantsContext.getKaptchaOpen()) { String kaptcha = super.getPara("kaptcha").trim(); String code = (String) super.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); if (ToolUtil.isEmpty(kaptcha) || !kaptcha.equalsIgnoreCase(code)) { throw new InvalidKaptchaException(); } } return new SuccessResponseData(authService.login(username, password)); } /** * 退出登录 */ @ResponseBody @RequestMapping(value = "/logout") public ResponseData logOut() { authService.logout(); return new SuccessResponseData(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/LoginController.java
Java
gpl-3.0
3,169
package com.zmops.iot.web.sys.controller; import com.zmops.iot.model.page.Pager; import com.zmops.iot.web.auth.Permission; import com.zmops.iot.web.sys.dto.SysLoginLogDto; import com.zmops.iot.web.sys.service.LoginLogService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; /** * @author yefei **/ @RestController @RequestMapping("/loginLog") public class LoginLogController { @Autowired private LoginLogService loginLogService; /** * 登录日志列表 */ @Permission(code = "businessLog") @RequestMapping("/getLoginLogByPage") @ResponseBody public Pager<SysLoginLogDto> list(@RequestParam(required = false) Long beginTime, @RequestParam(required = false) Long endTime, @RequestParam(required = false) String logName, @RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "20") int maxRow) { return loginLogService.list(beginTime, endTime, logName, page, maxRow); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/LoginLogController.java
Java
gpl-3.0
1,395
package com.zmops.iot.web.sys.controller; import com.zmops.iot.core.auth.context.LoginContextHolder; import com.zmops.iot.core.auth.model.LoginUser; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import io.ebean.DB; import io.ebean.SqlRow; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @author nantian created at 2021/8/1 21:56 * <p> * 系统菜单 */ @RequestMapping("/sys/menu") @RestController public class SysMenuController { /** * 获取 菜单列表及按钮 * * @return */ @RequestMapping("/list") public ResponseData getMenuList() { LoginUser user = LoginContextHolder.getContext().getUser(); List<Long> roleList = user.getRoleList(); if (ToolUtil.isEmpty(roleList)) { throw new ServiceException(BizExceptionEnum.USER_NOT_BIND_ROLE); } String sql = "select " + " m1.menu_id AS id," + " ( CASE WHEN ( m2.menu_id = 0 OR m2.menu_id IS NULL ) THEN 0 ELSE m2.menu_id END ) AS pId," + " m1.NAME AS NAME," + " m1.url," + " m1.icon," + " m1.menu_flag " + " FROM " + " sys_menu m1" + " LEFT JOIN sys_menu m2 ON m1.pcode = m2.CODE " + " WHERE" + " m1.status = 'ENABLE' " + " AND m1.menu_id in (select menu_id from sys_role_menu where role_id in (:roleIds))" + " ORDER BY" + " m1.menu_id ASC"; List<SqlRow> menuList = DB.sqlQuery(sql).setParameter("roleIds", roleList).findList(); Map<String, List> map = new HashMap<>(2); map.put("menu", menuList.parallelStream().filter(x -> "Y".equals(x.getString("menu_flag"))).collect(Collectors.toList())); map.put("button", menuList.parallelStream().filter(x -> "N".equals(x.getString("menu_flag"))).map(x -> x.getString("url")).collect(Collectors.toList())); return ResponseData.success(map); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/SysMenuController.java
Java
gpl-3.0
2,403
package com.zmops.iot.web.sys.controller; import com.zmops.iot.core.log.BussinessLog; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.web.auth.Permission; import com.zmops.iot.web.sys.dto.SysParamDto; import com.zmops.iot.web.sys.service.SysParamService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** * @author nantian created at 2021/8/1 21:57 * <p> * 系统参数 */ @RestController @RequestMapping("/sys/param") public class SysParamController { @Autowired SysParamService sysParamService; /** * 参数列表 */ @Permission(code = "sysParam") @GetMapping("/list") public ResponseData list() { return ResponseData.success(sysParamService.list()); } /** * 参数修改 */ @Permission(code = "sysParam") @PostMapping("/update") @BussinessLog(value = "系统参数修改") public ResponseData update(@Validated @RequestBody SysParamDto sysParamDto) { sysParamService.update(sysParamDto); return ResponseData.success(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/SysParamController.java
Java
gpl-3.0
1,181
package com.zmops.iot.web.sys.controller; import com.zmops.iot.core.log.BussinessLog; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.web.auth.Permission; import com.zmops.iot.web.sys.dto.SysRoleDto; import com.zmops.iot.web.sys.dto.param.RoleParam; import com.zmops.iot.web.sys.service.SysRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** * @author nantian created at 2021/8/1 21:57 * <p> * 角色管理 */ @RestController @RequestMapping("/sys/role") public class SysRoleController { @Autowired SysRoleService sysRoleService; /** * 角色列表 */ @RequestMapping("/list") public ResponseData list(@RequestParam(value = "name", required = false) String name) { return ResponseData.success(sysRoleService.list(name)); } /** * 角色新增 */ @Permission(code = "role") @RequestMapping("/create") @BussinessLog(value = "角色新增") public ResponseData create(@Validated(BaseEntity.Create.class) @RequestBody SysRoleDto sysRoleDto) { return ResponseData.success(sysRoleService.create(sysRoleDto)); } /** * 角色修改 */ @Permission(code = "role") @RequestMapping("/update") @BussinessLog(value = "角色修改") public ResponseData update(@Validated(BaseEntity.Update.class) @RequestBody SysRoleDto sysRoleDto) { return ResponseData.success(sysRoleService.update(sysRoleDto)); } /** * 角色删除 */ @Permission(code = "role") @RequestMapping("/delete") @BussinessLog(value = "角色删除") public ResponseData delete(@Validated(BaseEntity.Delete.class) @RequestBody RoleParam sysRoleParam) { sysRoleService.delete(sysRoleParam); return ResponseData.success(); } /** * 绑定菜单 * * @return */ @Permission(code = "role") @RequestMapping("/bindMenu") @BussinessLog(value = "角色绑定菜单") public ResponseData bindMenu(@Validated @RequestBody RoleParam roleParam) { sysRoleService.bindMenu(roleParam); return ResponseData.success(); } /** * 角色已绑定的菜单 */ @Permission(code = "role") @RequestMapping("/bindedMenu") public ResponseData bindMenu(@RequestParam(value = "roleId") Long roleId) { return ResponseData.success(sysRoleService.bindedMenu(roleId)); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/SysRoleController.java
Java
gpl-3.0
2,773
package com.zmops.iot.web.sys.controller; import com.zmops.iot.core.log.BussinessLog; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.domain.sys.SysUser; import com.zmops.iot.domain.sys.query.QSysUser; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.model.page.Pager; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.auth.Permission; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.sys.dto.UserDto; import com.zmops.iot.web.sys.dto.param.UserParam; import com.zmops.iot.web.sys.service.SysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; /** * @author nantian created at 2021/8/1 21:56 * <p> * 用户管理 */ @RestController @RequestMapping("/sys/user") public class SysUserController { @Autowired SysUserService sysUserService; /** * 用户分页列表 * * @return */ @Permission(code = "mgr") @PostMapping("/getUserByPage") public Pager<UserDto> userList(@RequestBody UserParam userParam) { return sysUserService.userList(userParam); } /** * 用户列表 * * @return */ @Permission(code = "mgr") @PostMapping("/list") public ResponseData list(@RequestBody UserParam userParam) { QSysUser qSysUser = new QSysUser(); if (ToolUtil.isNotEmpty(userParam.getName())) { qSysUser.name.contains(userParam.getName()); } return ResponseData.success(qSysUser.findList()); } /** * 创建用户 * * @return */ @Permission(code = "mgr") @PostMapping("/create") @BussinessLog(value = "创建用户") public ResponseData createUser(@Validated(BaseEntity.Create.class) @RequestBody UserDto sysUser) { return ResponseData.success(sysUserService.createUser(sysUser)); } /** * 更新用户 * * @return */ @Permission(code = "mgr") @PostMapping("/update") @BussinessLog(value = "更新用户") public ResponseData updateUser(@Validated(value = BaseEntity.Update.class) @RequestBody UserDto userDto) { return ResponseData.success(sysUserService.updateUser(userDto)); } /** * 删除用户 * * @return */ @Permission(code = "mgr") @PostMapping("/delete") @BussinessLog(value = "删除用户") public ResponseData deleteUser(@Validated(BaseEntity.Delete.class) @RequestBody UserParam user) { sysUserService.deleteUser(user); return ResponseData.success(); } /** * 修改密码 */ @Permission(code = "mgr") @PostMapping("/changePwd") @BussinessLog(value = "修改密码") public ResponseData changePwd(@Valid @RequestBody UserParam user) { sysUserService.changePwd(user.getOldPassword(), user.getNewPassword()); return ResponseData.success(); } /** * 重置管理员的密码 */ @Permission(code = "mgr") @RequestMapping("/reset") @BussinessLog(value = "重置密码") public ResponseData reset(@RequestParam("userId") Long userId) { if (userId == 1) { throw new ServiceException(BizExceptionEnum.CANT_CHANGE_ADMIN_PWD); } sysUserService.reset(userId); return ResponseData.success(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/SysUserController.java
Java
gpl-3.0
3,542
package com.zmops.iot.web.sys.controller; import com.zmops.iot.core.log.BussinessLog; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.model.page.Pager; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.web.auth.Permission; import com.zmops.iot.web.sys.dto.UserGroupDto; import com.zmops.iot.web.sys.dto.param.UserGroupParam; import com.zmops.iot.web.sys.service.SysUserGroupService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @author yefei created at 2021/8/1 13:56 * <p> * 用户组管理 */ @RestController @RequestMapping("/sys/userGroup") public class SysUserGroupController { @Autowired SysUserGroupService sysUserGroupService; /** * 用户组分页列表 * * @return */ @Permission(code = "usrGrp") @PostMapping("/getUsrGrpByPage") public Pager<UserGroupDto> getUsrGrpByPage(@RequestBody UserGroupParam userGroupParam) { return sysUserGroupService.userGroupPageList(userGroupParam); } /** * 用户组列表 * * @return */ @Permission(code = "usrGrp") @PostMapping("/list") public ResponseData userGroupList() { return ResponseData.success(sysUserGroupService.userGroupList()); } /** * 创建用户组 * * @return */ @Permission(code = "usrGrp") @PostMapping("/create") @BussinessLog(value = "创建用户组") public ResponseData createUserGroup(@Validated @RequestBody UserGroupDto userGroup) { return ResponseData.success(sysUserGroupService.createUserGroup(userGroup)); } /** * 更新用户组 * * @return */ @Permission(code = "usrGrp") @PostMapping("/update") @BussinessLog(value = "更新用户组") public ResponseData updateUserGroup(@Validated(BaseEntity.Update.class) @RequestBody UserGroupDto userGroup) { return ResponseData.success(sysUserGroupService.updateUserGroup(userGroup)); } /** * 删除用户组 * * @return */ @Permission(code = "usrGrp") @PostMapping("/delete") @BussinessLog(value = "删除用户组") public ResponseData deleteUserGroup(@Validated @RequestBody UserGroupParam userGroup) { sysUserGroupService.deleteUserGroup(userGroup); return ResponseData.success(); } /** * 用户组绑定主机组 * * @return */ @Permission(code = "usrGrp") @PostMapping("/bindHostGrp") @BussinessLog(value = "用户组绑定主机组") public ResponseData bindHostGrp(@Validated(BaseEntity.BindDevice.class) @RequestBody UserGroupParam userGroup) { sysUserGroupService.bindHostGrp(userGroup); return ResponseData.success(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/SysUserGroupController.java
Java
gpl-3.0
3,056
package com.zmops.iot.web.sys.controller; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.domain.sys.SysUser; import com.zmops.iot.domain.sys.query.QSysUser; import com.zmops.iot.domain.tenant.TenantInfo; import com.zmops.iot.domain.tenant.query.QTenantInfo; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.model.page.Pager; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.web.auth.Permission; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.sys.dto.TenantInfoDto; import com.zmops.iot.web.sys.dto.param.TenantInfoParam; import com.zmops.iot.web.sys.service.SysUserService; import com.zmops.iot.web.sys.service.Tenantervice; import io.ebean.DB; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** * @author yefei **/ @RestController @RequestMapping("/tenant") public class TenantController { @Autowired Tenantervice tenantervice; @Autowired SysUserService sysUserService; /** * 租户列表 * * @return */ @Permission(code = "tenant_list") @PostMapping("/getTenantByPage") public Pager<TenantInfoDto> userList(@RequestBody TenantInfoParam tenantInfoParam) { return tenantervice.getTenantByPage(tenantInfoParam); } /** * 创建租户 * * @return */ @Permission(code = "tenant_add") @PostMapping("/create") public ResponseData createTenant(@Validated(BaseEntity.Create.class) @RequestBody TenantInfoParam tenantInfoParam) { int count = new QTenantInfo().name.eq(tenantInfoParam.getName()).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.TENANT_NAME_EXISTS); } count = new QTenantInfo().account.eq(tenantInfoParam.getAccount()).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.TENANT_ACCOUNT_EXISTS); } return ResponseData.success(tenantervice.createTenant(tenantInfoParam)); } /** * 更新租户 * * @return */ @Permission(code = "tenant_update") @PostMapping("/update") public ResponseData updateTenant(@Validated(value = BaseEntity.Update.class) @RequestBody TenantInfoParam tenantInfoParam) { int count = new QTenantInfo().name.eq(tenantInfoParam.getName()).tenantId.ne(tenantInfoParam.getTenantId()).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.TENANT_NAME_EXISTS); } return ResponseData.success(tenantervice.updateTenant(tenantInfoParam)); } /** * 删除租户 * * @return */ @Permission(code = "tenant_delete") @PostMapping("/delete") public ResponseData deleteTenant(@Validated(BaseEntity.Delete.class) @RequestBody TenantInfoParam tenantInfoParam) { tenantervice.deleteTenant(tenantInfoParam); return ResponseData.success(); } /** * 租户状态修改 * * @return */ @Permission(code = "tenant_update") @RequestMapping("/status") public ResponseData status(@RequestParam("tenantId") Long tenantId, @RequestParam("status") String status) { tenantervice.status(tenantId,status); return ResponseData.success(); } /** * 租户详情 * * @return */ @Permission(code = "tenant_update") @RequestMapping("/detail") public ResponseData detail(@RequestParam Long tenantId) { TenantInfoDto tenantInfoDto = new QTenantInfo().tenantId.eq(tenantId).asDto(TenantInfoDto.class).findOne(); return ResponseData.success(tenantInfoDto); } /** * 重置密码 * * @return */ @RequestMapping("/reset") @Permission(code = "reset") public ResponseData reset(@RequestParam("account") String account) { SysUser sysUser = new QSysUser().account.eq(account).findOne(); if (sysUser == null) { throw new ServiceException(BizExceptionEnum.TENANT_NOT_EXISTS); } sysUserService.reset(sysUser.getUserId()); return ResponseData.success(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/controller/TenantController.java
Java
gpl-3.0
4,262
/** * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) * <p> * Licensed 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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. */ package com.zmops.iot.web.sys.dto; import com.zmops.iot.domain.sys.SysUser; import lombok.Data; /** * 用户传输bean * * @author stylefeng */ @Data public class LoginUserDto { private Long userId; private String account; private Long tenantId; private String name; private String token; public static LoginUserDto buildLoginUser(SysUser sysUser, String token) { LoginUserDto loginUserDto = new LoginUserDto(); loginUserDto.setUserId(sysUser.getUserId()); loginUserDto.setAccount(sysUser.getAccount()); loginUserDto.setName(sysUser.getName()); loginUserDto.setToken(token); return loginUserDto; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/LoginUserDto.java
Java
gpl-3.0
1,339
package com.zmops.iot.web.sys.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.zmops.iot.model.cache.filter.CachedValue; import com.zmops.iot.model.cache.filter.CachedValueFilter; import lombok.Data; import java.time.LocalDateTime; /** * <p> * 基础字典 * </p> */ @Data @JsonSerialize(using = CachedValueFilter.class) public class SysDictDto { /** * 字典id */ private Long dictId; /** * 所属字典类型的id */ private Long dictTypeId; /** * 字典编码 */ private String code; /** * 字典名称 */ private String name; /** * 状态 */ @CachedValue(value = "STATUS", fieldName = "statusName") private String status; /** * 排序 */ private Integer sort; /** * 字典的描述 */ private String remark; private String groups; LocalDateTime createTime; LocalDateTime updateTime; Long createUser; Long updateUser; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/SysDictDto.java
Java
gpl-3.0
1,023
package com.zmops.iot.web.sys.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.zmops.iot.model.cache.filter.CachedValue; import com.zmops.iot.model.cache.filter.CachedValueFilter; import lombok.Data; import java.time.LocalDateTime; /** * <p> * 字典类型表 * </p> */ @Data @JsonSerialize(using = CachedValueFilter.class) public class SysDictTypeDto { /** * 字典类型id */ private Long dictTypeId; /** * 字典类型编码 */ private String code; /** * 字典类型名称 */ private String name; /** * 字典描述 */ private String remark; /** * 是否是系统字典,Y-是,N-否 */ private String systemFlag = "N"; /** * 状态 */ @CachedValue(value = "STATUS", fieldName = "statusName") private String status; /** * 排序 */ private Integer sort; LocalDateTime createTime; LocalDateTime updateTime; Long createUser; Long updateUser; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/SysDictTypeDto.java
Java
gpl-3.0
1,044
package com.zmops.iot.web.sys.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.zmops.iot.model.cache.filter.CachedValue; import com.zmops.iot.model.cache.filter.CachedValueFilter; import com.zmops.iot.model.cache.filter.DicType; import lombok.Data; import java.time.LocalDateTime; /** * @author nantian created at 2021/7/31 18:20 */ @Data @JsonSerialize(using = CachedValueFilter.class) public class SysLoginLogDto { long loginLogId; String logName; @CachedValue(type = DicType.SysUserName, fieldName = "userName") Long userId; LocalDateTime createTime; String succeed; String message; String ipAddress; private Long tenantId; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/SysLoginLogDto.java
Java
gpl-3.0
710
package com.zmops.iot.web.sys.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.zmops.iot.model.cache.filter.CachedValue; import com.zmops.iot.model.cache.filter.CachedValueFilter; import com.zmops.iot.model.cache.filter.DicType; import lombok.Data; import java.time.LocalDateTime; /** * @author nantian created at 2021/8/1 22:04 */ @Data @JsonSerialize(using = CachedValueFilter.class) public class SysOperationLogDto { private Long operationLogId; private String logType; private String logName; @CachedValue(type = DicType.SysUserName, fieldName = "userName") private Long userId; private String className; private String method; private String succeed; private String message; private LocalDateTime createTime; private Long tenantId; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/SysOperationLogDto.java
Java
gpl-3.0
830
package com.zmops.iot.web.sys.dto; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.util.List; /** * @author nantian created at 2021/8/1 20:51 */ @Data public class SysParamDto { @NotNull private List<SysParam> sysParamList; @Data public static class SysParam { private Long id; /** * 名称 */ @NotBlank private String name; /** * 属性值,如果是字典中的类型,则为dict的code */ @NotBlank private String value; /** * 备注 */ private String remark; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/SysParamDto.java
Java
gpl-3.0
700
package com.zmops.iot.web.sys.dto; import com.zmops.iot.domain.BaseEntity; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** * @author yefei **/ @Data public class SysRoleDto { @NotNull(groups = BaseEntity.Update.class) private Long roleId; @NotBlank(groups = {BaseEntity.Update.class, BaseEntity.Create.class}) private String name; private String remark; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/SysRoleDto.java
Java
gpl-3.0
451
package com.zmops.iot.web.sys.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.zmops.iot.model.cache.filter.CachedValue; import com.zmops.iot.model.cache.filter.CachedValueFilter; import com.zmops.iot.model.cache.filter.DicType; import lombok.Data; import java.io.Serializable; import java.time.LocalDateTime; /** * @author yefei */ @Data @JsonSerialize(using = CachedValueFilter.class) public class TenantInfoDto implements Serializable { /** * 主键id */ private Long tenantId; /** * 租户名称 */ private String name; /** * 备注 */ private String remark; /** * 租户管理员账号 */ private String account; /** * 租户联系人 */ private String contact; /** * 租户联系人电话 */ private String phone; private int userNum; LocalDateTime createTime; LocalDateTime updateTime; @CachedValue(type = DicType.SysUserName, fieldName = "createUserName") Long createUser; @CachedValue(type = DicType.SysUserName, fieldName = "updateUserName") Long updateUser; @CachedValue(value = "STATUS", fieldName = "statusName") private String status; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/TenantInfoDto.java
Java
gpl-3.0
1,245
/** * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) * <p> * Licensed 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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. */ package com.zmops.iot.web.sys.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.model.cache.filter.CachedValue; import com.zmops.iot.model.cache.filter.CachedValueFilter; import com.zmops.iot.model.cache.filter.DicType; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** * 用户传输bean * * @author stylefeng */ @Data @JsonSerialize(using = CachedValueFilter.class) public class UserDto { @NotNull(groups = BaseEntity.Update.class) private Long userId; @NotBlank(groups = {BaseEntity.Create.class}) private String account; @NotBlank(groups = {BaseEntity.Create.class}) private String password; @NotBlank(groups = {BaseEntity.Create.class, BaseEntity.Update.class}) private String name; private String email; private String phone; @NotNull(groups = {BaseEntity.Create.class, BaseEntity.Update.class}) private Long userGroupId; @CachedValue(value = "STATUS", fieldName = "statusName") private String status; @NotNull(groups = {BaseEntity.Create.class, BaseEntity.Update.class}) private Long roleId; @CachedValue(type = DicType.Tenant, fieldName = "tenantName") private Long tenantId; private String roleName; private String userGroupName; @CachedValue(type = DicType.SysUserName, fieldName = "createUserName") private Long createUser; private String createTime; @CachedValue(type = DicType.SysUserName, fieldName = "updateUserName") private Long updateUser; private String updateTime; private String remark; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/UserDto.java
Java
gpl-3.0
2,331
/** * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) * <p> * Licensed 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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. */ package com.zmops.iot.web.sys.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.model.cache.filter.CachedValue; import com.zmops.iot.model.cache.filter.CachedValueFilter; import com.zmops.iot.model.cache.filter.DicType; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.time.LocalDateTime; import java.util.List; /** * 用户组传输bean * * @author yefei */ @Data @JsonSerialize(using = CachedValueFilter.class) public class UserGroupDto { @NotNull(groups = BaseEntity.Update.class) private Long userGroupId; @NotBlank private String groupName; @CachedValue(value = "STATUS", fieldName = "statusName") private String status; private String remark; private List<Long> deviceGroupIds; //列表返回的设备组ID private String groupIds; LocalDateTime createTime; LocalDateTime updateTime; @CachedValue(type = DicType.SysUserName, fieldName = "createUserName") Long createUser; @CachedValue(type = DicType.SysUserName, fieldName = "updateUserName") Long updateUser; @CachedValue(type = DicType.Tenant, fieldName = "tenantName") private Long tenantId; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/UserGroupDto.java
Java
gpl-3.0
1,948
package com.zmops.iot.web.sys.dto.param; import lombok.Data; /** * @author yefei **/ @Data public class BaseQueryParam { private int page = 1; private int maxRow = 10; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/param/BaseQueryParam.java
Java
gpl-3.0
182
package com.zmops.iot.web.sys.dto.param; import com.zmops.iot.domain.BaseEntity; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.List; /** * <p> * 基础字典 * </p> * * @author stylefeng */ @Data public class DictParam implements Serializable { private static final long serialVersionUID = 1L; /** * 字典id */ @NotNull(groups = {BaseEntity.Update.class, BaseEntity.Get.class}) private Long dictId; /** * 所属字典类型的id */ @NotNull(groups = {BaseEntity.Create.class, BaseEntity.Update.class}) private Long dictTypeId; /** * 所属字典类型的code */ private List<String> dictTypeCodes; /** * 字典编码 */ @NotBlank(groups = {BaseEntity.Create.class}) private String code; /** * 字典名称 */ @NotBlank(groups = {BaseEntity.Create.class}) private String name; /** * 状态(字典) */ private String status; /** * 字典的描述 */ private String remark; /** * 查询条件 */ private String condition; private Integer sort; @NotNull(groups = {BaseEntity.MassRemove.class}) private List<Long> dictIds; private String dictTypeCode; private Integer page = 1; private Integer size = 10; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/param/DictParam.java
Java
gpl-3.0
1,433
package com.zmops.iot.web.sys.dto.param; import com.zmops.iot.domain.BaseEntity; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.List; /** * <p> * 字典类型表 * </p> * * @author stylefeng */ @Data public class DictTypeParam extends BaseQueryParam { /** * 字典类型id */ @NotNull(groups = {BaseEntity.Update.class, BaseEntity.Get.class}) private Long dictTypeId; /** * 字典类型编码 */ @NotBlank(groups = {BaseEntity.Create.class}) private String code; /** * 字典类型名称 */ @NotBlank(groups = {BaseEntity.Create.class}) private String name; /** * 字典描述 */ private String remark; /** * 状态(字典) */ private String status; /** * 查询条件 */ private String condition; @NotEmpty(groups = {BaseEntity.MassRemove.class}) private List<Long> dictTypeIds; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/param/DictTypeParam.java
Java
gpl-3.0
1,057
/** * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) * <p> * Licensed 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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. */ package com.zmops.iot.web.sys.dto.param; import lombok.Data; import javax.validation.constraints.NotBlank; /** * 用户组参数 * * @author yefei */ @Data public class LoginParam { @NotBlank private String username; @NotBlank private String password; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/param/LoginParam.java
Java
gpl-3.0
931
/** * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) * <p> * Licensed 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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. */ package com.zmops.iot.web.sys.dto.param; import com.zmops.iot.domain.BaseEntity; import lombok.Data; import javax.validation.constraints.NotNull; import java.util.List; /** * 用户参数 * * @author yefei */ @Data public class RoleParam { @NotNull private Long roleId; @NotNull(groups = BaseEntity.Delete.class) private List<Long> roleIds; @NotNull private List<Long> menuIds; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/param/RoleParam.java
Java
gpl-3.0
1,065
package com.zmops.iot.web.sys.dto.param; import com.zmops.iot.domain.BaseEntity; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; /** * @author yefei */ @Data public class TenantInfoParam extends BaseQueryParam { /** * 主键id */ @NotNull(groups = {BaseEntity.Update.class, BaseEntity.Delete.class}) private Long tenantId; /** * 租户名称 */ @NotBlank(groups = {BaseEntity.Update.class, BaseEntity.Create.class}) private String name; private String status; /** * 备注 */ private String remark; /** * 租户管理员账号 */ @NotBlank(groups = BaseEntity.Create.class) private String account; /** * 租户管理员账号密码 */ @NotBlank(groups = BaseEntity.Create.class) private String password; /** * 租户联系人 */ private String contact; /** * 租户联系人电话 */ @Pattern(regexp = "^[1][3,4,5,7,8][0-9]{9}$",message = "电话号码格式不正确") private String phone; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/param/TenantInfoParam.java
Java
gpl-3.0
1,167
/** * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) * <p> * Licensed 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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. */ package com.zmops.iot.web.sys.dto.param; import com.zmops.iot.domain.BaseEntity; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import javax.validation.constraints.NotNull; import java.util.List; /** * 用户组参数 * * @author yefei */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class UserGroupParam extends BaseQueryParam { private String groupName; private String status; @NotNull private List<Long> userGroupIds; @NotNull(groups = BaseEntity.BindDevice.class) private Long userGroupId; @NotNull(groups = BaseEntity.BindDevice.class) private List<Long> deviceGroupIds; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/param/UserGroupParam.java
Java
gpl-3.0
1,352
/** * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) * <p> * Licensed 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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. */ package com.zmops.iot.web.sys.dto.param; import com.zmops.iot.domain.BaseEntity; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.util.List; /** * 用户参数 * * @author yefei */ @Data public class UserParam extends BaseQueryParam { private String name; private String status; @NotBlank(groups = BaseEntity.Update.class) private String oldPassword; @NotBlank(groups = BaseEntity.Update.class) private String newPassword; @NotNull(groups = BaseEntity.Delete.class) private List<Long> userIds; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/dto/param/UserParam.java
Java
gpl-3.0
1,265
/** * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) * <p> * Licensed 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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. */ package com.zmops.iot.web.sys.factory; import cn.hutool.core.bean.BeanUtil; import com.zmops.iot.constant.ConstantsContext; import com.zmops.iot.core.auth.context.LoginContextHolder; import com.zmops.iot.core.auth.model.LoginUser; import com.zmops.iot.domain.sys.SysUser; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.constant.state.ManagerStatus; import com.zmops.iot.web.sys.dto.UserDto; import org.springframework.beans.BeanUtils; import java.util.HashMap; import java.util.Map; /** * 用户创建工厂 * * @author fengshuonan */ public class UserFactory { /** * 根据请求创建实体 */ public static SysUser createUser(UserDto userDto, String md5Password, String salt) { if (userDto == null) { return null; } else { SysUser user = new SysUser(); BeanUtils.copyProperties(userDto, user); user.setStatus(ManagerStatus.OK.getCode()); user.setPassword(md5Password); user.setSalt(salt); return user; } } /** * 更新user */ public static SysUser editUser(UserDto newUser, SysUser oldUser) { if (newUser == null || oldUser == null) { return oldUser; } else { if (ToolUtil.isNotEmpty(newUser.getName())) { oldUser.setName(newUser.getName()); } if (ToolUtil.isNotEmpty(newUser.getEmail())) { oldUser.setEmail(newUser.getEmail()); } if (ToolUtil.isNotEmpty(newUser.getUserGroupId())) { oldUser.setUserGroupId(newUser.getUserGroupId()); } if (ToolUtil.isNotEmpty(newUser.getRoleId())) { oldUser.setRoleId(newUser.getRoleId()); } if (ToolUtil.isNotEmpty(newUser.getPhone())) { oldUser.setPhone(newUser.getPhone()); } if (ToolUtil.isNotEmpty(newUser.getStatus())) { oldUser.setStatus(newUser.getStatus()); } if (ToolUtil.isNotEmpty(newUser.getRemark())) { oldUser.setRemark(newUser.getRemark()); } return oldUser; } } /** * 过滤不安全字段并转化为map */ public static Map<String, Object> removeUnSafeFields(SysUser user) { if (user == null) { return new HashMap<>(); } else { Map<String, Object> map = BeanUtil.beanToMap(user); map.remove("password"); map.remove("salt"); return map; } } /** * 通过用户表的信息创建一个登录用户 */ public static LoginUser createLoginUser(SysUser user) { LoginUser loginUser = new LoginUser(); if (user == null) { return loginUser; } loginUser.setId(user.getUserId()); loginUser.setAccount(user.getAccount()); loginUser.setUserGroupId(user.getUserGroupId()); loginUser.setTenantId(user.getTenantId()); // loginUser.setDeptId(user.getDeptId()); // loginUser.setDeptName(ConstantFactory.me().getDeptName(user.getDeptId())); loginUser.setName(user.getName()); loginUser.setEmail(user.getEmail()); loginUser.setZbxToken(user.getZbxToken()); // loginUser.setAvatar("/api/system/preview/" + user.getAvatar()); return loginUser; } /** * 判断用户是否是从oauth2登录过来的 */ public static boolean oauth2Flag() { String account = LoginContextHolder.getContext().getUser().getAccount(); if (account.startsWith(ConstantsContext.getOAuth2UserPrefix())) { return true; } else { return false; } } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/factory/UserFactory.java
Java
gpl-3.0
4,440
package com.zmops.iot.web.sys.service; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; import com.zmops.iot.domain.sys.SysDict; import com.zmops.iot.domain.sys.SysDictType; import com.zmops.iot.domain.sys.query.QSysDict; import com.zmops.iot.domain.sys.query.QSysDictType; import com.zmops.iot.enums.CommonStatus; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.util.DefinitionsUtil; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.sys.dto.SysDictDto; import com.zmops.iot.web.sys.dto.param.DictParam; import io.ebean.DB; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * <p> * 基础字典 服务实现类 * </p> */ @Service @Order(Integer.MAX_VALUE) public class DictService implements CommandLineRunner { @Autowired private DictTypeService dictTypeService; /** * 新增 */ public SysDict add(DictParam param) { //判断是否已经存在同编码或同名称字典 int count = new QSysDict() .dictTypeId.eq(param.getDictTypeId()).or() .code.ieq(param.getCode()) .name.ieq(param.getName()).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.DICT_EXISTED); } //判断字典是否存在 count = new QSysDictType().dictTypeId.eq(param.getDictTypeId()).findCount(); if (count <= 0) { throw new ServiceException(BizExceptionEnum.ERROR_CODE_EMPTY); } SysDict entity = getEntity(param); //设置状态 entity.setStatus(CommonStatus.ENABLE.getCode()); DB.save(entity); updateDictionaries(); return entity; } /** * 删除 */ public void delete(DictParam param) { String systemFlag = new QSysDictType().select(QSysDictType.alias().systemFlag).dictTypeId.eq(param.getDictTypeId()).findSingleAttribute(); if ("Y".equals(systemFlag)) { throw new ServiceException(BizExceptionEnum.SYSTEM_DICT_CANNOT_DELETE); } new QSysDict().dictId.in(param.getDictIds()).delete(); updateDictionaries(); } /** * 更新 */ public SysDict update(DictParam param) { SysDict oldEntity = new QSysDict().dictId.eq(param.getDictId()).findOne(); if (null == oldEntity) { throw new ServiceException(BizExceptionEnum.DICT_NOT_EXIST); } //判断编码是否重复 int count = new QSysDict().or().code.ieq(param.getCode()).name.ieq(param.getName()).endOr() .dictId.ne(param.getDictId()).dictTypeId.eq(param.getDictTypeId()).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.DICT_EXISTED); } //判断字典是否存在 count = new QSysDictType().dictTypeId.eq(param.getDictTypeId()).findCount(); if (count <= 0) { throw new ServiceException(BizExceptionEnum.ERROR_CODE_EMPTY); } SysDict newEntity = getEntity(param); ToolUtil.copyProperties(newEntity, oldEntity); DB.update(newEntity); updateDictionaries(); return newEntity; } /** * 查询字典列表,通过字典ID */ public List<SysDictDto> listDicts(Long dictTypeId) { return new QSysDict().dictTypeId.eq(dictTypeId).orderBy(" sort desc").asDto(SysDictDto.class).findList(); } /** * 查询字典列表,通过字典编码 */ public List<SysDictDto> listDicts(String dictTypeCode) { Long dictTypeId = new QSysDictType().select(QSysDictType.alias().dictTypeId).code.eq(dictTypeCode).findSingleAttribute(); return listDicts(dictTypeId); } /** * 分组查询字典列表,通过字典编码 */ public Map<String, List<SysDictDto>> groupDictByCode(String dictTypeCode) { Long dictTypeId = new QSysDictType().select(QSysDictType.alias().dictTypeId).code.eq(dictTypeCode).findSingleAttribute(); List<SysDictDto> sysDicts = listDicts(dictTypeId); if (ToolUtil.isEmpty(sysDicts)) { return new HashMap<>(); } return sysDicts.parallelStream().collect(Collectors.groupingBy(SysDictDto::getGroups)); } private void updateDictionaries() { List<SysDictType> dictTypes = new QSysDictType().findList(); Map<Long, String> map = dictTypes.parallelStream().collect(Collectors.toMap(SysDictType::getDictTypeId, SysDictType::getCode, (a, b) -> a)); List<Long> collect = dictTypes.stream().map(SysDictType::getDictTypeId).collect(Collectors.toList()); List<SysDict> dictList = new QSysDict().dictTypeId.in(collect).findList(); Table<String, String, String> dictionaryValues = HashBasedTable.create(); for (SysDict dict : dictList) { dictionaryValues.put(map.get(dict.getDictTypeId()), dict.getCode(), dict.getName()); } DefinitionsUtil.updateDictionaries(dictionaryValues); } @Override public void run(String... args) throws Exception { updateDictionaries(); } // /** // * 查询分页数据,Specification模式 // * // */ // public LayuiPageInfo findPageBySpec(DictParam param) { // QueryWrapper<Dict> objectQueryWrapper = new QueryWrapper<>(); // objectQueryWrapper.eq("dict_type_id", param.getDictTypeId()); // // if (ToolUtil.isNotEmpty(param.getCondition())) { // objectQueryWrapper.and(i -> i.eq("code", param.getCondition()).or().eq("name", param.getCondition())); // } // // objectQueryWrapper.orderByAsc("sort"); // // List<Dict> list = this.list(objectQueryWrapper); // // //去除根节点为0的 // if (list.size() > 0) { // for (Dict dict : list) { // if (dict.getParentId() != null && dict.getParentId().equals(0L)) { // dict.setParentId(null); // } // } // } // // LayuiPageInfo result = new LayuiPageInfo(); // result.setData(list); // // return result; // } // // /** // * 获取字典的树形列表(ztree结构) // * // */ // public List<ZTreeNode> dictTreeList(Long dictTypeId, Long dictId) { // if (dictTypeId == null) { // throw new RequestEmptyException(); // } // // List<ZTreeNode> tree = this.baseMapper.dictTree(dictTypeId); // // //获取dict的所有子节点 // List<Long> subIds = getSubIds(dictId); // // //如果传了dictId,则在返回结果里去掉 // List<ZTreeNode> resultTree = new ArrayList<>(); // for (ZTreeNode zTreeNode : tree) { // // //如果dictId等于树节点的某个id则去除 // if (ToolUtil.isNotEmpty(dictId) && dictId.equals(zTreeNode.getId())) { // continue; // } // if (subIds.contains(zTreeNode.getId())) { // continue; // } // resultTree.add(zTreeNode); // } // // resultTree.add(ZTreeNode.createParent()); // // return resultTree; // } // // /** // * 查看dict的详情 // * // */ // public DictResult dictDetail(Long dictId) { // if (ToolUtil.isEmpty(dictId)) { // throw new RequestEmptyException(); // } // // DictResult dictResult = new DictResult(); // // //查询字典 // Dict detail = this.getById(dictId); // if (detail == null) { // throw new RequestEmptyException(); // } // // //查询父级字典 // if (ToolUtil.isNotEmpty(detail.getParentId())) { // Long parentId = detail.getParentId(); // Dict dictType = this.getById(parentId); // if (dictType != null) { // dictResult.setParentName(dictType.getName()); // } else { // dictResult.setParentName("无父级"); // } // } // // ToolUtil.copyProperties(detail, dictResult); // // return dictResult; // } // // // /** // * 查询字典列表,通过字典类型code // * // */ // public List<Dict> listDictsByCode(String dictTypeCode) { // // QueryWrapper<DictType> wrapper = new QueryWrapper<>(); // wrapper.eq("code", dictTypeCode); // // DictType one = this.dictTypeService.getOne(wrapper); // return listDicts(one.getDictTypeId()); // } // // /** // * 查询字典列表,通过字典类型code // * // */ // public List<Map<String, Object>> getDictsByCodes(List<String> dictCodes) { // // QueryWrapper<Dict> wrapper = new QueryWrapper<>(); // wrapper.in("code", dictCodes).orderByAsc("sort"); // // ArrayList<Map<String, Object>> results = new ArrayList<>(); // // //转成map // List<Dict> list = this.list(wrapper); // for (Dict dict : list) { // Map<String, Object> map = BeanUtil.beanToMap(dict); // results.add(map); // } // // return results; // } // // private Serializable getKey(DictParam param) { // return param.getDictId(); // } // // private Page getPageContext() { // return LayuiPageFactory.defaultPage(); // } // // private Dict getOldEntity(DictParam param) { // return this.getById(getKey(param)); // } // private SysDict getEntity(DictParam param) { SysDict entity = new SysDict(); ToolUtil.copyProperties(param, entity); return entity; } // // private List<Long> getSubIds(Long dictId) { // // ArrayList<Long> longs = new ArrayList<>(); // // if (ToolUtil.isEmpty(dictId)) { // return longs; // } else { // List<Dict> list = this.baseMapper.likeParentIds(dictId); // for (Dict dict : list) { // longs.add(dict.getDictId()); // } // return longs; // } // } // // private void dictSetPids(Dict param) { // if (param.getParentId().equals(0L)) { // param.setParentIds("[0]"); // } else { // //获取父级的pids // Long parentId = param.getParentId(); // Dict parent = this.getById(parentId); // if (parent == null) { // param.setParentIds("[0]"); // } else { // param.setParentIds(parent.getParentIds() + "," + "[" + parentId + "]"); // } // } // } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/DictService.java
Java
gpl-3.0
10,902
package com.zmops.iot.web.sys.service; import com.zmops.iot.domain.sys.SysDictType; import com.zmops.iot.domain.sys.query.QSysDict; import com.zmops.iot.domain.sys.query.QSysDictType; import com.zmops.iot.enums.CommonStatus; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.model.page.Pager; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.sys.dto.SysDictTypeDto; import com.zmops.iot.web.sys.dto.param.DictTypeParam; import io.ebean.DB; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; /** * <p> * 字典类型表 服务实现类 * </p> */ @Service public class DictTypeService { @Autowired private DictService dictService; /** * 新增 */ public SysDictType add(DictTypeParam param) { //判断是否已经存在同编码或同名称字典 int count = new QSysDictType().or().code.eq(param.getCode()).name.eq(param.getName()).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.DICT_EXISTED); } SysDictType entity = getEntity(param); //设置状态 entity.setStatus(CommonStatus.ENABLE.getCode()); DB.save(entity); return entity; } /** * 删除 */ @Transactional(rollbackFor = Exception.class) public void delete(DictTypeParam param) { String systemFlag = new QSysDictType().select(QSysDictType.alias().systemFlag).dictTypeId.eq(param.getDictTypeId()).findSingleAttribute(); if ("Y".equals(systemFlag)) { throw new ServiceException(BizExceptionEnum.SYSTEM_DICT_CANNOT_DELETE); } //删除字典类型 new QSysDictType().dictTypeId.in(param.getDictTypeIds()).delete(); //删除字典 new QSysDict().dictTypeId.in(param.getDictTypeIds()).delete(); } /** * 更新 */ public SysDictType update(DictTypeParam param) { SysDictType oldEntity = new QSysDictType().dictTypeId.eq(param.getDictTypeId()).findOne(); if (null == oldEntity) { throw new ServiceException(BizExceptionEnum.DICT_NOT_EXIST); } //判断编码是否重复 int count = new QSysDictType().dictTypeId.ne(param.getDictTypeId()) .or().code.eq(param.getCode()).name.eq(param.getName()).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.DICT_EXISTED); } SysDictType newEntity = getEntity(param); ToolUtil.copyProperties(newEntity, oldEntity); DB.update(newEntity); return newEntity; } /** * 查询分页数据 */ public Pager findPageBySpec(DictTypeParam param) { QSysDictType qSysDictType = new QSysDictType(); if (ToolUtil.isNotEmpty(param.getCondition())) { qSysDictType.or().code.contains(param.getCondition()).name.contains(param.getCondition()); } qSysDictType.orderBy("create_time desc"); qSysDictType.setFirstRow((param.getPage() - 1) * param.getMaxRow()).setMaxRows(param.getMaxRow()); List<SysDictTypeDto> pagedList = qSysDictType.asDto(SysDictTypeDto.class).findList(); return new Pager<>(pagedList, qSysDictType.findCount()); } private SysDictType getEntity(DictTypeParam param) { SysDictType entity = new SysDictType(); ToolUtil.copyProperties(param, entity); return entity; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/DictTypeService.java
Java
gpl-3.0
3,644
package com.zmops.iot.web.sys.service; import com.zmops.iot.core.auth.model.LoginUser; import com.zmops.iot.web.auth.AuthService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; /** * 用户详情信息获取 * * @author fengshuonan */ @Service("jwtUserDetailsService") public class JwtUserDetailsService implements UserDetailsService { @Autowired private AuthService authService; @Override public LoginUser loadUserByUsername(String username) throws UsernameNotFoundException { return authService.user(username); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/JwtUserDetailsService.java
Java
gpl-3.0
770
package com.zmops.iot.web.sys.service; import com.zmops.iot.core.auth.context.LoginContextHolder; import com.zmops.iot.domain.sys.query.QSysLoginLog; import com.zmops.iot.model.page.Pager; import com.zmops.iot.util.LocalDateTimeUtils; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.sys.dto.SysLoginLogDto; import org.springframework.stereotype.Service; import java.util.List; /** * @author yefei **/ @Service public class LoginLogService { public Pager<SysLoginLogDto> list(Long beginTime, Long endTime, String logName, int page, int maxRow) { QSysLoginLog qSysLoginLog = new QSysLoginLog(); if (ToolUtil.isNotEmpty(beginTime)) { qSysLoginLog.createTime.ge(LocalDateTimeUtils.getLDTByMilliSeconds(beginTime)); } if (ToolUtil.isNotEmpty(endTime)) { qSysLoginLog.createTime.le(LocalDateTimeUtils.getLDTByMilliSeconds(endTime)); } if (ToolUtil.isNotEmpty(logName)) { qSysLoginLog.logName.eq(logName); } Long tenantId = LoginContextHolder.getContext().getUser().getTenantId(); if (null != tenantId) { qSysLoginLog.tenantId.eq(tenantId); } qSysLoginLog.setFirstRow((page - 1) * maxRow).setMaxRows(maxRow); List<SysLoginLogDto> pagedList = qSysLoginLog.orderBy("create_time desc").asDto(SysLoginLogDto.class).findList(); return new Pager<>(pagedList, qSysLoginLog.findCount()); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/LoginLogService.java
Java
gpl-3.0
1,456
package com.zmops.iot.web.sys.service; import com.zmops.iot.core.auth.context.LoginContextHolder; import com.zmops.iot.domain.sys.query.QSysOperationLog; import com.zmops.iot.model.page.Pager; import com.zmops.iot.util.LocalDateTimeUtils; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.sys.dto.SysOperationLogDto; import org.springframework.stereotype.Service; import java.util.List; /** * @author yefei **/ @Service public class OperationLogService { public Pager<SysOperationLogDto> list(Long beginTime, Long endTime, String logName, String logType, int page, int maxRow) { QSysOperationLog qSysOperationLog = new QSysOperationLog(); if (ToolUtil.isNotEmpty(beginTime)) { qSysOperationLog.createTime.ge(LocalDateTimeUtils.getLDTByMilliSeconds(beginTime)); } if (ToolUtil.isNotEmpty(endTime)) { qSysOperationLog.createTime.le(LocalDateTimeUtils.getLDTByMilliSeconds(endTime)); } if (ToolUtil.isNotEmpty(logName)) { qSysOperationLog.logName.contains(logName); } if (ToolUtil.isNotEmpty(logType)) { qSysOperationLog.logType.eq(logType); } Long tenantId = LoginContextHolder.getContext().getUser().getTenantId(); if (null != tenantId) { qSysOperationLog.tenantId.eq(tenantId); } qSysOperationLog.setFirstRow((page - 1) * maxRow).setMaxRows(maxRow); List<SysOperationLogDto> pagedList = qSysOperationLog.orderBy("create_time desc").asDto(SysOperationLogDto.class).findList(); return new Pager<>(pagedList, qSysOperationLog.findCount()); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/OperationLogService.java
Java
gpl-3.0
1,646
package com.zmops.iot.web.sys.service; import com.zmops.iot.domain.sys.SysConfig; import com.zmops.iot.domain.sys.query.QSysConfig; import com.zmops.iot.enums.CommonStatus; import com.zmops.iot.web.init.SysConfigInit; import com.zmops.iot.web.sys.dto.SysParamDto; import io.ebean.DB; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @author yefei **/ @Service public class SysParamService { @Autowired SysConfigInit sysConfigInit; public List<SysConfig> list() { return new QSysConfig().status.eq(CommonStatus.ENABLE.getCode()).orderBy().id.desc().findList(); } public void update(SysParamDto sysParamDto) { Map<Long, SysParamDto.SysParam> sysParamMap = sysParamDto.getSysParamList().parallelStream().collect(Collectors.toMap(SysParamDto.SysParam::getId, o -> o)); List<SysConfig> sysParamList = list(); for (SysConfig sysConfig : sysParamList) { SysParamDto.SysParam sysParam = sysParamMap.get(sysConfig.getId()); sysConfig.setName(sysParam.getName()); sysConfig.setValue(sysParam.getValue()); sysConfig.setRemark(sysParam.getRemark()); } DB.saveAll(sysParamList); sysConfigInit.initConfigConst(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/SysParamService.java
Java
gpl-3.0
1,388
package com.zmops.iot.web.sys.service; import com.zmops.iot.core.auth.context.LoginContextHolder; import com.zmops.iot.core.auth.exception.enums.AuthExceptionEnum; import com.zmops.iot.core.auth.model.LoginUser; import com.zmops.iot.core.tree.DefaultTreeBuildFactory; import com.zmops.iot.domain.sys.SysRole; import com.zmops.iot.domain.sys.SysRoleMenu; import com.zmops.iot.domain.sys.query.QSysMenu; import com.zmops.iot.domain.sys.query.QSysRole; import com.zmops.iot.domain.sys.query.QSysRoleMenu; import com.zmops.iot.domain.sys.query.QSysUser; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.model.node.TreeNode; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.sys.dto.SysRoleDto; import com.zmops.iot.web.sys.dto.param.RoleParam; import io.ebean.DB; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @author yefei **/ @Service public class SysRoleService { /** * 角色列表 * * @return */ public List<SysRole> list(String name) { QSysRole qSysRole = new QSysRole(); if (ToolUtil.isNotEmpty(name)) { qSysRole.name.contains(name); } return qSysRole.roleId.ne(1L).orderBy("create_time desc").findList(); } /** * 角色新增 * * @param sysRoleDto * @return */ public SysRole create(SysRoleDto sysRoleDto) { checkSysRoleExist(sysRoleDto.getName(), -1L); SysRole sysRole = new SysRole(); BeanUtils.copyProperties(sysRoleDto, sysRole); DB.save(sysRole); return sysRole; } /** * 角色修改 * * @param sysRoleDto * @return */ public SysRole update(SysRoleDto sysRoleDto) { checkSysRoleExist(sysRoleDto.getName(), sysRoleDto.getRoleId()); SysRole sysRole = new SysRole(); BeanUtils.copyProperties(sysRoleDto, sysRole); DB.update(sysRole); return sysRole; } /** * 角色删除 * * @param sysRoleParam * @return */ @Transactional(rollbackFor = Exception.class) public void delete(RoleParam sysRoleParam) { int count = new QSysUser().roleId.in(sysRoleParam.getRoleIds()).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.ROLE_HAS_BIND_USER); } new QSysRoleMenu().roleId.in(sysRoleParam.getRoleIds()).roleId.ne(1L).delete(); new QSysRole().roleId.in(sysRoleParam.getRoleIds()).roleId.ne(1L).delete(); } /** * 角色绑定菜单 * * @param roleParam */ @Transactional(rollbackFor = Exception.class) public void bindMenu(RoleParam roleParam) { checkRoleId(roleParam.getRoleId()); checkMenuId(roleParam.getMenuIds()); new QSysRoleMenu().roleId.eq(roleParam.getRoleId()).delete(); List<SysRoleMenu> sysRoleMenuList = new ArrayList<>(); for (Long menuId : roleParam.getMenuIds()) { SysRoleMenu sysRoleMenu = new SysRoleMenu(); sysRoleMenu.setMenuId(menuId); sysRoleMenu.setRoleId(roleParam.getRoleId()); sysRoleMenuList.add(sysRoleMenu); } DB.saveAll(sysRoleMenuList); } private void checkRoleId(Long roleId) { LoginUser user = LoginContextHolder.getContext().getUser(); if (null == user) { return; } if (user.getRoleList().contains(roleId)) { throw new ServiceException(BizExceptionEnum.CANNOT_MODIFY_OWNER_MENUS); } } /** * 检查授权的菜单 是否存在或是否有权授权此菜单 */ private void checkMenuId(List<Long> menuIds) { List<Long> paramMuenuIds = new ArrayList<>(menuIds); LoginUser user = LoginContextHolder.getContext().getUser(); if (null == user) { throw new ServiceException(AuthExceptionEnum.NOT_LOGIN_ERROR); } List<Long> adminMenuIds = new QSysMenu().select(QSysMenu.alias().menuId).adminFlag.eq("Y").findSingleAttributeList(); menuIds.removeAll(adminMenuIds); List<Long> lists = new QSysRoleMenu().select(QSysRoleMenu.Alias.menuId).menuId.in(menuIds).roleId.in(user.getRoleList()).findSingleAttributeList(); paramMuenuIds.removeAll(lists); if (ToolUtil.isNotEmpty(paramMuenuIds)) { throw new ServiceException(BizExceptionEnum.MENU_NOT_EXIST_OR_NO_PRERMISSION); } } /** * 根据角色名称 、Id检查角色是否已存在 * * @param name */ private void checkSysRoleExist(String name, Long roleId) { int count; if (roleId >= 0) { count = new QSysRole().name.equalTo(name).roleId.ne(roleId).findCount(); } else { count = new QSysRole().name.equalTo(name).findCount(); } if (count > 0) { throw new ServiceException(BizExceptionEnum.ROLE_HAS_EXIST); } } public List<TreeNode> bindedMenu(Long roleId) { LoginUser user = LoginContextHolder.getContext().getUser(); if (null == user) { return Collections.emptyList(); } //取当前操作者 可以授权的菜单 String sql = "select " + " m1.menu_id AS id," + " ( CASE WHEN ( m2.menu_id = 0 OR m2.menu_id IS NULL ) THEN 0 ELSE m2.menu_id END ) AS pId," + " m1.NAME," + " m1.url," + " m1.menu_flag " + " FROM " + " sys_menu m1" + " LEFT JOIN sys_menu m2 ON m1.pcode = m2.CODE " + " WHERE" + " m1.status = 'ENABLE' " + " AND m1.admin_flag = 'N' " + " AND " + " m1.menu_id in (select menu_id from sys_role_menu where role_id in (:roleIds))" + " ORDER BY" + " m1.sort ASC"; List<TreeNode> allMenuList = DB.findDto(TreeNode.class, sql).setParameter("roleIds", user.getRoleList()).findList(); //取被授权用户 已授权的菜单 List<Long> selectMenuIdList = new QSysRoleMenu().select(QSysRoleMenu.Alias.menuId).roleId.eq(roleId).findSingleAttributeList(); for (TreeNode menuTreeNode : allMenuList) { if (selectMenuIdList.contains(menuTreeNode.getId())) { menuTreeNode.setIsChecked(true); } } DefaultTreeBuildFactory<TreeNode> treeBuildFactory = new DefaultTreeBuildFactory<>(); treeBuildFactory.setRootParentId("0"); return treeBuildFactory.doTreeBuild(allMenuList); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/SysRoleService.java
Java
gpl-3.0
6,913
package com.zmops.iot.web.sys.service; import cn.hutool.core.util.IdUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.zmops.iot.core.auth.context.LoginContextHolder; import com.zmops.iot.domain.device.DeviceGroup; import com.zmops.iot.domain.device.SysUserGrpDevGrp; import com.zmops.iot.domain.device.query.QDeviceGroup; import com.zmops.iot.domain.device.query.QSysUserGrpDevGrp; import com.zmops.iot.domain.sys.SysUserGroup; import com.zmops.iot.domain.sys.query.QSysUser; import com.zmops.iot.domain.sys.query.QSysUserGroup; import com.zmops.iot.enums.CommonStatus; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.model.page.Pager; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.sys.dto.UserGroupDto; import com.zmops.iot.web.sys.dto.param.UserGroupParam; import com.zmops.zeus.driver.entity.ZbxUserGrpInfo; import com.zmops.zeus.driver.service.ZbxUserGroup; import io.ebean.DB; import io.ebean.DtoQuery; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * @author yefei **/ @Service public class SysUserGroupService { @Autowired private ZbxUserGroup zbxUserGroup; /** * 用户组分页列表 * * @param userGroupParam * @return */ public Pager<UserGroupDto> userGroupPageList(UserGroupParam userGroupParam) { QSysUserGroup qSysUserGroup = new QSysUserGroup(); StringBuilder sql = new StringBuilder("SELECT " + " sug.group_name, sug.remark, sug.create_time, sug.create_user, sug.update_time, sug.update_user, sug.status, sug.user_group_id, sug.tenant_id," + " dg.groupIds " + "FROM " + " sys_user_group sug " + " LEFT JOIN ( SELECT user_group_id, array_to_string( ARRAY_AGG ( device_group_id ), ',' ) groupIds FROM sys_usrgrp_devicegrp GROUP BY user_group_id ) dg " + " ON dg.user_group_id = sug.user_group_id"); sql.append(" where 1=1 "); if (ToolUtil.isNotEmpty(userGroupParam.getGroupName())) { sql.append(" and sug.group_name like :groupName"); } Long tenantId = LoginContextHolder.getContext().getUser().getTenantId(); if (null != tenantId) { sql.append(" and sug.tenant_id = :tenantId"); } sql.append(" order by sug.create_time desc "); DtoQuery<UserGroupDto> dto = DB.findDto(UserGroupDto.class, sql.toString()); if (ToolUtil.isNotEmpty(userGroupParam.getGroupName())) { dto.setParameter("groupName", "%" + userGroupParam.getGroupName() + "%"); qSysUserGroup.groupName.contains(userGroupParam.getGroupName()); } if (null != tenantId) { dto.setParameter("tenantId", tenantId); qSysUserGroup.tenantId.eq(tenantId); } List<UserGroupDto> list = dto.setFirstRow((userGroupParam.getPage() - 1) * userGroupParam.getMaxRow()) .setMaxRows(userGroupParam.getMaxRow()).findList(); return new Pager<>(list, qSysUserGroup.findCount()); } /** * 用户组列表 * * @return */ public List<SysUserGroup> userGroupList() { // QSysUserGroup qSysUserGroup = new QSysUserGroup(); // if (ToolUtil.isNotEmpty(userGroupParam.getGroupName())) { // qSysUserGroup.groupName.contains(userGroupParam.getGroupName()); // } QSysUserGroup qSysUserGroup = new QSysUserGroup(); Long tenantId = LoginContextHolder.getContext().getUser().getTenantId(); if (null != tenantId) { qSysUserGroup.tenantId.eq(tenantId); } return qSysUserGroup.findList(); } /** * 添加用戶組 */ @Transactional(rollbackFor = Exception.class) public SysUserGroup createUserGroup(UserGroupDto userGroup) { // 判断用户组是否重复 checkByGroupName(userGroup.getGroupName(), -1L, userGroup.getTenantId()); long usrGrpId = IdUtil.getSnowflake().nextId(); SysUserGroup newUserGroup = new SysUserGroup(); BeanUtils.copyProperties(userGroup, newUserGroup); newUserGroup.setUserGroupId(usrGrpId); newUserGroup.setStatus(CommonStatus.ENABLE.getCode()); //回填 ZBX用户组ID JSONObject result = JSONObject.parseObject(zbxUserGroup.userGrpAdd(String.valueOf(usrGrpId))); JSONArray userGrpids = result.getJSONArray("usrgrpids"); newUserGroup.setZbxId(userGrpids.get(0).toString()); DB.save(newUserGroup); if (ToolUtil.isNotEmpty(userGroup.getDeviceGroupIds())) { bindHostGrp(UserGroupParam.builder().userGroupId(usrGrpId).deviceGroupIds(userGroup.getDeviceGroupIds()).build()); } return newUserGroup; } /** * 修改用户组 * * @param userGroup * @return SysUser */ public SysUserGroup updateUserGroup(UserGroupDto userGroup) { // 判断用户组是否重复 checkByGroupName(userGroup.getGroupName(), userGroup.getUserGroupId(), userGroup.getTenantId()); SysUserGroup newUserGroup = new SysUserGroup(); BeanUtils.copyProperties(userGroup, newUserGroup); DB.update(newUserGroup); bindHostGrp(UserGroupParam.builder().userGroupId(userGroup.getUserGroupId()).deviceGroupIds(userGroup.getDeviceGroupIds()).build()); return newUserGroup; } /** * 根据GroupName userGroupId检查用户组是否已存在 * * @param groupName */ private void checkByGroupName(String groupName, Long userGroupId, Long tenantId) { int count; if (userGroupId > 0) { count = new QSysUserGroup().groupName.eq(groupName).tenantId.eq(tenantId).userGroupId.ne(userGroupId).findCount(); } else { count = new QSysUserGroup().groupName.eq(groupName).tenantId.eq(tenantId).findCount(); } if (count > 0) { throw new ServiceException(BizExceptionEnum.USERGROUP_HAS_EXIST); } } /** * 删除用户组 * * @param userGroupParam */ public void deleteUserGroup(UserGroupParam userGroupParam) { List<SysUserGroup> list = new QSysUserGroup().userGroupId.in(userGroupParam.getUserGroupIds()).findList(); if (ToolUtil.isEmpty(list)) { throw new ServiceException(BizExceptionEnum.USERGROUP_NOT_EXIST); } int count = new QSysUser().userGroupId.in(userGroupParam.getUserGroupIds()).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.USERGROUP_HAS_BIND_USER); } List<String> zbxUsrGrpIds = list.parallelStream().map(SysUserGroup::getZbxId).collect(Collectors.toList()); //删除 zbx 用户组数据 if (ToolUtil.isNotEmpty(zbxUsrGrpIds)) { List<ZbxUserGrpInfo> zbxUserGrpList = JSONObject.parseArray(zbxUserGroup.getUserGrp(zbxUsrGrpIds.toString()), ZbxUserGrpInfo.class); if (ToolUtil.isNotEmpty(zbxUserGrpList)) { zbxUserGroup.userGrpDelete(zbxUserGrpList.parallelStream().map(ZbxUserGrpInfo::getUsrgrpid).collect(Collectors.toList())); } } // 删除 与设备组关联 new QSysUserGrpDevGrp().userGroupId.in(userGroupParam.getUserGroupIds()).delete(); new QSysUserGroup().userGroupId.in(userGroupParam.getUserGroupIds()).delete(); } /** * 根据用户组ID 取zabbix用户组ID */ public String getZabUsrGrpId(Long usrGrpId) { SysUserGroup usrGrp = new QSysUserGroup().userGroupId.eq(usrGrpId).findOne(); if (null == usrGrp) { throw new ServiceException(BizExceptionEnum.USERGROUP_NOT_EXIST); } return usrGrp.getZbxId(); } /** * 用户组绑定设备组 * * @param userGroup */ public void bindHostGrp(UserGroupParam userGroup) { new QSysUserGrpDevGrp().userGroupId.eq(userGroup.getUserGroupId()).delete(); if (ToolUtil.isEmpty(userGroup.getDeviceGroupIds())) { return; } List<SysUserGrpDevGrp> lists = new ArrayList<>(); for (Long deviceGroupId : userGroup.getDeviceGroupIds()) { SysUserGrpDevGrp devicesGroups = new SysUserGrpDevGrp(); devicesGroups.setUserGroupId(userGroup.getUserGroupId()); devicesGroups.setDeviceGroupId(deviceGroupId); lists.add(devicesGroups); } DB.saveAll(lists); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/SysUserGroupService.java
Java
gpl-3.0
8,838
package com.zmops.iot.web.sys.service; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.zmops.iot.constant.ConstantsContext; import com.zmops.iot.core.auth.context.LoginContextHolder; import com.zmops.iot.core.auth.exception.enums.AuthExceptionEnum; import com.zmops.iot.core.auth.model.LoginUser; import com.zmops.iot.core.util.SaltUtil; import com.zmops.iot.domain.sys.SysUser; import com.zmops.iot.domain.sys.query.QSysRole; import com.zmops.iot.domain.sys.query.QSysUser; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.model.page.Pager; import com.zmops.iot.util.DefinitionsUtil; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.sys.dto.UserDto; import com.zmops.iot.web.sys.dto.param.UserParam; import com.zmops.iot.web.sys.factory.UserFactory; import com.zmops.zeus.driver.entity.ZbxUserInfo; import com.zmops.zeus.driver.service.ZbxUser; import io.ebean.DB; import io.ebean.DtoQuery; import org.apache.commons.codec.binary.Hex; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import static com.zmops.iot.web.init.DeviceSatusScriptInit.GLOBAL_ADMIN_ROLE_CODE; /** * @author yefei * <p> * 用户管理 **/ @Service @Order(Integer.MAX_VALUE) public class SysUserService implements CommandLineRunner { @Autowired private ZbxUser zbxUser; @Autowired private SysUserGroupService sysUserGroupService; public Map<String, Object> getUserIndexInfo() { //获取当前用户角色列表 LoginUser user = LoginContextHolder.getContext().getUser(); List<Long> roleList = user.getRoleList(); //用户没有角色无法显示首页信息 if (roleList == null || roleList.size() == 0) { return null; } HashMap<String, Object> result = new HashMap<>(); result.put("name", user.getName()); return result; } /** * 用户列表 * * @param userParam * @return */ public Pager<UserDto> userList(UserParam userParam) { QSysUser qSysUser = new QSysUser(); StringBuilder sql = new StringBuilder( "select u.account, u.name, u.email, u.phone, u.role_id,r.name role_name," + "u.user_group_id,g.group_name user_group_name, u.status, u.create_user, " + "u.update_user, u.create_time, u.update_time, u.user_id,u.tenant_id,u.remark FROM sys_user u"); sql.append(" LEFT JOIN sys_role r ON r.role_id = u.role_id "); sql.append(" LEFT JOIN sys_user_group g ON g.user_group_id = u.user_group_id "); sql.append(" where 1=1 "); if (ToolUtil.isNotEmpty(userParam.getName())) { sql.append(" and u.name like :name"); qSysUser.name.contains(userParam.getName()); } Long tenantId = LoginContextHolder.getContext().getUser().getTenantId(); if (tenantId != null) { sql.append(" and u.tenant_id = :tenantId"); qSysUser.tenantId.eq(tenantId); } sql.append(" order by u.create_time desc "); DtoQuery<UserDto> dto = DB.findDto(UserDto.class, sql.toString()); if (ToolUtil.isNotEmpty(userParam.getName())) { dto.setParameter("name", "%" + userParam.getName() + "%"); } if (tenantId != null) { dto.setParameter("tenantId", tenantId); } List<UserDto> pagedList = dto.setFirstRow((userParam.getPage() - 1) * userParam.getMaxRow()).setMaxRows(userParam.getMaxRow()).findList(); int count = qSysUser.findCount(); return new Pager<>(pagedList, count); } /** * 添加用戶 */ @Transactional(rollbackFor = Exception.class) public SysUser createUser(UserDto user) { // 判断账号是否重复 checkByAccount(user.getAccount()); //判断角色是否存在 checkByRole(user.getRoleId()); // 完善账号信息 String password = user.getPassword(); String decryptPwd = ""; try { password = new String(Hex.decodeHex(password)); decryptPwd = password; } catch (Exception e) { throw new ServiceException(BizExceptionEnum.PWD_DECRYPT_ERR); } String salt = SaltUtil.getRandomSalt(); password = SaltUtil.md5Encrypt(password, salt); SysUser newUser = UserFactory.createUser(user, password, salt); //取对应的ZBX用户组ID String usrZbxId = sysUserGroupService.getZabUsrGrpId(user.getUserGroupId()); JSONObject result = JSONObject.parseObject( zbxUser.userAdd(user.getAccount(), decryptPwd, usrZbxId, ConstantsContext.getConstntsMap().get(GLOBAL_ADMIN_ROLE_CODE).toString())); JSONArray userids = result.getJSONArray("userids"); newUser.setZbxId(String.valueOf(userids.get(0))); DB.save(newUser); updateUserCache(); return newUser; } /** * 修改用户 * * @param user * @return SysUser */ @Transactional(rollbackFor = Exception.class) public SysUser updateUser(UserDto user) { SysUser oldUser = new QSysUser().userId.eq(user.getUserId()).findOne(); if (null == oldUser) { throw new ServiceException(BizExceptionEnum.USER_NOT_EXIST); } if (user.getUserId() == 1) { throw new ServiceException(BizExceptionEnum.CANT_CHANGE_ADMIN); } //判断角色是否存在 checkByRole(user.getRoleId()); SysUser sysUser = UserFactory.editUser(user, oldUser); //取对应的ZBX用户组ID 修改自己的信息 不更新zbx Long id = LoginContextHolder.getContext().getUser().getId(); if (!user.getUserId().equals(id)) { String usrZbxId = sysUserGroupService.getZabUsrGrpId(user.getUserGroupId()); zbxUser.userUpdate(oldUser.getZbxId(), usrZbxId, ConstantsContext.getConstntsMap().get(GLOBAL_ADMIN_ROLE_CODE).toString()); } DB.save(sysUser); updateUserCache(); return sysUser; } /** * 删除用户 * * @param user * @return */ public void deleteUser(UserParam user) { if (user.getUserIds().contains(1)) { throw new ServiceException(BizExceptionEnum.CANT_DELETE_ADMIN); } List<SysUser> list = new QSysUser().userId.in(user.getUserIds()).findList(); if (ToolUtil.isEmpty(list)) { throw new ServiceException(BizExceptionEnum.USER_NOT_EXIST); } List<String> zbxIds = list.parallelStream().map(SysUser::getZbxId).collect(Collectors.toList()); //删除 zbx 用户数据 if (ToolUtil.isNotEmpty(zbxIds)) { List<ZbxUserInfo> zbxUserList = JSONObject.parseArray(zbxUser.getUser(zbxIds.toString()), ZbxUserInfo.class); if (ToolUtil.isNotEmpty(zbxUserList)) { zbxUser.userDelete(zbxUserList.parallelStream().map(ZbxUserInfo::getUserid).collect(Collectors.toList())); } } new QSysUser().userId.in(user.getUserIds()).delete(); updateUserCache(); } /** * 根据account、userId 检查用户是否已注册 * * @param account */ private void checkByAccount(String account) { int count = new QSysUser().account.equalTo(account).findCount(); if (count > 0) { throw new ServiceException(BizExceptionEnum.USER_ALREADY_REG); } } /** * 检查所选角色是否存在 * * @param roleId 角色ID */ private void checkByRole(Long roleId) { int count = new QSysRole().roleId.eq(roleId).findCount(); if (count <= 0) { throw new ServiceException(BizExceptionEnum.ROLE_NOT_EXIST); } } /** * 修改密码 * * @param oldPassword String * @param newPassword String */ public void changePwd(String oldPassword, String newPassword) { LoginUser loginUser = LoginContextHolder.getContext().getUser(); if (null == loginUser) { throw new ServiceException(AuthExceptionEnum.NOT_LOGIN_ERROR); } if (loginUser.getId() == 1) { throw new ServiceException(BizExceptionEnum.CANT_CHANGE_ADMIN_PWD); } SysUser user = new QSysUser().userId.eq(loginUser.getId()).findOne(); String rawNewPasswd = ""; try { oldPassword = new String(Hex.decodeHex(oldPassword)); newPassword = new String(Hex.decodeHex(newPassword)); rawNewPasswd = newPassword; } catch (Exception e) { throw new ServiceException(BizExceptionEnum.PWD_DECRYPT_ERR); } oldPassword = SaltUtil.md5Encrypt(oldPassword, user.getSalt()); if (user.getPassword().equals(oldPassword)) { newPassword = SaltUtil.md5Encrypt(newPassword, user.getSalt()); user.setPassword(newPassword); DB.update(user); zbxUser.updatePwd(user.getZbxId(), rawNewPasswd); } else { throw new ServiceException(BizExceptionEnum.OLD_PWD_NOT_RIGHT); } } public void updateUserCache() { DefinitionsUtil.updateSysUser(new QSysUser().findList()); } @Override public void run(String... args) throws Exception { updateUserCache(); } public void reset(Long userId) { SysUser user = new QSysUser().userId.eq(userId).findOne(); user.setSalt(SaltUtil.getRandomSalt()); user.setPassword(SaltUtil.md5Encrypt(ConstantsContext.getDefaultPassword(), user.getSalt())); DB.update(user); zbxUser.updatePwd(user.getZbxId(), ConstantsContext.getDefaultPassword()); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/SysUserService.java
Java
gpl-3.0
10,165
package com.zmops.iot.web.sys.service; import com.zmops.iot.constant.ConstantsContext; import com.zmops.iot.domain.device.DeviceGroup; import com.zmops.iot.domain.device.query.QDeviceGroup; import com.zmops.iot.domain.product.query.QProductType; import com.zmops.iot.domain.sys.SysUser; import com.zmops.iot.domain.sys.SysUserGroup; import com.zmops.iot.domain.sys.query.QSysUser; import com.zmops.iot.domain.sys.query.QSysUserGroup; import com.zmops.iot.domain.tenant.TenantInfo; import com.zmops.iot.domain.tenant.query.QTenantInfo; import com.zmops.iot.enums.CommonStatus; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.model.page.Pager; import com.zmops.iot.util.DefinitionsUtil; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.device.dto.param.DeviceGroupParam; import com.zmops.iot.web.device.service.DeviceGroupService; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.product.dto.param.ProductTypeParam; import com.zmops.iot.web.product.service.ProductTypeService; import com.zmops.iot.web.sys.dto.TenantInfoDto; import com.zmops.iot.web.sys.dto.UserDto; import com.zmops.iot.web.sys.dto.UserGroupDto; import com.zmops.iot.web.sys.dto.param.TenantInfoParam; import io.ebean.DB; import io.ebean.annotation.Transactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Service; import java.util.List; import java.util.stream.Collectors; /** * @author yefei **/ @Service public class Tenantervice implements CommandLineRunner { private static final String ZEUS_TENANT_ROLE_ID = "ZEUS_TENANT_ROLE_ID"; @Autowired SysUserGroupService sysUserGroupService; @Autowired DeviceGroupService deviceGroupService; @Autowired SysUserService sysUserService; @Autowired ProductTypeService productTypeService; public Pager<TenantInfoDto> getTenantByPage(TenantInfoParam tenantInfoParam) { QTenantInfo qTenantInfo = new QTenantInfo(); if (ToolUtil.isNotEmpty(tenantInfoParam.getName())) { qTenantInfo.name.contains(tenantInfoParam.getName()); } List<TenantInfoDto> list = qTenantInfo.orderBy().createTime.desc().asDto(TenantInfoDto.class).setFirstRow((tenantInfoParam.getPage() - 1) * tenantInfoParam.getMaxRow()) .setMaxRows(tenantInfoParam.getMaxRow()).findList(); list.forEach(tenantInfoDto -> { int count = new QSysUser().tenantId.eq(tenantInfoDto.getTenantId()).findCount(); tenantInfoDto.setUserNum(count); }); return new Pager<>(list, qTenantInfo.findCount()); } @Transactional public Object createTenant(TenantInfoParam tenantInfoParam) { //step 1:新增租户 TenantInfo tenantInfo = new TenantInfo(); ToolUtil.copyProperties(tenantInfoParam, tenantInfo); tenantInfo.setStatus(CommonStatus.ENABLE.getCode()); DB.save(tenantInfo); //step 2: 新增默认产品分类 addProductType(tenantInfo.getTenantId(), tenantInfoParam.getName()); //step 3:新增默认设备组 addDeviceGrp(tenantInfo.getTenantId(), tenantInfoParam.getName()); //step 4:新增租户管理员账号 long userGrpId = addSysUserGrp(tenantInfo.getTenantId(), tenantInfoParam.getName()); addSysUser(tenantInfoParam, userGrpId, tenantInfo.getTenantId()); //step 5:新增租户告警通知方式设置 addMediaTypeSetting(tenantInfo.getTenantId()); //更新租户名称缓存 updateTenantName(); return tenantInfo; } private void addMediaTypeSetting(Long tenantId) { DB.sqlUpdate("insert into media_type_setting (type,template,webhooks,tenant_id) SELECT type,template,webhooks,:tenantId from media_type_setting where tenant_id is null") .setParameter("tenantId", tenantId).execute(); DB.sqlUpdate("insert into mail_setting (host, port, account, password, sender, ssl, tls, severity, silent, tenant_id) SELECT host, port, account, password, sender, ssl, tls, severity, silent,:tenantId from mail_setting where tenant_id is null") .setParameter("tenantId", tenantId).execute(); } private void addProductType(Long tenantId, String tenantName) { ProductTypeParam productTypeParam = new ProductTypeParam(); productTypeParam.setName("默认产品分组-" + tenantName); productTypeParam.setTenantId(tenantId); productTypeService.create(productTypeParam); } private long addDeviceGrp(Long tenantId, String tenantName) { DeviceGroupParam deviceGroupDto = new DeviceGroupParam(); deviceGroupDto.setName("默认设备组-" + tenantName); deviceGroupDto.setTenantId(tenantId); DeviceGroup deviceGroup = deviceGroupService.createDeviceGroup(deviceGroupDto); return deviceGroup.getDeviceGroupId(); } private long addSysUserGrp(Long tenantId, String tenantName) { UserGroupDto userGroupDto = new UserGroupDto(); userGroupDto.setGroupName("管理员组-" + tenantName); userGroupDto.setRemark("默认管理员组,不要绑定设备组"); userGroupDto.setTenantId(tenantId); SysUserGroup userGroup = sysUserGroupService.createUserGroup(userGroupDto); return userGroup.getUserGroupId(); } private void addSysUser(TenantInfoParam tenantInfoParam, Long userGrpId, Long tenantId) { UserDto userDto = new UserDto(); userDto.setAccount(tenantInfoParam.getAccount()); userDto.setPassword(tenantInfoParam.getPassword()); userDto.setRoleId(Long.parseLong(ConstantsContext.getConstntsMap().getOrDefault(ZEUS_TENANT_ROLE_ID, "1").toString())); userDto.setUserGroupId(userGrpId); String userName = tenantInfoParam.getContact(); if (ToolUtil.isEmpty(userName)) { userName = tenantInfoParam.getName() + "管理员"; } userDto.setName(userName); userDto.setPhone(tenantInfoParam.getPhone()); userDto.setTenantId(tenantId); sysUserService.createUser(userDto); } @Transactional public Object updateTenant(TenantInfoParam tenantInfoParam) { TenantInfo tenantInfo = new QTenantInfo().tenantId.eq(tenantInfoParam.getTenantId()).findOne(); if (null == tenantInfo) { throw new ServiceException(BizExceptionEnum.TENANT_NOT_EXISTS); } tenantInfo.setName(tenantInfoParam.getName()); tenantInfo.setRemark(tenantInfoParam.getRemark()); tenantInfo.setContact(tenantInfoParam.getContact()); tenantInfo.setPhone(tenantInfoParam.getPhone()); DB.update(tenantInfo); updateTenantName(); return tenantInfo; } public void deleteTenant(TenantInfoParam tenantInfoParam) { if (isRelationInfo(tenantInfoParam.getTenantId())) { throw new ServiceException(BizExceptionEnum.TENANT_HAS_RELATION_INFO); } new QTenantInfo().tenantId.eq(tenantInfoParam.getTenantId()).delete(); updateTenantName(); } private boolean isRelationInfo(Long tenantId) { int count = new QSysUserGroup().tenantId.eq(tenantId).findCount(); if (count > 0) { return true; } count = new QDeviceGroup().tenantId.eq(tenantId).findCount(); if (count > 0) { return true; } count = new QProductType().tenantId.eq(tenantId).findCount(); if (count > 0) { return true; } return false; } /** * 启用 禁用租户 * * @param tenantId * @param status */ @Transactional(rollbackFor = Exception.class) public void status(Long tenantId, String status) { DB.update(SysUser.class).where().eq("tenantId", tenantId).asUpdate().set("status", status).update(); DB.update(TenantInfo.class).where().eq("tenantId", tenantId).asUpdate().set("status", status).update(); } private void updateTenantName() { List<TenantInfo> list = new QTenantInfo().findList(); if (ToolUtil.isEmpty(list)) { return; } DefinitionsUtil.updateTenantName(list.parallelStream().collect(Collectors.toMap(TenantInfo::getTenantId, TenantInfo::getName, (a, b) -> a))); } @Override public void run(String... args) throws Exception { updateTenantName(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/sys/service/Tenantervice.java
Java
gpl-3.0
8,517
package com.zmops.iot.web.task.controller; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.model.page.Pager; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.web.device.dto.DeviceGroupDto; import com.zmops.iot.web.task.dto.TaskDto; import com.zmops.iot.web.task.param.TaskParam; import com.zmops.iot.web.task.service.TaskService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @author yefei * <p> * 任务管理 **/ @RestController @RequestMapping("/task") public class taskController { @Autowired TaskService taskService; // /** // * 任务分页列表 // * // * @return // */ // @PostMapping("/getTaskByPage") // public Pager<DeviceGroupDto> getTaskByPage(@RequestBody TaskParam taskParam) { // return taskService.getTaskByPage(taskParam); // } // // /** // * 设任务列表 // * // * @return // */ // @PostMapping("/list") // public ResponseData list(@RequestBody TaskParam taskParam) { // return ResponseData.success(taskService.list(taskParam)); // } /** * 创建任务 * * @return */ @PostMapping("/create") // @BussinessLog(value = "创建任务") public ResponseData createTask(@Validated(BaseEntity.Create.class) @RequestBody TaskDto taskDto) { return ResponseData.success(taskService.createTask(taskDto)); } /** * 更新任务 * * @return */ @PostMapping("/update") // @BussinessLog(value = "更新任务") public ResponseData updateTask(@Validated(BaseEntity.Update.class) @RequestBody TaskDto taskDto) { return ResponseData.success(taskService.updateTask(taskDto)); } /** * 删除任务 * * @return */ @PostMapping("/delete") // @BussinessLog(value = "删除任务") public ResponseData deleteTask(@Validated(BaseEntity.Delete.class) @RequestBody TaskDto taskParam) { taskService.deleteTask(taskParam); return ResponseData.success(); } /** * 启动 停止任务 * * @return */ @PostMapping("/status") // @BussinessLog(value = "启动 停止任务") public ResponseData status(@Validated(BaseEntity.Delete.class) @RequestBody TaskDto taskDto) { taskService.status(taskDto); return ResponseData.success(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/task/controller/taskController.java
Java
gpl-3.0
2,679
package com.zmops.iot.web.task.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.zmops.iot.model.cache.filter.CachedValue; import com.zmops.iot.model.cache.filter.CachedValueFilter; import com.zmops.iot.model.cache.filter.DicType; import lombok.Data; import java.time.LocalDateTime; /** * @author yefei **/ @Data @JsonSerialize(using = CachedValueFilter.class) public class TaskDto { private Integer id; private String scheduleType = "CRON"; private String scheduleConf; private String misfireStrategy = "DO_NOTHING"; private Integer taskTimeout = 0; private Integer taskFailRetryCount = 0; @CachedValue(value = "STATUS", fieldName = "triggerStatusName") private String triggerStatus = "ENABLE"; private Long triggerLastTime = 0L; private Long triggerNextTime = 0L; private String remark; private String executorParam; LocalDateTime createTime; LocalDateTime updateTime; @CachedValue(type = DicType.SysUserName, fieldName = "createUserName") private Long createUser; @CachedValue(type = DicType.SysUserName, fieldName = "updateUserName") private Long updateUser; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/task/dto/TaskDto.java
Java
gpl-3.0
1,187
package com.zmops.iot.web.task.param; import lombok.Data; /** * @author yefei **/ @Data public class TaskParam { private Integer id; private String triggerStatus; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/task/param/TaskParam.java
Java
gpl-3.0
179
package com.zmops.iot.web.task.service; import cn.hutool.core.bean.BeanUtil; import com.zmops.iot.domain.schedule.Task; import com.zmops.iot.domain.schedule.query.QTask; import com.zmops.iot.enums.CommonStatus; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.task.dto.TaskDto; import io.ebean.DB; import org.springframework.stereotype.Service; /** * @author yefei **/ @Service public class TaskService { /** * 创建任务 * * @param taskDto * @return */ public Integer createTask(TaskDto taskDto) { Task task = new Task(); BeanUtil.copyProperties(taskDto, task); DB.insert(task); return task.getId(); } /** * 修改任务 * * @param taskDto * @return */ public TaskDto updateTask(TaskDto taskDto) { Task task = new QTask().id.eq(taskDto.getId()).findOne(); if (task == null) { task = new Task(); BeanUtil.copyProperties(taskDto, task); DB.insert(task); } else { task.setExecutorParam(taskDto.getExecutorParam()); task.setScheduleConf(taskDto.getScheduleConf()); task.setTriggerNextTime(0L); task.setRemark(taskDto.getRemark()); DB.update(task); } return taskDto; } /** * 删除任务 * * @param taskParam */ public void deleteTask(TaskDto taskParam) { if (taskParam.getId() == null) { return; } new QTask().id.eq(taskParam.getId()).delete(); } /** * 启用 禁用任务 * 默认启用 * * @param taskParam */ public void status(TaskDto taskParam) { if (taskParam.getId() == null) { return; } String triggerStatus = taskParam.getTriggerStatus(); if (ToolUtil.isEmpty(triggerStatus)) { triggerStatus = CommonStatus.DISABLE.getCode(); } DB.update(Task.class).where().eq("id", taskParam.getId()).asUpdate().set("trigger_status", triggerStatus).update(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/task/service/TaskService.java
Java
gpl-3.0
2,096
package com.zmops.iot.web.transfer.controller; import com.zmops.iot.domain.BaseEntity; import com.zmops.iot.domain.proxy.query.QProxy; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.model.page.Pager; import com.zmops.iot.model.response.ResponseData; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.transfer.dto.TransferDto; import com.zmops.iot.web.transfer.dto.param.TransferParam; import com.zmops.iot.web.transfer.service.TransferService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * @author yefei * <p> * 数据转换服务 */ @RestController @RequestMapping("/transfer") public class TransferController { @Autowired TransferService proxyService; /** * 数据转换分页列表 */ @GetMapping("/list") public ResponseData list() { return ResponseData.success(proxyService.list()); } /** * 数据转换创建 */ @RequestMapping("/create") public ResponseData create() { proxyService.create(); return ResponseData.success(); } /** * 数据转换删除 */ @RequestMapping("/delete") public ResponseData delete(@Validated(BaseEntity.Delete.class) @RequestBody TransferParam transferParam) { proxyService.delete(transferParam.getNames()); return ResponseData.success(); } /** * 数据转换启动 */ @RequestMapping("/run") public ResponseData run(@Validated @RequestBody TransferParam transferParam) { proxyService.run(transferParam); return ResponseData.success(); } /** * 数据转换停止 */ @RequestMapping("/stop") public ResponseData stop(@Validated @RequestBody TransferParam transferParam) { proxyService.stop(transferParam); return ResponseData.success(); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/transfer/controller/TransferController.java
Java
gpl-3.0
2,212
package com.zmops.iot.web.transfer.dto; import lombok.Data; /** * @author yefei **/ @Data public class ConfigDto { private String name; private String batchSize; private String batchInterval; private String createtime; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/transfer/dto/ConfigDto.java
Java
gpl-3.0
244
package com.zmops.iot.web.transfer.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.zmops.iot.model.cache.filter.CachedValueFilter; import lombok.Data; /** * @author yefei **/ @Data @JsonSerialize(using = CachedValueFilter.class) public class StatusDto { private String name; private String logpath; private String readDataSize; private String readDataCount; private String elaspedtime; private Lag lag; private ReaderStats readerStats; private ParserStats parserStats; private String readspeedKb; private String readspeed; private String runningStatus; private String senderStats; @Data public static class Lag { private String total; private String size; private String ftlags; private String sizeunit; } @Data public static class ReaderStats { private String errors; private String success; private String speed; private String trend; private String last_error; } @Data public static class ParserStats { private String errors; private String success; private String speed; private String trend; private String last_error; } @Data public static class SenderStatsObj { private String errors; private String success; private String speed; private String trend; private String last_error; } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/transfer/dto/StatusDto.java
Java
gpl-3.0
1,493
package com.zmops.iot.web.transfer.dto; import lombok.Data; /** * @author yefei **/ @Data public class TransferDto { private String name; private String createtime; private String logpath; private String readDataCount; private String lagSize; private String parseSuccess; private String parseError; private String parseTotal; private String sendSuccess; private String sendError; private String sendTotal; private String readspeedKb; private String readspeed; private String sendspeed; private String runningStatus; private String readLastError; private String parseLastError; private String sendLastError; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/transfer/dto/TransferDto.java
Java
gpl-3.0
702
package com.zmops.iot.web.transfer.dto.param; import com.zmops.iot.web.sys.dto.param.BaseQueryParam; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.util.List; /** * @author yefei **/ @Data public class TransferParam extends BaseQueryParam { @NotNull private List<String> names; private String run; }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/transfer/dto/param/TransferParam.java
Java
gpl-3.0
395
package com.zmops.iot.web.transfer.service; import com.alibaba.fastjson.JSONObject; import com.zmops.iot.model.exception.ServiceException; import com.zmops.iot.util.LocalDateTimeUtils; import com.zmops.iot.util.ParseUtil; import com.zmops.iot.util.ToolUtil; import com.zmops.iot.web.exception.enums.BizExceptionEnum; import com.zmops.iot.web.transfer.dto.ConfigDto; import com.zmops.iot.web.transfer.dto.StatusDto; import com.zmops.iot.web.transfer.dto.TransferDto; import com.zmops.iot.web.transfer.dto.param.TransferParam; import com.zmops.zeus.driver.service.TransferKit; import com.zmops.zeus.driver.service.ZbxConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.*; /** * @author yefei * <p> * 数据转换 服务 **/ @Service public class TransferService { @Autowired TransferKit transferKit; @Autowired ZbxConfig zbxConfig; /** * 转换服务列表 * * @return */ public List<TransferDto> list() { String configs = transferKit.getConfigs(); if (ToolUtil.isEmpty(configs)) { return Collections.emptyList(); } JSONObject jsonObject = JSONObject.parseObject(configs); List<TransferDto> transferDtoList = new ArrayList<>(); HashMap<String, Object> hashMap = JSONObject.parseObject(jsonObject.getString("data"), HashMap.class); for (Map.Entry<String, Object> s : hashMap.entrySet()) { ConfigDto configDto = JSONObject.parseObject(JSONObject.toJSONString(s.getValue()), ConfigDto.class); transferDtoList.add(BuildTransferDto(configDto)); } String status = transferKit.getStatus(); if (ToolUtil.isEmpty(status)) { return transferDtoList; } JSONObject statusObject = JSONObject.parseObject(status); HashMap<String, Object> statusMap = JSONObject.parseObject(statusObject.getString("data"), HashMap.class); transferDtoList.forEach(transferDto -> { if (null != statusMap.get(transferDto.getName())) { StatusDto statusDto = JSONObject.parseObject(JSONObject.toJSONString(statusMap.get(transferDto.getName())), StatusDto.class); transferDto.setLogpath(statusDto.getLogpath()); transferDto.setReadDataCount(ParseUtil.getCommaFormat(statusDto.getReadDataCount())); transferDto.setReadLastError(statusDto.getReaderStats().getLast_error()); transferDto.setLagSize(ParseUtil.formatLagSize(statusDto.getLag().getSize())); transferDto.setParseError(ToolUtil.isEmpty(statusDto.getParserStats().getErrors()) ? "0" : statusDto.getParserStats().getErrors()); transferDto.setParseSuccess(ToolUtil.isEmpty(statusDto.getParserStats().getSuccess()) ? "0" : statusDto.getParserStats().getSuccess()); transferDto.setParseTotal(transferDto.getParseSuccess() + transferDto.getParseError()); transferDto.setParseLastError(statusDto.getParserStats().getLast_error()); HashMap<String, Object> sendStatusMap = JSONObject.parseObject(statusDto.getSenderStats(), HashMap.class); for (Map.Entry map : sendStatusMap.entrySet()) { StatusDto.SenderStatsObj senderStatsObj = JSONObject.parseObject(JSONObject.toJSONString(map.getValue()), StatusDto.SenderStatsObj.class); transferDto.setSendSuccess(ToolUtil.isEmpty(senderStatsObj.getSuccess()) ? "0" : senderStatsObj.getSuccess()); transferDto.setSendError(ToolUtil.isEmpty(senderStatsObj.getErrors()) ? "0" : senderStatsObj.getErrors()); transferDto.setSendTotal(transferDto.getSendSuccess() + transferDto.getSendError()); transferDto.setSendspeed(ToolUtil.isEmpty(senderStatsObj.getSpeed()) ? "0" : senderStatsObj.getSpeed()); transferDto.setSendLastError(senderStatsObj.getLast_error()); } transferDto.setReadspeed(statusDto.getReadspeed()); transferDto.setReadspeedKb(statusDto.getReadspeedKb()); transferDto.setRunningStatus(statusDto.getRunningStatus().equalsIgnoreCase("running") ? "ENABLE" : "DISABLE"); } }); return transferDtoList; } private TransferDto BuildTransferDto(ConfigDto configDto) { TransferDto transferDto = new TransferDto(); transferDto.setName(configDto.getName()); transferDto.setCreatetime(configDto.getCreatetime()); return transferDto; } /** * 转换服务创建 * * @return */ public void create() { String config = zbxConfig.getConfig(); if (ToolUtil.isEmpty(config)) { throw new ServiceException(BizExceptionEnum.ZBX_SERBER_NOT_CONFIG); } Map<String, String> map = JSONObject.parseObject(config, Map.class); String exportPath = map.get("ExportDir"); String StartDBSyncers = map.get("StartDBSyncers"); if (null == exportPath || "".equals(exportPath) || null == StartDBSyncers || "".equals(StartDBSyncers)) { throw new ServiceException(BizExceptionEnum.ZBX_SERBER_EXPORT_PATH_NOT_CONFIG); } int dbSyncers = Integer.parseInt(StartDBSyncers); for (int i = 1; i <= dbSyncers; i++) { String logPath = exportPath + "/history-history-syncer-" + i + ".ndjson"; String name = "runner:" + LocalDateTimeUtils.getMilliByTime(LocalDateTime.now()); transferKit.createRunner(name, name, logPath, 20, 2097152); } } /** * 转换服务删除 * * @param names * @return */ public void delete(List<String> names) { names.forEach(name -> { transferKit.deleteRunner(name); }); } /** * 数据转换启动 */ public void run(TransferParam transferParam) { if (ToolUtil.isEmpty(transferParam.getRun()) || !"true".equals(transferParam.getRun())) { stop(transferParam); } transferParam.getNames().forEach(name -> { transferKit.startRunner(name); }); } /** * 数据转换停止 */ public void stop(TransferParam transferParam) { transferParam.getNames().forEach(name -> { transferKit.stopRunner(name); }); } }
2301_81045437/zeus-iot
zeus-webapp/src/main/java/com/zmops/iot/web/transfer/service/TransferService.java
Java
gpl-3.0
6,577
import streamlit as st import pandas as pd import streamlit.components.v1 as components from jinja2 import Template import os import re import time import jieba import pdfplumber import warnings import logging import base64 from st_aggrid import AgGrid, GridOptionsBuilder # 页面美化:苹果风格极简设计 st.set_page_config(page_title="公司信息查询系统", layout="wide") # 引入外部CSS with open("style/custom.css", "r", encoding="utf-8") as f: st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True) # 搜索框状态管理 if 'searchbox' not in st.session_state: st.session_state['searchbox'] = '' # 在渲染输入框前处理pending_searchbox if 'pending_searchbox' in st.session_state: st.session_state['searchbox'] = st.session_state['pending_searchbox'] del st.session_state['pending_searchbox'] # 读取数据 @st.cache_data(ttl=300) # 缓存5分钟 def load_data(): try: with st.spinner("正在加载数据..."): df = pd.read_excel("new.xlsx") # 读取所有列 return df except Exception as e: st.error(f"数据加载失败:{e}") return pd.DataFrame() # 添加刷新数据的函数 def refresh_data(): st.cache_data.clear() return load_data() df = load_data() # 内容卡片区 st.markdown('<div class="apple-title">公司数字化信息查询系统</div>', unsafe_allow_html=True) st.markdown('<div class="apple-subtitle">极简设计 · 极速检索 </div>', unsafe_allow_html=True) # 简单搜索框 st.markdown('<div class="simple-search-container">', unsafe_allow_html=True) search_input = st.text_input( "搜索企业", # 非空label,隐藏 key="searchbox", placeholder="例如:北京大豪科技股份有限公司", label_visibility="collapsed" ) st.markdown('</div>', unsafe_allow_html=True) # 模糊搜索和下拉建议功能 search_input = st.session_state.get('searchbox', '') # 生成搜索建议 def get_search_suggestions(query, df, max_suggestions=10): if not query: return [] suggestions = [] query_lower = query.lower() # 搜索股票代码 code_matches = df[df["股票代码"].astype(str).str.contains(query, case=False, na=False)] for _, row in code_matches.head(5).iterrows(): suggestions.append(f"{row['股票代码']} - {row['企业名称']}") # 搜索企业名称 name_matches = df[df["企业名称"].str.contains(query, case=False, na=False)] for _, row in name_matches.head(5).iterrows(): suggestion = f"{row['股票代码']} - {row['企业名称']}" if suggestion not in suggestions: suggestions.append(suggestion) return suggestions[:max_suggestions] # 显示搜索建议 if search_input: suggestions = get_search_suggestions(search_input, df) if suggestions and len(suggestions) > 0: st.markdown('<div class="suggestions-title">💡 搜索建议:</div>', unsafe_allow_html=True) for i, suggestion in enumerate(suggestions): if st.button(f"📋 {suggestion}", key=f"suggestion_{i}", help="点击选择此选项"): if " - " in suggestion: selected_text = suggestion.split(" - ")[1] else: selected_text = suggestion st.session_state['pending_searchbox'] = selected_text st.experimental_rerun() # 查询逻辑 if search_input: result = df[ df["股票代码"].astype(str).str.contains(search_input, case=False, na=False) | df["企业名称"].str.contains(search_input, case=False, na=False) ] if len(result) > 0: st.success(f"找到 {len(result)} 条匹配记录") else: st.warning("未找到匹配的记录") else: # 当用户没有输入时,显示所有数据 result = df # 数据统计极简卡片 st.markdown('<div style="text-align:center; margin-top:2em;">', unsafe_allow_html=True) st.info(f"总记录数:{len(df)}", icon="📊") # 分页功能 page_size = 10 # 每页显示10个企业 total = len(result) total_pages = (total - 1) // page_size + 1 # 初始化 if 'current_page' not in st.session_state: st.session_state['current_page'] = 1 # 读取URL参数并同步 params = st.query_params if "page" in params: try: page = int(params["page"]) if 1 <= page <= total_pages: st.session_state['current_page'] = page except: pass current_page = st.session_state['current_page'] # 获取当前页数据 start_idx = (current_page - 1) * page_size end_idx = min(start_idx + page_size, total) current_page_data = result.iloc[start_idx:end_idx] # 股票代码补零 if '股票代码' in current_page_data.columns: current_page_data['股票代码'] = current_page_data['股票代码'].astype(str).str.zfill(6) # 按钮和说明在表格上方一行 row1_col1, _ = st.columns([1, 1]) with row1_col1: if st.button("上传年报", help="支持批量上传多个PDF年报文件,解析提取数字化指数"): st.session_state['show_upload'] = True if st.session_state.get('show_upload', False): uploaded_files = st.file_uploader( "", type=["pdf"], label_visibility="collapsed", key="pdf_upload", accept_multiple_files=True) if uploaded_files is not None and len(uploaded_files) > 0: # 创建统一的进度条 total_files = len(uploaded_files) progress_bar = st.progress(0, text=f"正在批量解析 {total_files} 个文件...") # 批量处理文件 for file_index, uploaded_file in enumerate(uploaded_files): filename = uploaded_file.name is_pdf = filename.lower().endswith('.pdf') code_match = re.search(r'\d{6}', filename) name_match = '公司' in filename if not is_pdf or (not code_match and not name_match): continue # 跳过不合规文件 save_path = os.path.join("pdfData", filename) with open(save_path, "wb") as f: f.write(uploaded_file.getbuffer()) # 只更新进度条 current_progress = file_index / total_files progress_bar.progress(current_progress, text=f"完成第 {file_index}/{total_files} 个文件的解析, 正在解析中……") import time time.sleep(0.1) try: # 维度与关键词 dimensions = { '人工智能技术': ['人工智能', '图像理解', '智能数据分析', '智能机器人', '机器学习', '深度学习', '语义搜索', '语言识别', '身份验证', '自动驾驶', '自然语言处理', '神经网络', '卷积神经'], '区块链技术': ['区块链', '分布式记账', '数字货币', '差分隐私技术', '智能金融合约', '加密货币'], '大数据技术': ['大数据', '数据挖掘', '文本挖掘', '数据可视化', '异构数据', '增强现实', '混合现实', '虚拟现实', '图像识别', '机器视觉', '雷达点云'], '云计算技术': ['云计算', '流计算', '图计算', '内存计算', '安全计算', '类脑计算认知计算', '融合架构', 'EB级存储', '物联网', '信息物理系统', '机器通信'], '数字技术应用': ['移动互联网', '人工互联网', '无人工厂', '互联网医疗', '电子商务', '移动支付', '第三方支付', 'NFC支付', '智能能源', 'B2B', 'B2C', 'C2B', 'C2C', 'O2O', '智能穿戴', '智慧农业', '智能交通', '智慧医疗', '智慧客服', '智能家居', '智能文旅', '智能环保', '智能电网', '智慧营销', '数字销售', '无人零售', '互联网金融', '数字金融', 'Fintech', '金融科技', '量化金融', '开放银行'] } # 提取股票代码 stock_code = code_match.group(0) if code_match else '' stock_code = stock_code.zfill(6) # 补齐6位 # 解析PDF with pdfplumber.open(save_path) as pdf: text = "" for page in pdf.pages: text += page.extract_text() if page.extract_text() else "" # 企业名正则 company_name_pattern = re.compile(r'([\u4e00-\u9fa5a-zA-Z()()\s]+公司)') match = company_name_pattern.search(text[:1000]) company_name = match.group(1) if match else '未找到企业名' words = jieba.lcut(text) row = {dim: 0 for dim in dimensions.keys()} total_keywords = 0 for dimension, keywords in dimensions.items(): for keyword in keywords: count = words.count(keyword) row[dimension] += count total_keywords += count row['总词频数'] = total_keywords row['企业名称'] = company_name # 追加到new.xlsx if os.path.exists("new.xlsx"): df = pd.read_excel("new.xlsx") else: df = pd.DataFrame() # 构造新行 new_row = { '股票代码': stock_code, '企业名称': row['企业名称'], '数字技术应用': row['数字技术应用'], '人工智能技术': row['人工智能技术'], '区块链技术': row['区块链技术'], '大数据技术': row['大数据技术'], '云计算技术': row['云计算技术'], '总词频数': row['总词频数'] } # 检查企业名称是否已存在 exists = False if not df.empty and new_row['企业名称'] in df['企业名称'].values: exists = True # 删除企业名称相同的行 df = df[df['企业名称'] != new_row['企业名称']] # 追加新行 df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True) df['股票代码'] = df['股票代码'].astype(str).str.zfill(6) # 写入前补零 df.to_excel("new.xlsx", index=False) except Exception as e: pass # 处理完成后,进度条100% progress_bar.progress(1.0, text=f"批量解析完成!共处理 {total_files} 个文件") time.sleep(1) # 自动刷新数据 st.success(f"✅ 年报解析完成!共处理 {total_files} 个文件,数据已自动更新") # 清除缓存并重新加载数据 st.cache_data.clear() df = refresh_data() # 重置上传状态 st.session_state['show_upload'] = False # 强制刷新页面 st.experimental_rerun() # 表格显示 st.dataframe(current_page_data, use_container_width=True, height=400) # 页码文本紧贴表格底部并居中 st.markdown( f'''<div style="width:100%;text-align:center;font-size:13px;font-weight:500;background:#f8f9fa;border-radius:6px;border:1.5px solid #e9ecef;padding:0 24px;min-width:180px;height:28px;display:flex;align-items:center;justify-content:center;color:#333;margin:0 auto 0 auto;">第 {current_page} 页 / 共 {total_pages} 页</div>''', unsafe_allow_html=True ) # 分页按钮(在页码信息下方) if total_pages > 1: st.markdown(""" <style> .pager-btn-row { display: flex; justify-content: space-between; align-items: center; margin-top: 0; margin-bottom: 0; padding: 0 8vw 0 8vw; } .pager-btn-row .stButton > button { height: 28px !important; min-width: 36px !important; font-size: 13px !important; background: #f8f9fa !important; color: #333 !important; border: 1.5px solid #b2bec3 !important; border-radius: 6px !important; padding: 0 12px !important; box-shadow: none !important; margin: 0 !important; } .pager-btn-row .stButton > button:disabled { background: #f1f2f6 !important; color: #b2bec3 !important; border: 1.5px solid #dfe4ea !important; opacity: 0.7 !important; } </style> """, unsafe_allow_html=True) st.markdown('<div class="pager-btn-row">', unsafe_allow_html=True) col_left,_, j, i, col_right = st.columns([1,2,3,2,1]) with col_left: prev_disabled = current_page <= 1 if st.button("◀", key="prev_page", disabled=prev_disabled): st.session_state['current_page'] = max(1, current_page - 1) st.experimental_rerun() with col_right: next_disabled = current_page >= total_pages st.markdown('<div style="display:flex;justify-content:flex-end;">', unsafe_allow_html=True) if st.button("▶", key="next_page", disabled=next_disabled): st.session_state['current_page'] = min(total_pages, current_page + 1) st.experimental_rerun() st.markdown('</div>', unsafe_allow_html=True) st.markdown('</div>', unsafe_allow_html=True) # 底部极简灰色小字 st.markdown(""" <div style='text-align:center; color: #b2bec3; font-size:0.95em; margin-top:32px;'> © 2025 公司数字化信息查询系统 | 联系方式:1141194854@qq.com </div> """, unsafe_allow_html=True) st.markdown( """ <style> .stApp, .block-container, .main { background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 90%) !important; min-height: 100vh; } </style> """, unsafe_allow_html=True )
2301_81200836/bigDataPro01
app.py
Python
unknown
14,138
body { background: #f5f6fa; } section.main > div { background: #f5f6fa; } .card { background: #fff; border-radius: 24px; box-shadow: 0 4px 24px 0 rgba(0,0,0,0.06); padding: 48px 32px 32px 32px; margin: 32px auto 24px auto; max-width: 700px; } .apple-title { font-size: 2.8em; font-weight: 700; color: #222; text-align: center; letter-spacing: 1px; margin-bottom: 0.2em; font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Arial,sans-serif; } .apple-subtitle { font-size: 1.2em; color: #888; text-align: center; margin-bottom: 2em; font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Arial,sans-serif; } input, .stTextInput > div > div > input { border-radius: 16px !important; border: 1px solid #e0e0e0 !important; box-shadow: 0 2px 8px 0 rgba(0,0,0,0.03) !important; padding: 12px 16px !important; font-size: 1.1em !important; background: #fafbfc !important; } .stButton > button { border-radius: 16px !important; background: linear-gradient(90deg,#e0eafc,#cfdef3); color: #222; font-weight: 600; border: none; box-shadow: 0 2px 8px 0 rgba(0,0,0,0.04); padding: 10px 32px; font-size: 1.1em; margin-top: 8px; transition: background 0.2s; } .stButton > button:hover { background: linear-gradient(90deg,#d2e1fb,#e2eafc); } .stDataFrame, .stTable { border-radius: 16px; overflow: hidden; box-shadow: 0 2px 12px 0 rgba(0,0,0,0.04); } .stAlert, .stInfo { border-radius: 16px; } input[type="text"], .stTextInput > div > div > input { cursor: text !important; caret-color: auto; transition: box-shadow 0.2s, border-color 0.2s; } input[type="text"]:hover, .stTextInput > div > div > input:hover { border-color: #4a90e2 !important; box-shadow: 0 0 0 3px rgba(74,144,226,0.15) !important; } input[type="text"]:focus, .stTextInput > div > div > input:focus { border-color: #e0e0e0 !important; box-shadow: 0 0 0 3px rgba(74,144,226,0.10) !important; } .input-row { display: flex; justify-content: center; align-items: center; margin-top: 24px; } .input-row .stTextInput { flex: 1 1 0; max-width: 400px; } .input-row .stButton { margin-left: -8px; } .search-bar-flex { display: flex; justify-content: center; align-items: center; margin-top: 32px; } .search-bar-flex input[type="text"] { height: 44px; border-radius: 16px 0 0 16px; border: 1px solid #e0e0e0; border-right: none; font-size: 1.1em; background: #fafbfc; padding: 0 16px; outline: none; width: 320px; } .search-bar-flex button { height: 44px; border-radius: 0 16px 16px 0; border: 1px solid #e0e0e0; border-left: none; background: linear-gradient(90deg,#e0eafc,#cfdef3); color: #222; font-weight: 600; font-size: 1.1em; padding: 0 28px; cursor: pointer; transition: background 0.2s; box-shadow: none; } .search-bar-flex button:hover { background: linear-gradient(90deg,#d2e1fb,#e2eafc); } .input-btn-row { display: flex; justify-content: center; align-items: center; margin-top: 32px; } .input-btn-row .stTextInput input { height: 44px; border-radius: 16px 0 0 16px; border-right: none; font-size: 1.1em; background: #fafbfc; } .input-btn-row .stButton button { height: 44px; border-radius: 0 16px 16px 0; border-left: none; background: linear-gradient(90deg,#e0eafc,#cfdef3); color: #222; font-weight: 600; font-size: 1.1em; margin-left: -4px; padding: 0 28px; box-shadow: none; } .animated-search-bar-container { display: flex; justify-content: center; align-items: center; margin-top: 48px; min-height: 60px; } .animated-search-btn { height: 44px; border-radius: 16px; background: linear-gradient(90deg,#e0eafc,#cfdef3); color: #222; font-weight: 600; font-size: 1.1em; border: 1px solid #e0e0e0; padding: 0 32px; box-shadow: 0 2px 8px 0 rgba(0,0,0,0.04); cursor: pointer; transition: all 0.4s cubic-bezier(.4,0,.2,1); outline: none; margin-left: 0; } .animated-search-form { display: flex; align-items: center; } .animated-search-form input[type="text"], .animated-search-form .slide-input { width: 260px; opacity: 1; transform: none; transition: none; height: 44px; border-radius: 16px 0 0 16px; border: 1px solid #e0e0e0; border-right: none; font-size: 1.1em; background: #fafbfc; padding: 0 16px; outline: none; margin-right: 0; } .animated-search-form.expanded input[type="text"] { width: 260px; opacity: 1; margin-right: 0; } @keyframes slideIn { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: translateX(0); } } .simple-search-container { display: flex; justify-content: center; align-items: center; margin-top: 48px; min-height: 60px; } .simple-search-form { display: flex; align-items: center; gap: 0; } .simple-search-form input[type="text"] { width: 320px; height: 44px; border-radius: 16px; border: none; font-size: 1.1em; background: #fafbfc; padding: 0 16px; outline: none; transition: box-shadow 0.2s; box-shadow: 0 2px 8px 0 rgba(0,0,0,0.03); } .simple-search-form input[type="text"]:hover { box-shadow: 0 4px 12px 0 rgba(0,0,0,0.08); } .simple-search-form input[type="text"]:focus { box-shadow: 0 0 0 3px rgba(74,144,226,0.10); } .simple-search-btn { height: 44px; border-radius: 0 16px 16px 0; border: 1px solid #e0e0e0; border-left: none; background: linear-gradient(90deg,#e0eafc,#cfdef3); color: #222; font-weight: 600; font-size: 1.1em; padding: 0 28px; cursor: pointer; transition: background 0.2s; box-shadow: none; } .simple-search-btn:hover { background: linear-gradient(90deg,#d2e1fb,#e2eafc); } .search-suggestions { margin-top: 16px; padding: 16px; background: #fff; border-radius: 16px; box-shadow: 0 4px 12px 0 rgba(0,0,0,0.08); max-width: 400px; margin-left: auto; margin-right: auto; } .suggestions-title { font-size: 0.9em; color: #666; margin-bottom: 12px; font-weight: 500; } .search-suggestions button { width: 100%; text-align: left; background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 8px; padding: 8px 12px; margin-bottom: 4px; font-size: 0.9em; color: #333; cursor: pointer; transition: all 0.2s; } .search-suggestions button:hover { background: #e9ecef; border-color: #4a90e2; transform: translateY(-1px); box-shadow: 0 2px 4px 0 rgba(0,0,0,0.1); }
2301_81200836/bigDataPro01
style/custom.css
CSS
unknown
6,759
<div class="simple-search-container"> <form id="search-form" class="simple-search-form" autocomplete="off"> <input id="search-input" name="searchbox" type="text" placeholder="请输入例如:中天金融" autocomplete="off" /> </form> </div>
2301_81200836/bigDataPro01
templates/search_bar.html
HTML
unknown
258
# IO Hardware Abstraction obj-$(USE_IOHWAB) += IoHwAb_Digital.o obj-$(USE_IOHWAB) += IoHwAb_Analog.o obj-$(USE_IOHWAB) += IoHwAb_Pwm.o vpath-$(USE_IOHWAB) += $(ROOTDIR)/Peripherals/IoHwAb/src inc-$(USE_IOHWAB) += $(ROOTDIR)/Peripherals/IoHwAb/src inc-$(USE_IOHWAB) += $(ROOTDIR)/Peripherals/IoHwAb/inc
2301_81045437/classic-platform
Peripherals/IoHwAb/IoHwAb.mod.mk
Makefile
unknown
313
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #ifndef IOHWAB_H_ #define IOHWAB_H_ #define IOHWAB_SW_MAJOR_VERSION 1u #define IOHWAB_SW_MINOR_VERSION 0u #define IOHWAB_SW_PATCH_VERSION 0u #define IOHWAB_MODULE_ID 254u #define IOHWAB_VENDOR_ID 60u #if defined(CFG_IOHWAB_USE_SERVICE_COMPONENT) #include "Rte_Type.h" #endif #include "IoHwAb_Cfg.h" #include "IoHwAb_Types.h" #include "IoHwAb_Analog.h" #include "IoHwAb_Digital.h" #include "IoHwAb_Pwm.h" #if (IOHWAB_USING_ADC == STD_ON) #if defined(USE_ADC) #include "Adc.h" #else #error "ADC Module is needed by IOHWAB" #endif #endif #if (IOHWAB_USING_PWM == STD_ON) #if defined(USE_PWM) #include "Pwm.h" #else #error "PWM Module is needed by IOHWAB" #endif #endif #if (IOHWAB_USING_DIO == STD_ON) #if defined(USE_DIO) #include "Dio.h" #else #error "DIO Module is needed by IOHWAB" #endif #endif #define IOHWAB_UNLOCKED 0u #define IOHWAB_LOCKED 1u /******************************************** API ids *********************************************/ #define IOHWAB_INIT_ID 0x10u #define IOHWAB_ANALOG_READ_ID 0x20u #define IOHWAB_ANALOG_IO_CONTROL_ID 0x21u #define IOHWAB_DIGITAL_READ_ID 0x30u #define IOHWAB_DIGITAL_WRITE_ID 0x31u #define IOHWAB_DIGITAL_WRITE_READBACK_ID 0x32u #define IOHWAB_DIGITAL_IO_CONTROL_ID 0x33u #define IOHWAB_PWMDUTY_SET_ID 0x40u #define IOHWAB_PWMFREQUENCYANDDUTY_SET_ID 0x41u #define IOHWAB_PWM_IO_CONTROL_ID 0x42u #define IOHWAB_CAPTURE_GET_ID 0x50u /***************************************** DET error ids ******************************************/ #define IOHWAB_E_INIT 0x01u #define IOHWAB_E_PARAM_SIGNAL 0x11u #define IOHWAB_E_PARAM_DUTY 0x12u #define IOHWAB_E_PARAM_LEVEL 0x13u #define IOHWAB_E_PARAM_ACTION 0x14u #define IOHWAB_E_PARAM_PTR 0x15u /******************************************* DET macros *******************************************/ #if (IOHWAB_DEV_ERROR_DETECT == STD_ON) #define IOHWAB_DET_REPORT_ERROR(api, error) \ (void)Det_ReportError(IOHWAB_MODULE_ID, 0, api, error); \ #define IOHWAB_VALIDATE(expression, api, error) \ if ( !(expression) ) { \ IOHWAB_DET_REPORT_ERROR(api, error); \ } \ #define IOHWAB_VALIDATE_RETURN(expression, api, error, rv) \ if ( !(expression) ) { \ IOHWAB_DET_REPORT_ERROR(api, error); \ return rv; \ } \ #else /* IOHWAB_DEV_ERROR_DETECT */ #define IOHWAB_DET_REPORT_ERROR(api, error) #define IOHWAB_VALIDATE(expression, api, error) #define IOHWAB_VALIDATE_RETURN(expression, api, error, rv) #endif /* IOHWAB_DEV_ERROR_DETECT */ #define IoHwAb_LockSave(_x) Irq_Save(_x) #define IoHwAb_LockRestore(_x) Irq_Restore(_x) void IoHwAb_Init( void ); void IoHwAb_MainFunction( void ); #if (IOHWAB_USING_ADC == STD_ON) /* If using ADC, IoHwAb must implement a read function for Adc values */ Adc_ValueGroupType IoHwAb_Adc_ReadSignal( Adc_GroupType group, Adc_ChannelType channel, IoHwAb_StatusType * status ); #endif #if (IOHWAB_USING_PWM_FREQ == STD_ON) /* If using PWM with frequency, IoHwAb must implement conversion function from frequency to period */ Pwm_PeriodType IoHwAb_Pwm_ConvertToPeriod(Pwm_ChannelType channel, IoHwAb_FrequencyType freq); #endif #endif /* IOHWAB_H_ */
2301_81045437/classic-platform
Peripherals/IoHwAb/inc/IoHwAb.h
C
unknown
4,319
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #ifndef IOHWAB_INTERNAL_H_ #define IOHWAB_INTERNAL_H_ #include "Cpu.h" #if defined(USE_DEM) #include "Dem.h" #include "Rte_Dem_Type.h" #endif #if defined(USE_DET) #include "Det.h" #endif /** * Takes a ptr to an array of big endian data and returns a uint32 * @param src * @return converted data */ static inline uint32 GetU32FromPtr(uint8* src) { uint32 value = *(src) << 24u; value = (*(src + 1) << 16u) | value; value = (*(src + 2) << 8u) | value; value = (*(src + 3)) | value; return value; } /** * Takes a value and copies that value to an array of big endian data * @param value * @param dst */ static inline void SetU32ToPtr(uint32 value, uint8* dst) { *(dst) = (value & 0xFF000000) >> 24u ; *(dst + 1) = (value & 0x00FF0000) >> 16u ; *(dst + 2) = (value & 0x0000FF00) >> 8u ; *(dst + 3) = (value & 0x000000FF); } /** * Takes a ptr to an array of big endian data and returns a sint32 * @param src * @return converted data */ static inline sint32 GetS32FromPtr(uint8* src) { sint32 value = *(src) << 24u; value = (*(src + 1) << 16u) | value; value = (*(src + 2) << 8u) | value; value = (*(src + 3)) | value; return value; } /** * Takes a value and copies that value to an array of big endian data * @param value * @param dst */ static inline void SetS32ToPtr(sint32 value, uint8* dst) { *(dst) = (value & 0xFF000000) >> 24 ; *(dst + 1) = (value & 0x00FF0000) >> 16 ; *(dst + 2) = (value & 0x0000FF00) >> 8 ; *(dst + 3) = (value & 0x000000FF); } #endif /* IOHWAB_INTERNAL_H_ */
2301_81045437/classic-platform
Peripherals/IoHwAb/inc/IoHwAb_Internal.h
C
unknown
2,408
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #ifndef IOHWAB_TYPES_H_ #define IOHWAB_TYPES_H_ #include "Std_Types.h" /* Digital levels */ typedef uint8 IoHwAb_LevelType; /* Analog values base type */ typedef sint32 IoHwAb_AnalogValueType; #if !defined(CFG_IOHWAB_USE_SERVICE_COMPONENT) typedef uint32 IoHwAb_SignalType; #endif /* Duty cycle type */ typedef uint32 IoHwAb_DutyType; #define IOHWAB_DUTY_MIN (IoHwAb_DutyType)0u /* 0% */ #define IOHWAB_DUTY_MAX (IoHwAb_DutyType)0x8000u /* 100% */ /* Frequency type (Hz) */ typedef uint32 IoHwAb_FrequencyType; /* ISO14229, IoControl */ #define IOHWAB_RETURNCONTROLTOECU 0 #define IOHWAB_RESETTODEFAULT 1 #define IOHWAB_FREEZECURRENTSTATE 2 #define IOHWAB_SHORTTERMADJUST 3 /** Enum literals for DigitalLevel */ #ifndef IOHWAB_LOW #define IOHWAB_LOW 0U #endif /* IOHWAB_LOW */ #ifndef IOHWAB_HIGH #define IOHWAB_HIGH 1U #endif /* IOHWAB_HIGH */ /** Enum literals for SignalQuality */ #ifndef IOHWAB_INIVAL #define IOHWAB_INIVAL 0U #endif /* IOHWAB_INIVAL */ #ifndef IOHWAB_ERR #define IOHWAB_ERR 1U #endif /* IOHWAB_ERR */ #ifndef IOHWAB_BAD #define IOHWAB_BAD 2U #endif /* IOHWAB_BAD */ #ifndef IOHWAB_GOOD #define IOHWAB_GOOD 3U #endif /* IOHWAB_GOOD */ typedef uint8 IoHwAb_QualityType; typedef struct { uint8 quality; } IoHwAb_StatusType; #endif /* IOHWAB_TYPES_H_ */
2301_81045437/classic-platform
Peripherals/IoHwAb/inc/IoHwAb_Types.h
C
unknown
2,129
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #include "Spi.h" #include "CanTrcv.h" #include "CanTrcv_TJA1145.h" #include "CanTrcv_Internal.h" /* Internal functions to read and write using SPI */ Std_ReturnType spiRead(uint8 cmd, uint8 *data, const CanTrcv_SpiSequenceConfigType *SEQ_NXP); Std_ReturnType spiWrite(uint8 cmd, uint8 data, const CanTrcv_SpiSequenceConfigType *SEQ_NXP); static Std_ReturnType CanTrcv_Hw_ReadPowerOnStatus(boolean * failSts,const CanTrcv_SpiSequenceConfigType *spiSeq); #define SPI_Write(regAddr, regData,spiSeq) \ if (E_NOT_OK == spiWrite(regAddr, regData,spiSeq)) { \ return E_NOT_OK; \ } #define SPI_Read(regAddr, regData,spiSeq) \ if (E_NOT_OK == spiRead(regAddr, &regData,spiSeq)) { \ return E_NOT_OK; \ } /** * SPI Read and Write to TJ1145 * * @param cmd * @param data * @param SEQ_NXP * @param write * @return */ static Std_ReturnType spiReadWrite(uint8 cmd, uint8 *data, const CanTrcv_SpiSequenceConfigType *SEQ_NXP, boolean write) { Std_ReturnType rv; uint16 try = 0; cmd = (Spi_DataType)((Spi_DataType)cmd << 1); rv = Spi_SetupEB( SEQ_NXP->CanTrcvSpiCmdChannel, &cmd, NULL, 1u ); if( rv == E_OK ) { if ( write ) { rv = Spi_SetupEB( SEQ_NXP->CanTrcvSpiDataChannel, data, NULL, 1u); /* Write */ } else { rv = Spi_SetupEB( SEQ_NXP->CanTrcvSpiDataChannel, NULL, data, 1u); /* Read */ } if( rv == E_OK ) { #if defined(CFG_TJA1145_SPI_ASYNC) rv = Spi_AsyncTransmit(SEQ_NXP->CanTrcvSpiSequenceName); #else rv = Spi_SyncTransmit(SEQ_NXP->CanTrcvSpiSequenceName); #endif while( Spi_GetSequenceResult(SEQ_NXP->CanTrcvSpiSequenceName) == SPI_SEQ_PENDING ) { if( ++try > SPI_GET_RESULT_MAX_TRY ) { rv = E_NOT_OK; break; } /* Wait */ Spi_MainFunction_Handling(); } } } return rv; } Std_ReturnType spiRead(uint8 cmd, uint8 *data, const CanTrcv_SpiSequenceConfigType *SEQ_NXP) { return spiReadWrite( cmd, data,SEQ_NXP, FALSE ); } Std_ReturnType spiWrite(uint8 cmd, uint8 data, const CanTrcv_SpiSequenceConfigType *SEQ_NXP) { return spiReadWrite( cmd, &data,SEQ_NXP, TRUE ); } /* Set Data rate */ Std_ReturnType CanTrcv_Hw_SetBaudRate(uint16 baudRate,const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; ret=E_OK; switch (baudRate) { case CANTRCV_BAUD_RATE_50KBPS: regData= REGISTER_0x26_CDR_50; break; case CANTRCV_BAUD_RATE_100KBPS: regData= REGISTER_0x26_CDR_100; break; case CANTRCV_BAUD_RATE_125KBPS: regData= REGISTER_0x26_CDR_125; break; case CANTRCV_BAUD_RATE_250KBPS: regData= REGISTER_0x26_CDR_250; break; case CANTRCV_BAUD_RATE_500KBPS: regData= REGISTER_0x26_CDR_500; break; case CANTRCV_BAUD_RATE_1000KBPS: regData= REGISTER_0x26_CDR_1000; break; default: ret = E_NOT_OK; break; } /* End of Switch Case */ if (E_OK == ret) { regAddr = (uint8)REGISTER_0x26_ADDR; /* Send data and Command on SPI to configure Baud rate */ SPI_Write(regAddr, regData,spiSeq); } return ret; } #if (CANTRCV_WAKE_UP_SUPPORTED == STD_ON) /* Enable selective wake up */ Std_ReturnType CanTrcv_Hw_EnablePN(const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; ret=E_OK; regAddr = (uint8)REGISTER_0x20_ADDR; /*CAN control register */ regData = (uint8)(REGISTER_20h_CPNC_SET |REGISTER_20h_PNCOK_SET); SPI_Write(regAddr, regData,spiSeq); ret = CanTrcv_Hw_EnableWakeUpEvent(spiSeq); if (E_NOT_OK == ret){ return ret; } regAddr = (uint8)REGISTER_0x22_ADDR; /*Trcv status register*/ regData = 0; SPI_Read(regAddr, regData,spiSeq); if (((regData & REGISTER_22h_CPNERR_MASK) == REGISTER_22h_CPNERR_MASK) || ((regData & (REGISTER_22h_CPNS_MASK )) != (REGISTER_22h_CPNS_MASK ))) { ret = E_NOT_OK; /*Error detected or Trcv not sucessfully setup*/ } return ret; } /* Disable selective wake up */ Std_ReturnType CanTrcv_Hw_DisablePN(const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; ret=E_OK; regAddr = (uint8)REGISTER_0x20_ADDR; /*CAN control register */ regData = 0; SPI_Read(regAddr, regData,spiSeq); regData &= (uint8)~REGISTER_20h_CPNC_SET; SPI_Write(regAddr, regData,spiSeq); return ret; } /* Set PN registers for wake up frame */ Std_ReturnType CanTrcv_Hw_SetupPN(const CanTrcv_PartialNetworkConfigType* partialNwConfig,const CanTrcv_SpiSequenceConfigType *spiSeq){ Std_ReturnType ret; uint8 regData; uint8 regAddr; boolean cFlag; boolean idFlag; uint8 loopCnt; uint8 idxCnt; ret=E_OK; cFlag = (partialNwConfig->CanTrcvPnFrameDataMaskSize !=0); idFlag = (partialNwConfig->CanTrcvPnCanIdIsExtended); regAddr = (uint8)REGISTER_0x2F_ADDR; /* Frame control register */ regData = idFlag?REGISTER_0x2F_IDE_EXT: REGISTER_0x2F_IDE_STD ; regData |= cFlag ? (REGISTER_0x2F_PNDM |partialNwConfig->CanTrcvPnFrameDlc) : 0; SPI_Write(regAddr, regData,spiSeq); if (idFlag){ /* For extended frames update Id and Mask */ regAddr = (uint8)REGISTER_0x27_ADDR; /* ID register 0 */ regData = (uint8)partialNwConfig->CanTrcvPnFrameCanId; SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x28_ADDR; /*ID register 1 */ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanId >> 8u); SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x29_ADDR; /*ID register 2*/ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanId >> 16u); SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x2A_ADDR; /*ID register 3*/ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanId >> 24u) & 0x1Fu; SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x2B_ADDR; /*Mask register 0*/ regData = (uint8)partialNwConfig->CanTrcvPnFrameCanIdMask; SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x2C_ADDR; /*Mask register 1 */ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanIdMask >> 8u); SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x2D_ADDR; /*Mask register 2*/ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanIdMask >> 16u); SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x2E_ADDR; /*Mask register 3*/ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanIdMask >> 24u) & 0x1Fu; SPI_Write(regAddr, regData,spiSeq); } else { /* For standard frames update Id and Mask */ regAddr = (uint8)REGISTER_0x29_ADDR; /*ID register 2*/ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanId << 2u); SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x2A_ADDR; /*ID register 3 */ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanId >> 6u) & 0x1Fu; SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x2D_ADDR; /*Mask register 2 */ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanIdMask << 2u); SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x2E_ADDR; /*Mask register 3 */ regData = (uint8)(partialNwConfig->CanTrcvPnFrameCanIdMask >> 6u) & 0x1Fu; SPI_Write(regAddr, regData,spiSeq); } if (cFlag) { idxCnt =0; regAddr = (uint8) REGISTER_0x6F_ADDR; for (loopCnt = 0; loopCnt < partialNwConfig->CanTrcvPnFrameDlc; loopCnt++,regAddr--){ regData = 0xFF; /* Set data mask (unused must be set to zero since default value is 0xFF) */ if ((partialNwConfig->CanTrcvPnFrameDataMaskConfig[idxCnt].CanTrcvPnFrameDataMaskIndex == loopCnt) && (idxCnt < partialNwConfig->CanTrcvPnFrameDataMaskSize)){ regData = partialNwConfig->CanTrcvPnFrameDataMaskConfig[idxCnt].CanTrcvPnFrameDataMask; idxCnt++; } SPI_Write(regAddr, regData,spiSeq); /*Data Mask register */ } } return ret; } #endif /* Set transceiver mode */ Std_ReturnType CanTrcv_Hw_SetupMode(CanTrcv_TrcvModeType mode,const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; regAddr = (uint8)0x3; regData = 0; SPI_Read(regAddr, regData,spiSeq); ret=E_OK; regAddr = (uint8)REGISTER_0x01_ADDR; /*Mode control register*/ switch(mode) { case CANTRCV_TRCVMODE_NORMAL: regData = REGISTER_0x01_MC_NORMAL; break; case CANTRCV_TRCVMODE_SLEEP: regData = REGISTER_0x01_MC_SLEEP; break; case CANTRCV_TRCVMODE_STANDBY: regData = REGISTER_0x01_MC_STANDBY; break; default: ret = E_NOT_OK; break; } if (E_OK == ret){ SPI_Write(regAddr, regData,spiSeq); if (CANTRCV_TRCVMODE_NORMAL == mode) /*Set the CAN to active mode*/ { regAddr = (uint8)0x3; regData = 0; SPI_Read(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x20_ADDR; /* CAN control register */ regData = 0; SPI_Read(regAddr, regData,spiSeq); regData |=REGISTER_20h_CMC_SET; SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x22_ADDR; /*Trcv status register*/ regData = 0; SPI_Read(regAddr, regData,spiSeq); if ((regData&REGISTER_22h_CTS_MASK)==0) { ret = E_NOT_OK; while( 1 ) {}; } } } return ret; } /* Read transceiver mode */ Std_ReturnType CanTrcv_Hw_ReadCurrMode(CanTrcv_TrcvModeType* mode,const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; ret=E_OK; regAddr = (uint8)REGISTER_0x01_ADDR; /* Mode control register */ regData = 0; SPI_Read(regAddr, regData,spiSeq); switch(regData&REGISTER_0x01_MODE_MASK){ case REGISTER_0x01_MC_NORMAL: *mode = CANTRCV_TRCVMODE_NORMAL; break; case REGISTER_0x01_MC_SLEEP: *mode = CANTRCV_TRCVMODE_SLEEP; break; case REGISTER_0x01_MC_STANDBY: *mode = CANTRCV_TRCVMODE_STANDBY; break; default: ret = E_NOT_OK; break; } return ret; } /* Check for power on status */ Std_ReturnType CanTrcv_Hw_ReadPowerOnStatus(boolean * resetSts,const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; ret=E_OK; regAddr = (uint8)REGISTER_0x61_ADDR; /*system event status register */ regData = 0; SPI_Read(regAddr, regData,spiSeq); if ((regData & REGISTER_0x61_PO_SET) == REGISTER_0x61_PO_SET) { *resetSts = TRUE; } else { *resetSts = FALSE; } return ret; } /* Check if PNC is properly configured */ Std_ReturnType CanTrcv_Hw_ReadPNConfigurationStatus(boolean * errConfigSts,const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; ret=E_OK; regAddr = (uint8)REGISTER_0x22_ADDR; /*Trcv status register*/ regData = 0; SPI_Read(regAddr, regData,spiSeq); if ((regData&REGISTER_22h_CPNS_MASK) == REGISTER_22h_CPNS_MASK) { *errConfigSts = FALSE; } else { *errConfigSts = TRUE;/*PN configuration error*/ } return ret; } /* Clear wake up events */ Std_ReturnType CanTrcv_Hw_ClearWakeUpEventStatus(const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; ret=E_OK; regAddr = (uint8)REGISTER_0x63_ADDR; /*Trcv event status register*/ regData = (uint8)(REGISTER_0x63_CW_SET |REGISTER_0x63_PNFDE_SET); SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x61_ADDR; /*system event status register */ regData = (uint8)REGISTER_0x61_PO_SET; SPI_Write(regAddr, regData,spiSeq); regAddr = (uint8)REGISTER_0x64_ADDR; /* Wake pin event status register*/ regData = (uint8)(REGISTER_0x64_WPR_SET|REGISTER_0x64_WPF_SET); SPI_Write(regAddr, regData,spiSeq); return ret; } /* Enable wake up on CAN bus (standard wake up pattern or selective wake up frame ) */ Std_ReturnType CanTrcv_Hw_EnableWakeUpEvent(const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; ret=E_OK; /* Wake up enable */ regAddr = (uint8)REGISTER_0x23_ADDR; /*capture enable register */ regData = (uint8) (REGISTER_0x23_CWE_SET); /* Wakeup detection (CFE is ignored because it is not a fault on the bus but fault at TxD pin due to MCU)*/ SPI_Write(regAddr, regData,spiSeq); #if 0 /*Enable wake up on pin*/ regAddr = (uint8)REGISTER_0x4c_ADDR; /*Wake pin event enable register*/ regData = (uint8) (REGISTER_0x4C_WPRE_SET|REGISTER_0x4C_WPFE_SET ); SPI_Write(regAddr, regData,spiSeq); #endif return ret; } /* Read wake up event status */ Std_ReturnType CanTrcv_Hw_ReadWakeupEventStatus(CanTrcv_TrcvWakeupReasonType* reason,boolean * wakeupDetected,const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; boolean resetSts; ret=E_OK; resetSts = FALSE; ret = CanTrcv_Hw_ReadPowerOnStatus(&resetSts,spiSeq); if ((E_OK == ret) && resetSts) { *reason = CANTRCV_WU_POWER_ON; *wakeupDetected = TRUE; } else { regAddr = (uint8)REGISTER_0x63_ADDR; /*Trcv event status register*/ regData = 0; SPI_Read(regAddr, regData,spiSeq); if (regData & REGISTER_0x63_CW_SET){ *reason = CANTRCV_WU_BY_BUS; *wakeupDetected = TRUE; } if (regData & REGISTER_0x63_PNFDE_SET){ *reason = CANTRCV_WU_BY_SYSERR; *wakeupDetected = TRUE; } #if 0 else { regAddr = (uint8)REGISTER_0x64_ADDR; /* Wake pin event status register*/ regData = 0; SPI_Read(regAddr, regData,spiSeq); if ((regData&(REGISTER_0x64_WPR_SET|REGISTER_0x64_WPF_SET)) != 0) { *reason = CANTRCV_WU_BY_PIN; *wakeupDetected = TRUE; } } #endif } return ret; } /* Check for bus activity */ Std_ReturnType CanTrcv_Hw_ReadSilenceFlag(CanTrcv_TrcvFlagStateType *flag,const CanTrcv_SpiSequenceConfigType *spiSeq) { Std_ReturnType ret; uint8 regData; uint8 regAddr; ret=E_OK; regAddr = (uint8)REGISTER_0x22_ADDR; /*Trcv status register*/ regData = 0; SPI_Read(regAddr, regData,spiSeq); if ((regData&REGISTER_22h_CBSS_MASK)!= 0u)/*REGISTER_22h_CBSS_MASK*/ { *flag = CANTRCV_FLAG_CLEARED; /* Currently silent */ } else { *flag = CANTRCV_FLAG_SET; /* CAN activity on-going */ } return ret; }
2301_81045437/classic-platform
arch/transceivers/tja1145/CanTrcv_TJA1145.c
C
unknown
16,704
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #ifndef CANTRCV_TJA1145_H_ #define CANTRCV_TJA1145_H_ /* CAN transceiver - TJA1145 Register declaration */ #define REGISTER_0x20_ADDR 0x20u #define REGISTER_20h_CPNC_SET 0x10u #define REGISTER_20h_PNCOK_SET 0x20u #define REGISTER_20h_CPNC_CLR 0x00u #define REGISTER_20h_PNCOK_CLR 0x00u #define REGISTER_0x22_ADDR 0x22u #define REGISTER_22h_CPNERR_MASK 0x40u #define REGISTER_22h_CPNS_MASK 0x20u #define REGISTER_22h_COCS_MASK 0x10u #define REGISTER_22h_CTS_MASK 0x80u #define REGISTER_22h_CBSS_MASK 0x08u #define REGISTER_0x23_ADDR 0x23u #define REGISTER_0x23_CWE_SET 0x01u #define REGISTER_0x23_CFE_SET 0x02u #define REGISTER_0x23_CBSE_SET 0x10u #define REGISTER_0x23_CWE_CLR 0x00u #define REGISTER_0x04_ADDR 0x04u #define REGISTER_0x04_SPIFE_SET 0x02u #define REGISTER_0x04_SPIFE_CLR 0x00u #define REGISTER_0x04_OTWE_SET 0x04u #define REGISTER_0x04_OTWE_CLR 0x00u #define REGISTER_0x4c_ADDR 0x4cu #define REGISTER_0x4C_WPFE_SET 0x01u #define REGISTER_0x4C_WPRE_SET 0x02u #define REGISTER_0x61_ADDR 0x61u #define REGISTER_0x63_ADDR 0x63u #define REGISTER_0x64_ADDR 0x64u #define REGISTER_0x61_PO_SET 0x10u #define REGISTER_0x61_OTW_SET 0x40u #define REGISTER_0x61_SPIF_SET 0x20u #define REGISTER_0x63_PNFDE_SET 0x20u #define REGISTER_0x63_CW_SET 0x01u #define REGISTER_0x63_CBS_SET 0x10u #define REGISTER_0x64_WPR_SET 0x02u #define REGISTER_0x64_WPF_SET 0x01u #define REGISTER_0x03_ADDR 0x03u #define REGISTER_0x22_ADDR 0x22u #define REGISTER_0x22_CBSS_SET 0x08u #define REGISTER_0x22_CFS_SET 0x01u #define REGISTER_0x4B_ADDR 0x4Bu #define REGISTER_0x26_ADDR 0x26u #define REGISTER_0x26_CDR_50 0x00u #define REGISTER_0x26_CDR_100 0x01u #define REGISTER_0x26_CDR_125 0x02u #define REGISTER_0x26_CDR_250 0x03u #define REGISTER_0x26_CDR_500 0x05u #define REGISTER_0x26_CDR_1000 0x07u #define REGISTER_0x01_ADDR 0x01u #define REGISTER_0x01_MC_NORMAL 0x07u /* System control registers */ #define REGISTER_0x01_MC_STANDBY 0x04u /* System control registers */ #define REGISTER_0x01_MC_SLEEP 0x01u /* System control registers */ #define REGISTER_0x01_MODE_MASK 0x07u #define REGISTER_0x60_ADDR 0x60u #define REGISTER_0x01_SYSE_SET 0x01u #define REGISTER_0x01_TRXE_SET 0x04u #define REGISTER_0x01_WPE_SET 0x08u #define REGISTER_0x2F_ADDR 0x2Fu /* Frame control register (address 2Fh) */ #define REGISTER_0x2F_PNDM 0x40u /* Frame control register (address 2Fh) */ #define REGISTER_0x2F_IDE_STD 0x00u /* Frame control register (address 2Fh) */ #define REGISTER_0x2F_IDE_EXT 0x80u /* Frame control register (address 2Fh) */ #define REGISTER_0x27_ADDR 0x27u /* ID register 0 (address 27h) */ #define REGISTER_0x28_ADDR 0x28u /* ID register 1 (address 28h) */ #define REGISTER_0x29_ADDR 0x29u /* ID register 1 (address 29h) */ #define REGISTER_0x2A_ADDR 0x2Au /* ID register 1 (address 2Ah) */ #define REGISTER_0x2B_ADDR 0x2Bu /* Mask register 0 (address 2Bh) */ #define REGISTER_0x2C_ADDR 0x2Cu /* Mask register 1 (address 2Ch) */ #define REGISTER_0x2D_ADDR 0x2Du /* Mask register 2 (address 2Dh) */ #define REGISTER_0x2E_ADDR 0x2Eu /* Mask register 3 (address 2Eh) */ #define REGISTER_20h_CMC_SET 0x01u #define REGISTER_0x68_ADDR 0x68u /* Data mask registers (addresses 68h to 6Fh) for byte 0 */ #define REGISTER_0x69_ADDR 0x69u /* Data mask registers (addresses 68h to 6Fh) for byte 1 */ #define REGISTER_0x6A_ADDR 0x6Au /* Data mask registers (addresses 68h to 6Fh) for byte 2 */ #define REGISTER_0x6B_ADDR 0x6Bu /* Data mask registers (addresses 68h to 6Fh) for byte 3 */ #define REGISTER_0x6C_ADDR 0x6Cu /* Data mask registers (addresses 68h to 6Fh) for byte 4 */ #define REGISTER_0x6D_ADDR 0x6Du /* Data mask registers (addresses 68h to 6Fh) for byte 5 */ #define REGISTER_0x6E_ADDR 0x6Eu /* Data mask registers (addresses 68h to 6Fh) for byte 6 */ #define REGISTER_0x6F_ADDR 0x6Fu /* Data mask registers (addresses 68h to 6Fh) for byte 7 */ #endif /* CANTRCV_TJA1145_H_ */
2301_81045437/classic-platform
arch/transceivers/tja1145/CanTrcv_TJA1145.h
C
unknown
5,237
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #ifndef CALIBRATION_SETTINGS_H_ #define CALIBRATION_SETTINGS_H_ /* These defines should be overridden in a project specific file with the same name if calibration data is a wanted feature */ #undef CALIBRATION_INITIALIZED_RAM #undef CALIBRATION_ENABLED #undef CALIBRATION_FLS_START #endif /* CALIBRATION_SETTINGS_H_ */
2301_81045437/classic-platform
base/Calibration_Settings.h
C
unknown
1,082
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ /* THIS IS A TEMPLATE FILE * This file should be generated by the make system. A hash of pre compiled data (e.g. * the header files for the modules that supports post build) shall be calculated * produce the define below with that hash. This file is included both by the * EcuM configuration and the Postbuild configuration. The hashes in EcuM conf. and * post build conf. is compared in EcuM and the node will only start if they match. */ #define PRE_COMPILED_DATA_HASH_LOW (0x5555AAAA) #define PRE_COMPILED_DATA_HASH_HIGH (0x5555AAAA)
2301_81045437/classic-platform
base/PreCompiledDataHash.h
C
unknown
1,305
# base inc-y += $(ROOTDIR)/base/compiler inc-y += $(ROOTDIR)/base
2301_81045437/classic-platform
base/base.mod.mk
Makefile
unknown
72
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ /* See CopmpilerAbstraction.pdf */ #ifndef COMPILER_H #define COMPILER_H /* REQ:COMPILER040,049,051 */ #define AUTOMATIC #define STATIC static #define NULL_PTR ((void *)0) #include "Compiler_Arc.h" #define INLINE __inline__ /* REQ:COMPILER005 */ #define FUNC(rettype,memclass) rettype #define P2VAR(ptrtype, memclass, ptrclass) ptrtype * #define P2CONST(ptrtype, memclass, ptrclass) const ptrtype * #define CONSTP2VAR(ptrtype,memclass,ptrclass) ptrtype * const #define CONSTP2CONST(ptrtype, memclass, ptrclass) const ptrtype * const #define P2FUNC(rettype,ptrclass,fctname) rettype (*fctname) #define CONST(consttype,memclass) const consttype #define FUNC_P2CONST(rettype, ptrclass, memclass) const ptrclass rettype * memclass #define VAR(vartype,memclass) memclass vartype #include "Compiler_Cfg.h" #endif /* COMPILER_H */
2301_81045437/classic-platform
base/compiler/Compiler.h
C
unknown
1,632
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ /* See CopmpilerAbstraction.pdf */ #ifndef COMPILER_ARC_H #define COMPILER_ARC_H /* REQ:COMPILER040,049,051 */ #if defined(__GNUC__) #define CC_EXTENSION __extension__ #elif defined(__CWCC__) #define CC_EXTENSION #pragma read_only_switch_tables on #elif defined(__DCC__) || defined(__ghs__) #define CC_EXTENSION #endif #if defined(__ghs__) #define typeof __typeof__ #endif #if defined(__ARMCC_VERSION) #define asm __asm #endif #if defined(__GNUC__) || defined(__CWCC__) || defined(__DCC__) || defined(__ghs__) #define __weak __attribute__ ((weak)) #elif defined(__IAR_SYSTEMS_ICC__) #define __weak __weak #else #define __weak #endif #if defined(__GNUC__) || defined(__ghs__) || defined(__CWCC__) || defined(__DCC__) || defined(__ARMCC_VERSION) #define __balign(x) __attribute__ ((aligned (x))) #elif defined(__IAR_SYSTEMS_ICC__) #define Pragma(x) _Pragma(#x) #define __balign(x) Pragma(data_alignment=(x)) #elif defined(_WIN32) #define __balign(x) __declspec ((align(x))) #else #error Compiler not defined. #endif #define SECTION_BALIGN(x) __balign(x) #define DECLARE_WEAK __attribute__ ((weak)) #if defined(__IAR_SYSTEMS_ICC__) #define LOCAL_INLINE Pragma(inline) #else #define LOCAL_INLINE static __inline__ #endif #if defined(CFG_BULLSEYE) #define __CODE_COVERAGE_ON__ _Pragma("BullseyeCoverage restore") #define __CODE_COVERAGE_OFF__ _Pragma("BullseyeCoverage save off") #define __CODE_COVERAGE_IGNORE__ _Pragma("BullseyeCoverage ignore") #define __CODE_COVERAGE_IGNORE2__ _Pragma("BullseyeCoverage ignore:2") #define __CODE_COVERAGE_IGNORE3__ _Pragma("BullseyeCoverage ignore:3") #pragma BullseyeCoverage ignore:3 #else #define __CODE_COVERAGE_ON__ #define __CODE_COVERAGE_OFF__ #define __CODE_COVERAGE_IGNORE__ #define __CODE_COVERAGE_IGNORE1__ #define __CODE_COVERAGE_IGNORE2__ #define __CODE_COVERAGE_IGNORE3__ #endif #endif /* COMPILER_H */
2301_81045437/classic-platform
base/compiler/Compiler_Arc.h
C
unknown
2,754
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #ifndef COMPILER_CFG_H #define COMPILER_CFG_H /* NOTE: Copy this file to your local config-folder * and add your code here */ /* See CompilerAbstraction.pdf */ /* REQ:COMPILER040 */ #endif /* COMPILER_CFG_H */
2301_81045437/classic-platform
base/compiler/Compiler_Cfg.h
C
unknown
989
_BOARD_COMMON_MK:=y # Include guard for backwards compatability ifndef NOKERNEL obj-$(CFG_PPC) += crt0.o obj-$(CFG_RH850) += crt0.o # mpc5xxx.h headers inc-$(CFG_PPC) += $(ROOTDIR)/mcal/arch/$(ARCH) # Coverage obj-$(CFG_BULLSEYE) += Bullseye_Coverage_Hooks.o inc-last-$(CFG_BULLSEYE) += $(COV_BULLSEYE_PATH) ##PPC## inc-$(CFG_PPC) += $(ROOTDIR)/$(mcal/arch/$(ARCH_MCU)) ##TC26X## vpath-$(CFG_TC26X) += $(ROOTDIR)/mcal/arch/tcxxx/src vpath-$(CFG_TC26X) += $(ROOTDIR)/mcal/arch/tcxxx/src/integration obj-$(CFG_TC26X) += IfxCpu_CStart$(SELECT_CORE).o obj-$(CFG_TC26X) += IfxCpu_cfg.o obj-$(CFG_TC26X) += IfxCpu.o obj-$(CFG_TC26X) += IfxScuWdt.o obj-$(CFG_TC26X) += CompilerGnuc.o obj-$(CFG_TC26X) += Ifx_preInitHook.o IFXTC26X_BASE_FRAMEWORK = $(ROOTDIR)/mcal/arch/tcxxx/src/contrib/ap32201_TC2xx_Source/0_Src inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/4_McHal/Tricore/_Reg inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/4_McHal/Tricore/_Impl inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/4_McHal/Tricore/Smu inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/0_AppSw/Config/Common inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/0_AppSw/Config/Tricore/Start inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/4_McHal/Tricore/Scu/Std inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/4_McHal/Tricore/Cpu/Std inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/4_McHal/Tricore/Mtu inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/4_McHal/Tricore inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/1_SrvSw vpath-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/4_McHal/Tricore/Cpu/CStart vpath-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/4_McHal/Tricore/Scu/Std vpath-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/1_SrvSw/Tricore/Compilers inc-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/0_AppSw/Tricore/DemoApp/Start vpath-$(CFG_TC26X) += $(IFXTC26X_BASE_FRAMEWORK)/0_AppSw/Tricore/DemoApp/Start ##TC29X## vpath-$(CFG_TC29X) += $(ROOTDIR)/mcal/arch/tcxxx/src vpath-$(CFG_TC29X) += $(ROOTDIR)/mcal/arch/tcxxx/src/integration vpath-$(CFG_TC29X) += $(ROOTDIR)/system/Os/osal/tricore/aurix/kernel obj-$(CFG_TC29X) += IfxCpu_CStart$(SELECT_CORE).o obj-$(CFG_TC29X) += IfxCpu_cfg.o obj-$(CFG_TC29X) += IfxCpu.o obj-$(CFG_TC29X) += IfxScuWdt.o ifeq ($(CFG_TC212),y) # Don't add for this one ifndef MCAL_PATH obj-y += IfxScuCcu.o endif else obj-$(CFG_TC29X) += IfxScuCcu.o endif obj-$(CFG_TC29X) += CompilerGnuc.o obj-$(CFG_TC29X) += Ifx_preInitHook.o IFXTC29X_BASE_FRAMEWORK = $(ROOTDIR)/mcal/arch/tcxxx/src/contrib/ap32201_TC2xx_Source/0_Src inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/4_McHal/Tricore/_Reg inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/4_McHal/Tricore/_Impl inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/4_McHal/Tricore/Smu inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/0_AppSw/Config/Common inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/0_AppSw/Config/Tricore/Start inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/4_McHal/Tricore/Scu/Std inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/4_McHal/Tricore/Cpu/Std inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/4_McHal/Tricore/Mtu inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/4_McHal/Tricore inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/1_SrvSw vpath-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/4_McHal/Tricore/Cpu/CStart vpath-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/4_McHal/Tricore/Scu/Std vpath-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/1_SrvSw/Tricore/Compilers inc-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/0_AppSw/Tricore/DemoApp/Start vpath-$(CFG_TC29X) += $(IFXTC29X_BASE_FRAMEWORK)/0_AppSw/Tricore/DemoApp/Start ##TC39X## obj-$(CFG_TC39X) += Ifx_Ssw_Tc$(SELECT_CORE).o obj-$(CFG_TC39X) += IfxCpu_cfg_Tc3xx.o obj-$(CFG_TC39X) += IfxCpu_Tc3xx.o obj-$(CFG_TC39X) += Ifx_Cfg_SswCallouts.o obj-$(CFG_TC39X) += Ifx_Cfg_Ssw.o obj-$(CFG_TC39X) += Ifx_Ssw_Infra.o obj-$(CFG_TC39X) += IfxScuWdt.o obj-$(CFG_TC39X) += IfxScuCcu.o obj-$(CFG_TC39X) += CompilerGnuc.o obj-$(CFG_TC39X) += IfxPmsEvr.o IFXTC399_BASE_FRAMEWORK = $(ROOTDIR)/system/Os/osal/tricore/aurix/TC39x_Source/IFX_base_famework/BaseFramework_TC39xA/0_Src inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/AppSw/Config/Common inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/SrvSw/CpuGeneric inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/Sfr_39A inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/Sfr_39A/_Reg inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/StartUp_39A/Tricore inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/_Impl inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/Scu/Std inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/Pms/Std inc-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/Cpu/Std vpath-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/AppSw/Tricore/Cfg_Ssw vpath-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/StartUp_39A/Tricore vpath-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/Compilers/Tricore vpath-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/_Impl vpath-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/Scu/Std vpath-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/Pms/Std vpath-$(CFG_TC39X) += $(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/Cpu/Std ## Excluding header from Lint ## ifeq ($(ARCH_FAM),tricore) LINT_EXCLUDE_PATHS +=$(IFXTC399_BASE_FRAMEWORK)/AppSw/Tricore/Cfg_Ssw LINT_EXCLUDE_PATHS +=$(IFXTC399_BASE_FRAMEWORK)/BaseSw/StartUp_39A/Tricore LINT_EXCLUDE_PATHS +=$(IFXTC399_BASE_FRAMEWORK)/BaseSw/Compilers/Tricore LINT_EXCLUDE_PATHS +=$(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/_Impl LINT_EXCLUDE_PATHS +=$(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/Scu/Std LINT_EXCLUDE_PATHS +=$(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/Pms/Std LINT_EXCLUDE_PATHS +=$(IFXTC399_BASE_FRAMEWORK)/BaseSw/iLLD_39A/Tricore/Cpu/Std endif else obj-$(CFG_STARTUP) += crt0.o endif obj-$(CFG_HC1X)-$(COMPILER) += crt0_$(COMPILER).o ifneq ($(filter-out arm generic gnulinux,$(ARCH_FAM)),) obj-y+=init.o endif obj-$(CFG_ZYNQ)+=init.o obj-$(CFG_TMS570) += init.o obj-$(CFG_TRAVEO) += init.o ##ZYNQ## inc-$(CFG_ZYNQ) += $(ROOTDIR)/mcal/arch/zynq/src vpath-$(CFG_ZYNQ) += $(ROOTDIR)/mcal/arch/zynq/src vpath-$(CFG_ZYNQ) += $(ROOTDIR)/mcal/arch/zynq/src/integration ##STM32## vpath-$(CFG_STM32F1X) += $(ROOTDIR)/mcal/arch/$(ARCH_MCU)/src/contrib/STM32F10x_StdPeriph_Driver/src vpath-$(CFG_STM32F1X) += $(ROOTDIR)/mcal/arch/$(ARCH_MCU)/src/contrib/STM32_ETH_Driver/src vpath-$(CFG_STM32F1X) += $(ROOTDIR)/mcal/arch/$(ARCH_MCU)/src inc-$(CFG_STM32F1X) += $(ROOTDIR)/mcal/arch/$(ARCH_MCU)/src/contrib/STM32F10x_StdPeriph_Driver/inc inc-$(CFG_STM32F1X) += $(ROOTDIR)/mcal/arch/$(ARCH_MCU)/src/contrib/STM32_ETH_Driver/inc obj-$(CFG_STM32F1X) += startup_cmx.o obj-$(CFG_STM32F3X) += startup_cmx.o obj-$(CFG_S32K144) += startup_cmx.o obj-$(CFG_S32K148) += startup_cmx.o obj-$(CFG_JACINTO) += startup_jacinto.o vpath-$(if $(CFG_STM32F1X)$(CFG_STM32F3X)$(CFG_S32K144)$(CFG_JACINTO),y) += $(ROOTDIR)/system/Os/osal/arm/armv7_m #stm32 lib files needed by drivers obj-$(CFG_STM32F1X) += stm32f10x_rcc.o obj-$(CFG_STM32F1X)-$(USE_CAN) += stm32f10x_can.o obj-$(CFG_STM32F1X)-$(USE_PORT) += stm32f10x_gpio.o obj-$(CFG_STM32F1X)-$(USE_ADC) += stm32f10x_adc.o obj-$(CFG_STM32F1X)-$(USE_ADC) += stm32f10x_dma.o obj-$(CFG_STM32F1X)-$(USE_FLS) += stm32f10x_flash.o obj-$(CFG_STM32F1X)-$(USE_PWM) += stm32f10x_tim.o obj-$(CFG_STM32F1X)-$(USE_LWIP) += stm32_eth.o obj-$(USE_TTY_TMS570_KEIL) += GLCD.o obj-$(USE_TTY_TMS570_KEIL) += emif.o ##JACINTO## inc-$(CFG_JACINTO) += $(ROOTDIR)/mcal/arch/jacinto/src vpath-$(CFG_JACINTO) += $(ROOTDIR)/mcal/arch/jacinto/src ##TMS570## # Cortex R4 inc-$(CFG_TMS570) += $(ROOTDIR)/mcal/arch/tms570/src vpath-$(CFG_TMS570) += $(ROOTDIR)/mcal/arch/tms570/src/integration vpath-$(CFG_TMS570) += $(ROOTDIR)/mcal/arch/tms570/src obj-$(CFG_ARMV7_AR) += startup_armv7-ar.o vpath-$(CFG_ARMV7_AR) += $(ROOTDIR)/system/Os/osal/arm/$(ARCH) ifeq ($(COMPILER),gcc) obj-$(CFG_ARMV7_AR) += crtin.o endif # OS object files. # (checking if already included for compatability) ifeq ($(filter Os_Cfg.o,$(obj-y)),) obj-$(USE_KERNEL) += Os_Cfg.o endif ifneq ($(CFG_SYSTEM_ASSERT),y) obj-y += arc_assert.o endif ifeq ($(CFG_MCAL_EXTERNAL),) ifeq ($(ARCH_MCU),) inc-y += $(ROOTDIR)/$(ARCH_DRIVER_PATH-y)/drivers vpath-y += $(ROOTDIR)/$(ARCH_DRIVER_PATH-y)/drivers else inc-y += $(ROOTDIR)/$(ARCH_DRIVER_PATH-y)/drivers_$(ARCH_MCU) vpath-y += $(ROOTDIR)/$(ARCH_DRIVER_PATH-y)/drivers_$(ARCH_MCU) endif endif #EcuM ECUM-MOD-MK?=$(ROOTDIR)/system/EcuM/EcuM.mod.mk include $(ECUM-MOD-MK) #Rtm RTM-MOD-MK?=$(ROOTDIR)/safety_security/Sm/Rtm/Rtm.mod.mk -include $(RTM-MOD-MK) #Smal SMAL-MOD-MK?=$(ROOTDIR)/safety_security/Sm/Smal/Smal.mod.mk -include $(SMAL-MOD-MK) #SecOC SECOC-MOD-MK?=$(ROOTDIR)/communication/SecOC/SecOC.mod.mk include $(SECOC-MOD-MK) #E2E E2E-MOD-MK?=$(ROOTDIR)/safety_security/SafeLib/E2E/E2E.mod.mk include $(E2E-MOD-MK) #HTMSS HTMSS-MOD-MK?=$(ROOTDIR)/safety_security/Sm/Htmss/Htmss.mod.mk -include $(HTMSS-MOD-MK) #CPL CPL-MOD-MK?=$(ROOTDIR)/system/Cpl/Cpl.mod.mk include $(CPL-MOD-MK) #CAL CAL-MOD-MK?=$(ROOTDIR)/system/Cal/Cal.mod.mk include $(CAL-MOD-MK) #Crc CRC-MOD-MK?=$(ROOTDIR)/safety_security/SafeLib/Crc/Crc.mod.mk include $(CRC-MOD-MK) #BswM BSWM-MOD-MK?=$(ROOTDIR)/system/BswM/BswM.mod.mk include $(BSWM-MOD-MK) #Ea EA-MOD-MK?=$(ROOTDIR)/memory/Ea/Ea.mod.mk include $(EA-MOD-MK) # Gpt GPT-MOD-MK?=$(ROOTDIR)/mcal/Gpt/gpt.mod.mk include $(GPT-MOD-MK) # Dma DMA-MOD-MK?=$(ROOTDIR)/drivers/dma.mod.mk include $(DMA-MOD-MK) #CDD_LinSlv CDD_LINSLV-MOD-MK?=$(ROOTDIR)/cdd/LinSlv/cdd_linslv.mod.mk include $(CDD_LINSLV-MOD-MK) #CDD_PduR ifeq ($(USE_CDDPDUR),y) include $(ROOTDIR)/cdd/PduR/mod.mk endif #DLT UartCom ifeq ($(USE_DLTUARTCOM),y) include $(ROOTDIR)/cdd/DltUartCom/mod.mk endif # CDD_EthTrcv ifeq ($(USE_CDDETHTRCV),y) include $(ROOTDIR)/cdd/EthTrcv/mod.mk endif # Mcu MCU-MOD-MK?=$(ROOTDIR)/mcal/Mcu/mcu.mod.mk include $(MCU-MOD-MK) # Port PORT-MOD-MK?=$(ROOTDIR)/mcal/Port/port.mod.mk include $(PORT-MOD-MK) # CPU specific # kernel KERNEL-MOD-MK?=$(ROOTDIR)/drivers/kernel.mod.mk include $(KERNEL-MOD-MK) vpath-$(CFG_PPC) += $(ROOTDIR)/$(ARCH_KERNEL_PATH-y)/integration vpath-$(CFG_ARM_CM3) += $(ROOTDIR)/$(ARCH_KERNEL_PATH-y)/integration vpath-$(CFG_ARM_CM4) += $(ROOTDIR)/$(ARCH_KERNEL_PATH-y)/integration vpath-$(CFG_TC2XX) += $(ROOTDIR)/$(ARCH_KERNEL_PATH-y)/integration obj-$(CFG_MCU_ARC_LP) += Mcu_Arc_Cfg.o obj-$(CFG_PPC) += Cpu.o obj-$(CFG_MPC5516) += mm.o vpath-$(CFG_PPC) += $(ROOTDIR)/$(ARCH_KERNEL_PATH-y)/mm inc-$(CFG_PPC) += $(ROOTDIR)/$(ARCH_KERNEL_PATH-y)/mm # Flash FLS-MOD-MK?=$(ROOTDIR)/drivers/Fls/fls.mod.mk include $(FLS-MOD-MK) #TI F021 flash programming API ifdef CFG_ARM_CR4 inc-$(CFG_TMS570) += $(ROOTDIR)/mcal/Fls/src/contrib endif ifdef CFG_BRD_TMDX570_LC43HDK inc-$(CFG_TMS570) += $(ROOTDIR)/mcal/Fls/src/contrib endif obj-$(CFG_ARM_CR5) += HL_sys_core.o obj-$(CFG_ARM_CR5) += HL_sys_mpu.o vpath-$(CFG_ARM_CR5) += $(ROOTDIR)/mcal/Fls/src/contrib/HL_sys # Bring in the freescale driver source inc-$(CFG_MPC55XX) += $(ROOTDIR)/$(ARCH_DRIVER_PATH-y)/delivery/mpc5500_h7f/include # Eth, Ethernet ETH-MOD-MK?=$(ROOTDIR)/mcal/Eth/eth.mod.mk include $(ETH-MOD-MK) # Eth SM ETHSM-MOD-MK?=$(ROOTDIR)/communication/EthSM/EthSM.mod.mk include $(ETHSM-MOD-MK) # EthIF ETHIF-MOD-MK?=$(ROOTDIR)/communication/EthIf/EthIf.mod.mk include $(ETHIF-MOD-MK) # EthTSyn ETHTSYN-MOD-MK?=$(ROOTDIR)/communication/EthTSyn/EthTSyn.mod.mk include $(ETHTSYN-MOD-MK) # Icu ICU-MOD-MK?=$(ROOTDIR)/drivers/icu.mod.mk include $(ICU-MOD-MK) # Fr, Flexray FR-MOD-MK?=$(ROOTDIR)/drivers/Fr/fr.mod.mk include $(FR-MOD-MK) # FrIf FRIF-MOD-MK?=$(ROOTDIR)/communication/FrIf/FrIf.mod.mk include $(FRIF-MOD-MK) # FrSM FRSM-MOD-MK?=$(ROOTDIR)/communication/FrSM/FrSM.mod.mk include $(FRSM-MOD-MK) # Can CAN-MOD-MK?=$(ROOTDIR)/mcal/Can/Can.mod.mk include $(CAN-MOD-MK) CANTRCV-MOD-MK?=$(ROOTDIR)/drivers/CanTrcv/cantrcv.mod.mk include $(CANTRCV-MOD-MK) # CanIf CANIF-MOD-MK?=$(ROOTDIR)/communication/CanIf/CanIf.mod.mk include $(CANIF-MOD-MK) # CanTp CANTP-MOD-MK?=$(ROOTDIR)/communication/CanTp/CanTp.mod.mk include $(CANTP-MOD-MK) #Dio DIO-MOD-MK?=$(ROOTDIR)/mcal/Dio/dio.mod.mk include $(DIO-MOD-MK) #Adc ADC-MOD-MK?=$(ROOTDIR)/mcal/Adc/Adc.mod.mk include $(ADC-MOD-MK) #FrTp FRTP-MOD-MK?=$(ROOTDIR)/communication/FrTp/FrTp.mod.mk include $(FRTP-MOD-MK) # SchM, always find the incluSchMde files. SCHM-MOD-MK?=$(ROOTDIR)/system/SchM/SchM.mod.mk include $(SCHM-MOD-MK) # StbM STBM-MOD-MK?=$(ROOTDIR)/system/StbM/StbM.mod.mk include $(STBM-MOD-MK) # J1939Tp J1939TP-MOD-MK?=$(ROOTDIR)/communication/J1939Tp/J1939Tp.mod.mk include $(J1939TP-MOD-MK) # Include the kernel ifneq ($(USE_KERNEL),) include $(ROOTDIR)/system/Os/rtos/makefile endif # Spi SPI-MOD-MK?=$(ROOTDIR)/mcal/Spi/spi.mod.mk include $(SPI-MOD-MK) # NvM NVM-MOD-MK?=$(ROOTDIR)/memory/NvM/NvM.mod.mk include $(NVM-MOD-MK) # MemIf MEMIF-MOD-MK?=$(ROOTDIR)/memory/MemIf/MemIf.mod.mk include $(MEMIF-MOD-MK) # Fee FEE-MOD-MK?=$(ROOTDIR)/memory/Fee/Fee.mod.mk include $(FEE-MOD-MK) #Eep EEP-MOD-MK?=$(ROOTDIR)/drivers/Eep/Eep.mod.mk include $(EEP-MOD-MK) #Fls ext obj-$(USE_FLS_SST25XX) += Fls_SST25xx.o obj-$(USE_FLS_SST25XX) += Fls_SST25xx_Cfg.o #Wdg WDG-MOD-MK?=$(ROOTDIR)/mcal/Wdg/Wdg.mod.mk include $(WDG-MOD-MK) #WdgIf WDGIF-MOD-MK?=$(ROOTDIR)/safety_security/WdgIf/WdgIf.mod.mk include $(WDGIF-MOD-MK) #WdgM WDGM-MOD-MK?=$(ROOTDIR)/safety_security/WdgM/WdgM.mod.mk include $(WDGM-MOD-MK) #Pwm PWM-MOD-MK?=$(ROOTDIR)/mcal/Pwm/Pwm.mod.mk include $(PWM-MOD-MK) # Ocu OCU-MOD-MK?=$(ROOTDIR)/drivers/ocu.mod.mk include $(OCU-MOD-MK) #DET DET-MOD-MK?=$(ROOTDIR)/diagnostic/Det/Det.mod.mk include $(DET-MOD-MK) # Dlt DLT-MOD-MK?=$(ROOTDIR)/diagnostic/Dlt/Dlt.mod.mk include $(DLT-MOD-MK) # Lin LIN-MOD-MK?=$(ROOTDIR)/drivers/lin.mod.mk include $(LIN-MOD-MK) # LinIf LINIF-MOD-MK?=$(ROOTDIR)/communication/LinIf/LinIf.mod.mk include $(LINIF-MOD-MK) # LinTp LINTP-MOD-MK?=$(ROOTDIR)/communication/LinIf/LinTp.mod.mk include $(LINTP-MOD-MK) # LinSm LINSM-MOD-MK?=$(ROOTDIR)/communication/LinSM/LinSM.mod.mk include $(LINSM-MOD-MK) # ComM COMM-MOD-MK?=$(ROOTDIR)/communication/ComM/ComM.mod.mk include $(COMM-MOD-MK) # Nm NM-MOD-MK?=$(ROOTDIR)/communication/Nm/Nm.mod.mk include $(NM-MOD-MK) # CanNm CANNM-MOD-MK?=$(ROOTDIR)/communication/CanNm/CanNm.mod.mk include $(CANNM-MOD-MK) # CanSm CANSM-MOD-MK?=$(ROOTDIR)/communication/CanSM/CanSM.mod.mk include $(CANSM-MOD-MK) #FrNm FRNM-MOD-MK?=$(ROOTDIR)/communication/FrNm/FrNm.mod.mk include $(FRNM-MOD-MK) #FrNm OSEKNM-MOD-MK?=$(ROOTDIR)/communication/OsekNm/OsekNm.mod.mk include $(OSEKNM-MOD-MK) # Com COM-MOD-MK?=$(ROOTDIR)/communication/Com/Com.mod.mk include $(COM-MOD-MK) # PduR PDUR-MOD-MK?=$(ROOTDIR)/communication/PduR/PduR.mod.mk include $(PDUR-MOD-MK) # IpduM IPDUM-MOD-MK?=$(ROOTDIR)/communication/IpduM/IpduM.mod.mk include $(IPDUM-MOD-MK) # DoIP DOIP-MOD-MK?=$(ROOTDIR)/communication/DoIP/DoIP.mod.mk include $(DOIP-MOD-MK) # IO Hardware Abstraction IOHWAB-MOD-MK?=$(ROOTDIR)/Peripherals/IoHwAb/IoHwAb.mod.mk include $(IOHWAB-MOD-MK) # SAFE IO Hardware Abstraction SAFE-IOHWAB-MOD-MK?=$(ROOTDIR)/Peripherals/SafeIoHwAb/SafeIoHwAb.mod.mk -include $(SAFE-IOHWAB-MOD-MK) #Dem DEM-MOD-MK?=$(ROOTDIR)/diagnostic/Dem/Dem.mod.mk include $(DEM-MOD-MK) #Dcm DCM-MOD-MK?=$(ROOTDIR)/diagnostic/Dcm/Dcm.mod.mk include $(DCM-MOD-MK) #Fim FIM-MOD-MK?=$(ROOTDIR)/diagnostic/FiM/FiM.mod.mk include $(FIM-MOD-MK) #RamTst RAMTST-MOD-MK?=$(ROOTDIR)/memory/RamTst/RamTst.mod.mk include $(RAMTST-MOD-MK) #LinuxOs LINUXOS-MOD-MK?=$(ROOTDIR)/system/LinuxOs/LinuxOs.mod.mk include $(LINUXOS-MOD-MK) # Common stuff, if speciied VPATH += $(ROOTDIR)/common # SD SD-MOD-MK?=$(ROOTDIR)/communication/SD/SD.mod.mk include $(SD-MOD-MK) # SoAd SOAD-MOD-MK?=$(ROOTDIR)/communication/SoAd/SoAd.mod.mk include $(SOAD-MOD-MK) # UdpNm UDPNM-MOD-MK?=$(ROOTDIR)/communication/UdpNm/UdpNm.mod.mk include $(UDPNM-MOD-MK) # Xcp XCP-MOD-MK?=$(ROOTDIR)/communication/Xcp/Xcp.mod.mk include $(XCP-MOD-MK) #LdCom LDCOM-MOD-MK?=$(ROOTDIR)/communication/LdCom/LdCom.mod.mk include $(LDCOM-MOD-MK) #TCPIP TCPIP-MOD-MK?=$(ROOTDIR)/communication/TcpIp/tcpip.mod.mk -include $(TCPIP-MOD-MK) #LWIP LWIP-MOD-MK?=$(ROOTDIR)/communication/lwip.mod.mk include $(LWIP-MOD-MK) obj-$(USE_RAMLOG) += ramlog.o #TCF TCF-MOD-MK?=$(ROOTDIR)/common/tcf/tcf.mod.mk include $(TCF-MOD-MK) #Queue QUEUE-MOD-MK?=$(ROOTDIR)/datastructures/Queue/Queue.mod.mk include $(QUEUE-MOD-MK) #Safety Queue SAFE-QUEUE-MOD-MK?=$(ROOTDIR)/datastructures/Safety_Queue/SafeQ.mod.mk include $(SAFE-QUEUE-MOD-MK) ifeq ($(CFG_MCAL_EXTERNAL),y) ifeq ($(ARCH_MCU),) inc-y += $(ROOTDIR)/$(ARCH_DRIVER_PATH-y)/drivers vpath-y += $(ROOTDIR)/$(ARCH_DRIVER_PATH-y)/drivers else inc-y += $(ROOTDIR)/$(ARCH_DRIVER_PATH-y)/drivers_$(ARCH_MCU) vpath-y += $(ROOTDIR)/$(ARCH_DRIVER_PATH-y)/drivers_$(ARCH_MCU) endif endif #SLEEP obj-$(USE_SLEEP) += sleep.o # Circular Buffer (always) obj-y += cirq_buffer.o obj-y += version.o # IPC for JAC6 IPC-MK?=$(ROOTDIR)/mcal/arch/jacinto/ipc.mk include $(IPC-MK) #I2C for mpc ifeq ($(USE_I2C_MPC),y) I2C_MPC-MOD-MK?=$(ROOTDIR)/mcal/arch/mpc5xxx/src/contrib/i2c/i2c_MPC.mod.mk include $(I2C_MPC-MOD-MK) endif ifeq ($(CFG_TIMER),y) obj-$(CFG_TIMER_TB)-$(CFG_PPC)+=timer_tb.o obj-$(CFG_TIMER_RTC)-$(CFG_PPC)+=timer_rtc.o obj-$(CFG_TIMER_STM)-$(CFG_PPC)+=timer_stm.o obj-$(CFG_TIMER_DWT)-$(CFG_ARM)+=timer_dwt.o obj-$(CFG_TIMER_GLOBAL)-$(CFG_ZYNQ)+=timer_global.o obj-$(CFG_TIMER_RTI)-$(CFG_TMS570)+=timer_rti.o obj-$(CFG_TIMER_OSTM)+=timer_ostm.o obj-$(CFG_TIMER_AURIX) += timer_aurix.o obj-$(CFG_TIMER_TIMERS)-$(CFG_JACINTO) += timer.o obj-$(CFG_TIMER_SCTM)-$(CFG_JACINTO) += timer_sctm.o inc-y += $(ROOTDIR)/mcal/arch/$(ARCH)/src vpath-y += $(ROOTDIR)/mcal/arch/$(ARCH)/src endif # Shell obj-$(CFG_SHELL)+=shell.o # Logger over shell (old) obj-$(CFG_LOGGER) += logger.o # New logger. obj-$(CFG_LOG) += log.o SELECT_CLIB?=CLIB_IAR # Performance stuff obj-$(CFG_OS_PERF)+=perf.o def-$(CFG_OS_PERF)+=CFG_OS_ISR_HOOKS # T1 integration stuff ifeq ($(CFG_T1_ENABLE),y) def-y += T1_ENABLE=1 #needed for T1 code def-y += CFG_OS_ISR_HOOKS ifeq ($(CFG_T1_DISABLE_FLEX),y) def-y += T1_DISABLE_T1_FLEX=1 endif T1_PATH?=$(PROJECT_DIR) VPATH += $(T1_PATH)/T1/src inc-y += $(T1_PATH)/T1/interface inc-y += $(T1_PATH)/T1/src libitem-y += $(T1_PATH)/T1/lib/libt1base.a libitem-y += $(T1_PATH)/T1/lib/libt1com8.a libitem-y += $(T1_PATH)/T1/lib/libt1cont.a libitem-y += $(T1_PATH)/T1/lib/libt1delay.a libitem-y += $(T1_PATH)/T1/lib/libt1flex.a libitem-y += $(T1_PATH)/T1/lib/libt1mod.a libitem-y += $(T1_PATH)/T1/lib/libt1scope.a obj-y +=Arc_T1_Int.o obj-y +=T1_AppInterface.o obj-y +=T1_config.o endif #CFG_T1_ENABLE ifeq ($(CFG_ARC_CLIB),y) # Just use native clib # Override native C-library with ArcCore tweaks. inc-system-y += $(ROOTDIR)/clib vpath-y += $(ROOTDIR)/clib obj-$(USE_TTY_T32) += serial_dbg_t32.o obj-$(USE_TTY_UDE)-$(CFG_PPC) += serial_dbg_ude.o obj-$(USE_TTY_UDE)-$(CFG_ARM) += serial_dbg_ude_arm.o obj-$(USE_TTY_WINIDEA) += serial_dbg_winidea.o obj-$(USE_TTY_CODE_COMPOSER) += serial_dbg_code_composer.o obj-$(CFG_FS_RAM) += fs_ram.o obj-$(USE_TTY_SCI) += serial_sci.o obj-y += clib_port.o obj-y += printf.o obj-y += xtoa.o obj-y-cw += strtok_r.o obj-y-diab += strtok_r.o else ifeq ($(SELECT_CLIB),CLIB_IAR) # This is not good, but don't know what to do right now.... obj-y += iar_port.o obj-y += xtoa.o else ifeq ($(SELECT_CLIB),CLIB_CW) # This is not good, but don't know what to do right now.... obj-y += xtoa.o obj-y += msl_port.o obj-$(USE_TTY_UDE) += serial_dbg_ude.o endif endif # SELECT_CLIB # Path to serial dbg drivers.. obj-$(CFG_BITDEF) += bitdef.o inc-y += $(ROOTDIR)/drivers vpath-y += $(ROOTDIR)/drivers # If postbuild mode, just build post-build files. ifneq ($(CFG_POSTBUILD_BUILD),y) obj-y += $(obj-y-y) obj-y += $(obj-y-y-y) obj-y += $(obj-y-y-y-y) obj-y += $(obj-y-$(COMPILER)) else obj-y = endif obj-y += $(pb-obj-y) $(pb-obj-y-y) #$(error x$(obj-y)x) vpath-y += $(vpath-y-y) vpath-y += $(board_path) vpath-y += $(ROOTDIR)/$(OSAL_ARCH)/$(ARCH_FAM) vpath-y += $(ROOTDIR)/arch/$(ARCH_FAM) vpath-y += $(board_path)/config vpath-y += $(ROOTDIR)/diagnostic/Dem vpath-y += $(ROOTDIR)/diagnostic/Dcm vpath-y += $(ROOTDIR)/diagnostic/Det # include files need by us inc-y += $(ROOTDIR)/include inc-y += $(ROOTDIR)/include/base BASE-MOD-MK?=$(ROOTDIR)/base/base.mod.mk include $(BASE-MOD-MK) inc-y += $(ROOTDIR)/$(ARCH_KERNEL_PATH-y)/kernel inc-y += $(board_path)/config # # And last the generic board # inc-y += $(ROOTDIR)/boards/generic vpath-y += $(ROOTDIR)/boards/generic vpath-y += $(ROOTDIR)/boards/ inc-y += $(ROOTDIR)/mcal/Mcu/inc inc-y += $(ROOTDIR)/integration VPATH += $(vpath-y) # # Remove unwanted warnings in BSW for different compilers and specific files # #Diab CFLAGS_diab_os_alarm.o += -ei4546 CFLAGS_diab_Dio.o += -ei4546 CFLAGS_diab_Can.o += -ei2273,4111 CFLAGS_diab_Dem.o += -ei4186 #Codewarrior CFLAGS_cw_IoHwAb.o += -W=nounused CFLAGS_cw_Dio.o += -W=nounused CFLAGS_cw_IoHwAb_Analog.o += -W=nounused -W=nounusedexpr CFLAGS_cw_IoHwAb_Digital.o += -W=nounused CFLAGS_cw_EcuM_Main.o += -W=nounused -W=off CFLAGS_cw_EcuM.o += -W=nounused -W=off CFLAGS_cw_Mcu.o += -W=nounused CFLAGS_cw_Can.o += -W=nounused CFLAGS_cw_CanIf.o += -W=off CFLAGS_cw_init.o += -W=off CFLAGS_cw_Nm.o += -W=nounused -W=off CFLAGS_cw_Mcu_Cfg.o += -W=off CFLAGS_cw_ComM.o += -W=nounused CFLAGS_cw_CanNm.o += -W=nounused CFLAGS_cw_Pwm.o += -W=nounused CFLAGS_cw_Adc_eQADC.o += -W=nopossible -W=nounwanted CFLAGS_cw_Com_misc.o += -W=nounused CFLAGS_cw_EcuM_Callout_Stubs.o += -W=nounused CFLAGS_cw_SchM.o += -W=nounused
2301_81045437/classic-platform
boards/board_common.mk
Makefile
unknown
22,888
# Memory MOD_AVAIL+=NVM MEMIF FEE FLS EEP EA # System + Communication + Diagnostic MOD_AVAIL+=XCP CANIF CANTP FRTP LINTP LINIF COM DCM DEM FIM DET DLT STBM ECUM_FIXED SAFEIOHWAB IOHWAB KERNEL PDUR WDGM WDGIF ETHIF FRIF SOAD DOIP SD QUEUE SAFEQ MOD_AVAIL+=RTE J1939TP SCHM ECUM_FLEXIBLE BSWM ETHTSYN SOMEIPXF E2EXF # Network management MOD_AVAIL+=COMM NM CANNM CANSM LINSM FRSM FRNM IPDUM ETHSM SECOC # Additional MOD_AVAIL+= RAMLOG CRC CDDPDUR CPL CAL RAMTST DLTUARTCOM LDCOM FRTP CDDETHTRCV E2E OSEKNM HTMSS RTM SMAL #Transceivers MOD_AVAIL+= CDDETHTRCV CANTRCV ifneq ($(SELECT_COV_TOOL),) CFG+=FILE_MEM_PARTITION CFG+=FS_RAM ifeq ($(SELECT_COV_TOOL),gcov) CFG+=GCOV endif ifeq ($(SELECT_COV_TOOL),bullseye) CFG+=BULLSEYE endif endif COV_BULLSEYE_PATH?=/c/devtools/BullseyeCoverage # We require at least this version... COV_BULLSEYE_REQ_VERSION?=81411 ifneq ($(SELECT_TEST_OUTPUT),) ifeq ($(SELECT_TEST_OUTPUT),xml) def-y+= XML_OUTPUTTER_SKIP_HEADER def-y+= XML_OUTPUTTER_HTML_ESCAPE def-y+= EMBUNIT_XML_OUTPUT endif endif
2301_81045437/classic-platform
boards/build_config_bsw.mk
Makefile
unknown
1,114
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ /* These defines are overriden by rte generated file with the same name */ #undef CALIBRATION_INITIALIZED_RAM #undef CALIBRATION_ENABLED #undef CALIBRATION_FLS_START
2301_81045437/classic-platform
boards/generic/Calibration_Settings.h
C
unknown
924
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #include "CanTp_Types.h" CanTp_GeneralType CanTpGeneralConfig = { .main_function_period = 20, }; //NSa CanTp_NSaType CanTpNSaConfig_UdsPhys_RxNSdu = { .CanTpNSa = 0, }; CanTp_NSaType CanTpNSaConfig_UdsFunc_RxNSdu = { .CanTpNSa = 0, }; CanTp_NSaType CanTpNSaConfig_UdsPhys_TxNSdu = { .CanTpNSa = 0, }; CanTp_NSaType CanTpNSaConfig_UdsFunc_TxNSdu = { .CanTpNSa = 0, }; //NTa CanTp_NTaType CanTpNTaConfig_UdsPhys_RxNSdu = { .CanTpNTa = 0, }; CanTp_NTaType CanTpNTaConfig_UdsFunc_RxNSdu = { .CanTpNTa = 0, }; CanTp_NTaType CanTpNTaConfig_UdsPhys_TxNSdu = { .CanTpNTa = 0, }; CanTp_NTaType CanTpNTaConfig_UdsFunc_TxNSdu = { .CanTpNTa = 0, }; CanTp_NSduType CanTpNSduConfigList[] = { { .direction = IS015765_TRANSMIT, .configData.CanTpTxNSdu.CanIf_PduId = 1, //CANIF_PDU_ID_UDS_PHYS_TX, .configData.CanTpTxNSdu.PduR_PduId = 0, //PDUR_PDU_ID_UDS_PHYS_TX, .configData.CanTpTxNSdu.CanTpTxChannel = 2, .configData.CanTpTxNSdu.CanTpAddressingMode = CANTP_STANDARD, .configData.CanTpTxNSdu.CanTpNas = 2, .configData.CanTpTxNSdu.CanTpNbs = 2, .configData.CanTpTxNSdu.CanTpNcs = 2, .configData.CanTpTxNSdu.CanTpTxDI = 6, .configData.CanTpTxNSdu.CanTpTxPaddingActivation = CANTP_OFF, .configData.CanTpTxNSdu.CanTpTxTaType = CANTP_FUNCTIONAL, .configData.CanTpTxNSdu.CanTpNSa = &CanTpNSaConfig_UdsPhys_TxNSdu, .configData.CanTpTxNSdu.CanTpNTa = &CanTpNTaConfig_UdsPhys_TxNSdu, .listItemType = CANTP_NOT_LAST_ENTRY, }, { .direction = IS015765_TRANSMIT, .configData.CanTpTxNSdu.CanIf_PduId = 0, //CANIF_PDU_ID_UDS_FUNC_TX, .configData.CanTpTxNSdu.PduR_PduId = 1, //PDUR_PDU_ID_UDS_FUNC_TX, .configData.CanTpTxNSdu.CanTpTxChannel = 3, .configData.CanTpTxNSdu.CanTpAddressingMode = CANTP_STANDARD, .configData.CanTpTxNSdu.CanTpNas = 2, .configData.CanTpTxNSdu.CanTpNbs = 2, .configData.CanTpTxNSdu.CanTpNcs = 2, .configData.CanTpTxNSdu.CanTpTxDI = 6, .configData.CanTpTxNSdu.CanTpTxPaddingActivation = CANTP_OFF, .configData.CanTpTxNSdu.CanTpTxTaType = CANTP_FUNCTIONAL, .configData.CanTpTxNSdu.CanTpNSa = &CanTpNSaConfig_UdsFunc_TxNSdu, .configData.CanTpTxNSdu.CanTpNTa = &CanTpNTaConfig_UdsFunc_TxNSdu, .listItemType = CANTP_END_OF_LIST, }, { .direction = ISO15765_RECEIVE, .configData.CanTpRxNSdu.CanIf_FcPduId = 0, //CANIF_PDU_ID_UDS_PHYS_RX, .configData.CanTpRxNSdu.PduR_PduId = 0, //PDUR_PDU_ID_UDS_PHYS_RX, .configData.CanTpRxNSdu.CanTpRxChannel = 0, .configData.CanTpRxNSdu.CanTpAddressingFormant = CANTP_STANDARD, .configData.CanTpRxNSdu.CanTpBs = 30, .configData.CanTpRxNSdu.CanTpNar = 5000, .configData.CanTpRxNSdu.CanTpNbr = 1000, .configData.CanTpRxNSdu.CanTpNcr = 1000, .configData.CanTpRxNSdu.CanTpRxDI = 6, .configData.CanTpRxNSdu.CanTpRxPaddingActivation = CANTP_OFF, .configData.CanTpRxNSdu.CanTpRxTaType = CANTP_FUNCTIONAL, .configData.CanTpRxNSdu.CanTpWftMax = 5, .configData.CanTpRxNSdu.CanTpSTmin = 0, .configData.CanTpRxNSdu.CanTpNSa = &CanTpNSaConfig_UdsPhys_RxNSdu, .configData.CanTpRxNSdu.CanTpNTa = &CanTpNTaConfig_UdsPhys_RxNSdu, .listItemType = CANTP_NOT_LAST_ENTRY, }, { .direction = ISO15765_RECEIVE, .configData.CanTpRxNSdu.CanIf_FcPduId = 0, //CANIF_PDU_ID_UDS_FUNC_RX, .configData.CanTpRxNSdu.PduR_PduId = 1, //PDUR_PDU_ID_UDS_FUNC_RX, .configData.CanTpRxNSdu.CanTpRxChannel = 1, .configData.CanTpRxNSdu.CanTpAddressingFormant = CANTP_STANDARD, .configData.CanTpRxNSdu.CanTpBs = 30, .configData.CanTpRxNSdu.CanTpNar = 5000, .configData.CanTpRxNSdu.CanTpNbr = 1000, .configData.CanTpRxNSdu.CanTpNcr = 1000, .configData.CanTpRxNSdu.CanTpRxDI = 6, .configData.CanTpRxNSdu.CanTpRxPaddingActivation = CANTP_OFF, .configData.CanTpRxNSdu.CanTpRxTaType = CANTP_FUNCTIONAL, .configData.CanTpRxNSdu.CanTpWftMax = 0, .configData.CanTpRxNSdu.CanTpSTmin = 0, .configData.CanTpRxNSdu.CanTpNSa = &CanTpNSaConfig_UdsFunc_RxNSdu, .configData.CanTpRxNSdu.CanTpNTa = &CanTpNTaConfig_UdsFunc_RxNSdu, .listItemType = CANTP_NOT_LAST_ENTRY, }, }; CanTp_ConfigType CanTpConfig = { .CanTpNSduList = CanTpNSduConfigList, .CanTpGeneral = &CanTpGeneralConfig, };
2301_81045437/classic-platform
boards/generic/CanTp_Cfg.c
C
unknown
5,480
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #ifndef CANTP_CFG_H_ #define CANTP_CFG_H_ #include "CanTp_Types.h" #define CANTP_MAIN_FUNCTION_PERIOD_TIME_MS 1000 #define CANTP_CONVERT_MS_TO_MAIN_CYCLES(x) (x)/CANTP_MAIN_FUNCTION_PERIOD_TIME_MS #define CANTP_NSDU_CONFIG_LIST_SIZE 4 #define CANTP_NSDU_RUNTIME_LIST_SIZE 4 #define FRTP_CANCEL_TRANSMIT_REQUEST STD_ON #define CANTP_VERSION_INFO_API STD_ON /**< Build version info API */ #define CANTP_DEV_ERROR_DETECT STD_ON extern CanTp_ConfigType CanTpConfig; extern const CanTp_NSduType CanTpNSduConfigList[]; #endif /* CANTP_CFG_H_ */
2301_81045437/classic-platform
boards/generic/CanTp_Cfg.h
C
unknown
1,410
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #ifndef COMPILER_CFG_H #define COMPILER_CFG_H /* NOTE: Copy this file to your local config-folder * and add your code here */ /* See CompilerAbstraction.pdf */ /* REQ:COMPILER040 */ #endif /* COMPILER_CFG_H */
2301_81045437/classic-platform
boards/generic/Compiler_Cfg.h
C
unknown
989
/* * Generator version: 2.0.0 * AUTOSAR version: 4.3.0 */ /*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ /** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */ #if !(((CRC_SW_MAJOR_VERSION == 2) && (CRC_SW_MINOR_VERSION == 0)) ) #error Crc: Configuration file expected BSW module version to be 2.0.* #endif #if !(((CRC_AR_RELEASE_MAJOR_VERSION == 4) && (CRC_AR_RELEASE_MINOR_VERSION == 3)) ) #error Crc: Configuration file expected AUTOSAR version to be 4.3.* #endif #ifndef CRC_CFG_H_ #define CRC_CFG_H_ /* @req SWS_CRC_00022 The Crc module shall comply with the following include file structure */ #include "Crc_MemMap.h" /* @req SWS_CRC_00040 Requirement was removed from ASR4.3.0, but kept to check,that only VARIANT-PRE-COMPILE is supported */ /* CRC 8 Configuration * Possible values and the mode decides what method to be used */ #define CRC_8_HARDWARE (0x01) /* Not supported */ #define CRC_8_RUNTIME (0x02) #define CRC_8_TABLE (0x04) /* Default value */ #define Crc_8_Mode CRC_8_TABLE /* CRC 8H2F Configuration * Possible values and the mode decides what method to be used */ #define CRC_8H2F_HARDWARE (0x01) /* Not supported */ #define CRC_8H2F_RUNTIME (0x02) #define CRC_8H2F_TABLE (0x04) /* Default value */ #define Crc_8_8H2FMode CRC_8H2F_TABLE /* CRC 16 Configuration * Possible values and the mode decides what method to be used */ #define CRC_16_HARDWARE (0x01) /* Not supported */ #define CRC_16_RUNTIME (0x02) #define CRC_16_TABLE (0x04) /* Default value */ #define SAFELIB_VERSIONINFO_API STD_OFF // Enable/Diable version info API #define Crc_16_Mode CRC_16_TABLE /* CRC 32 Configuration * Possible values and the mode decides what method to be used */ #define CRC_32_HARDWARE (0x01) /* Not supported */ #define CRC_32_RUNTIME (0x02) #define CRC_32_TABLE (0x04) /* Default value */ #define CRC_32_MODE CRC_32_TABLE /* CRC 32P4 Configuration * Possible values and the mode decides what method to be used */ #define CRC_32P4_HARDWARE (0x01) /* Not supported */ #define CRC_32P4_RUNTIME (0x02) #define CRC_32P4_TABLE (0x04) /* Default value */ #define CRC_32P4_MODE CRC_32P4_TABLE #endif /* CRC_CFG_H_ */
2301_81045437/classic-platform
boards/generic/Crc_Cfg.h
C
unknown
2,988
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #ifndef DCM_CFG_H_ #define DCM_CFG_H_ /* * DCM General */ #define DCM_VERSION_INFO_API STD_ON // Activate/Deactivate ver info API. #define DCM_DEV_ERROR_DETECT STD_ON // Activate/Deactivate Dev Error Detection and Notification. #define DCM_REQUEST_INDICATION_ENABLED STD_ON // Activate/Deactivate indication request mechanism. #define DCM_RESPOND_ALL_REQUEST STD_ON // Activate/Deactivate response on SID 0x40-0x7f and 0xc0-0xff. #define DCM_TASK_TIME TBD // Time for periodic task (in ms). #define DCM_PAGEDBUFFER_ENABLED STD_OFF // Enable/disable page buffer mechanism (currently only disabled supported) #endif /*DCM_CFG_H_*/
2301_81045437/classic-platform
boards/generic/Dcm_Cfg.h
C
unknown
1,502
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #include "Dcm.h" /********************* * DCM Configuration * *********************/ /* * DSP configurations */ const Dcm_DspType Dsp = { .DspDid = NULL, .DspDidInfo = NULL, .DspEcuReset = NULL, .DspPid = NULL, .DspReadDTC = NULL, .DspRequestControl = NULL, .DspRoutine = NULL, .DspRoutineInfo = NULL, .DspSecurity = NULL, .DspSession = NULL, .DspTestResultByObdmid = NULL, .DspVehInfo = NULL, }; /* * DSD configurations */ const Dcm_DsdType Dsd = { .DsdServiceTable = NULL }; /* * DSL configurations */ const Dcm_DslType Dsl = { .DslBuffer = NULL, .DslCallbackDCMRequestService = NULL, .DslDiagResp = NULL, .DslProtocol = NULL, .DslProtocolTiming = NULL, .DslServiceRequestIndication = NULL, .DslSessionControl = NULL }; /* * DCM configurations */ const Dcm_ConfigType DCM_Config = { .Dsp = &Dsp, .Dsd = &Dsd, .Dsl = &Dsl };
2301_81045437/classic-platform
boards/generic/Dcm_LCfg.c
C
unknown
1,922
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #ifndef DEM_CFG_H_ #define DEM_CFG_H_ /* * DEM General */ #define DEM_VERSION_INFO_API STD_ON // Activate/Deactivate ver info API. #define DEM_DEV_ERROR_DETECT STD_ON // Activate/Deactivate Dev Error Detection and Notification. #define DEM_OBD_SUPPORT STD_OFF #define DEM_PTO_SUPPORT STD_OFF #define DEM_TYPE_OF_DTC_SUPPORTED 0x01 // ISO14229-1 #define DEM_DTC_STATUS_AVAILABILITY_MASK 0xFF #define DEM_CLEAR_ALL_EVENTS STD_OFF // All event or only events with DTC is cleared with Dem_ClearDTC #define DEM_BSW_ERROR_BUFFER_SIZE 20 // Max nr of elements in BSW error buffer (0..255) #define DEM_FF_DID_LENGTH TBD // Length of DID & PID of FreezeFrames in Bytes. #define DEM_MAX_NUMBER_EVENT_ENTRY_MIR 0 // Max nr of events stored in mirror memory. #define DEM_MAX_NUMBER_EVENT_ENTRY_PER 0 // Max nr of events stored in permanent memory. #define DEM_MAX_NUMBER_EVENT_ENTRY_PRI 10 // Max nr of events stored in primary memory. #define DEM_MAX_NUMBER_EVENT_ENTRY_SEC 0 // Max nr of events stored in secondary memory. #define DEM_MAX_NUMBER_PRESTORED_FF 0 // Max nr of prestored FreezeFrames. 0=Not supported. /* * Size limitations of the types derived from DemGeneral */ #define DEM_MAX_NR_OF_RECORDS_IN_EXTENDED_DATA 10 // 0..253 according to Autosar #define DEM_MAX_NR_OF_EVENT_DESTINATION 4 // 0..4 according to Autosar /* * Size limitations of storage area */ #define DEM_MAX_SIZE_FF_DATA 10 // Max number of bytes in one freeze frame #define DEM_MAX_SIZE_EXT_DATA 10 // Max number of bytes in one extended data record #define DEM_MAX_NUMBER_EVENT 100 // Max number of events to keep status on #define DEM_MAX_NUMBER_EVENT_PRE_INIT 20 // Max number of events status to keep before init #define DEM_MAX_NUMBER_FF_DATA_PRE_INIT 20 // Max number of freeze frames to store before init #define DEM_MAX_NUMBER_EXT_DATA_PRE_INIT 20 // Max number of extended data to store before init #define DEM_MAX_NUMBER_EVENT_PRI_MEM (DEM_MAX_NUMBER_EVENT_ENTRY_PRI) // Max number of events status to store in primary memory #define DEM_MAX_NUMBER_FF_DATA_PRI_MEM 5 // Max number of freeze frames to store in primary memory #define DEM_MAX_NUMBER_EXT_DATA_PRI_MEM 5 // Max number of extended data to store in primary memory #define DEM_MAX_RECORD_NUMBERS_IN_FF_REC_NUM_CLASS 0 typedef struct { uint32 UDSDTC; uint32 OBDDTC; boolean DTCUsed; boolean ImmediateNvStorage; } Arc_Dem_DTC; typedef struct { boolean JumpUp; boolean JumpDown; uint16 IncrementStepSize; uint16 DecrementStepSize; sint16 JumpDownValue; sint16 JumpUpValue; sint16 FailedThreshold; sint16 PassedThreshold; } Dem_PreDebounceCounterBasedType; #endif /*DEM_CFG_H_*/
2301_81045437/classic-platform
boards/generic/Dem_Cfg.h
C
unknown
3,666
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #ifndef DEM_ENABLECONDID_H_ #define DEM_ENABLECONDID_H_ #warning "This default file may only be used as an example!" #endif /* DEM_ENABLECONDID_H_ */
2301_81045437/classic-platform
boards/generic/Dem_EnableCondId.h
C
unknown
908
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #ifndef DEM_INTERRID_H_ #define DEM_INTERRID_H_ #endif /*DEM_INTERRID_H_*/ /* * Definition of event IDs used by BSW * NB! Must be unique for each event! */ enum { // Event IDs from DEM module DEM_EVENT_ID_NULL = 0, // Do not change this entry!!! // Event IDs from MCU MCU_E_CLOCK_FAILURE, // Event IDs from CAN CANTRCV_E_NO_TRCV_CONTROL, CANTP_E_OPER_NOT_SUPPORTED, CANTP_E_COMM, CANNM_E_CANIF_TRANSMIT_ERROR, CANNM_E_NETWORK_TIMEOUT, CANIF_TRCV_E_TRANSCEIVER, CANIF_E_INVALID_DLC, CANIF_STOPPED, CANIF_E_FULL_TX_BUFFER, CAN_E_TIMEOUT, // Event IDs from EEPROM EEP_E_COM_FAILURE, // Event IDs from flash FLS_E_ERASE_FAILED, FLS_E_WRITE_FAILED, FLS_E_READ_FAILED, FLS_E_COMPARE_FAILED, FLS_E_UNEXPECTED_FLASH_ID, // Event IDs from LIN LIN_E_TIMEOUT, // Event IDs from ECU ECUM_E_RAM_CHECK_FAILED, ECUM_E_ALL_RUN_REQUESTS_KILLED, ECUM_E_CONFIGURATION_DATA_INCONSISTENT, // Event IDs from COM // COMM_E_NET_START_IND_CHANNEL_<X>, // Event IDs from PDUR PDUR_E_PDU_INSTANCE_LOST, PDUR_E_INIT_FAILED, // Event IDs from WDGM WDGM_E_ALIVE_SUPERVISION, WDGM_E_SET_MODE, // DEM last event id for BSW DEM_EVENT_ID_LAST_FOR_BSW };
2301_81045437/classic-platform
boards/generic/Dem_IntErrId.h
C
unknown
2,184
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #ifndef DEMINTEVTID_H_ #define DEMINTEVTID_H_ /* * Definition of event IDs used by SW-C * NB! Must be unique for each event! */ enum { // NB! Event IDs below DEM_SWC_EVENT_ID_START not allowed! DEM_EVENT_ID_SWC_START = DEM_EVENT_ID_LAST_FOR_BSW }; #endif /*DEMINTEVTID_H_*/
2301_81045437/classic-platform
boards/generic/Dem_IntEvtId.h
C
unknown
1,139
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #include "Dem.h" /********************* * DEM Configuration * *********************/ /* * Classes of extended data record */ /* * Classes of extended data */ /* * Classes of freeze frames */ /* * Classes of PreDebounce algorithms */ /* * Classes of event */ /* * Event parameter list */ const Dem_EventParameterType EventParameter[] = { { .Arc_EOL = TRUE } }; /* * DEM's config set */ const Dem_ConfigSetType DEM_ConfigSet = { .EventParameter = EventParameter, }; /* * DEM's config */ const Dem_ConfigType DEM_Config = { .ConfigSet = &DEM_ConfigSet, };
2301_81045437/classic-platform
boards/generic/Dem_LCfg.c
C
unknown
1,522
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ /* Generator version: 2.0.0 * AUTOSAR version: 4.3.0 */ #include "Det.h" #if !(((DET_SW_MAJOR_VERSION == 2) && (DET_SW_MINOR_VERSION == 0)) ) #error Det: Configuration file expected BSW module version to be 2.2.* #endif #if !(((DET_AR_MAJOR_VERSION == 4) && (DET_AR_MINOR_VERSION == 3)) ) #error Det: Expected AUTOSAR version to be 4.3.* #endif // No static Dethooks configured
2301_81045437/classic-platform
boards/generic/Det_Cfg.c
C
unknown
1,162
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ /* Generator version: 2.0.0 * AUTOSAR version: 4.3.0 */ #if !(((DET_SW_MAJOR_VERSION == 2) && (DET_SW_MINOR_VERSION == 0)) ) #error Det: Configuration file expected BSW module version to be 2.0.* #endif #if !(((DET_AR_MAJOR_VERSION == 4) && (DET_AR_MINOR_VERSION == 3)) ) #error Det: Expected AUTOSAR version to be 4.3.* #endif #ifndef DET_CFG_H_ #define DET_CFG_H_ /** @req ECUC_Det_00002 */ #define DET_ENABLE_CALLBACKS STD_ON // Enable to use callback on errors /** @req ECUC_Det_00006 */ #define DET_FORWARD_TO_DLT STD_OFF // Enable to use callout to Dlt #define DET_USE_RAMLOG STD_OFF // Enable to log DET errors to ramlog #define DET_WRAP_RAMLOG STD_OFF // The ramlog wraps around when reaching the end #define DET_USE_STDERR STD_OFF // Enable to get DET errors on stderr #define DET_DEINIT_API STD_OFF // Enable/Disable the Det_DeInit function /** @req ECUC_Det_00003 */ #define DET_VERSIONINFO_API STD_OFF // Enable/Diable version info API #define DET_SAFETYMONITOR_API STD_OFF // Enable/Diable safety monitor API #define DET_RAMLOG_SIZE (16) // Number of entries in ramlog #define DET_NUMBER_OF_CALLBACKS (5) // Number of callbacks #define DET_USE_STATIC_CALLBACKS STD_OFF // Enable static callbacks #define DET_NUMBER_OF_STATIC_CALLBACKS 0 #endif /* DET_CFG_H_ */
2301_81045437/classic-platform
boards/generic/Det_Cfg.h
C
unknown
2,118
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #if !(((EA_SW_MAJOR_VERSION == 1) && (EA_SW_MINOR_VERSION == 0)) ) #error Ea: Configuration file expected BSW module version to be 1.0.* #endif #ifndef EA_CFG_H #define EA_CFG_H #include "MemIf_Types.h" #define EA_NUMBER_OF_BLOCKS 2 /*The size in bytes to which logical blocks shall be aligned.*/ #define EA_VIRTUAL_PAGE_SIZE 8 /*The largest block size used.*/ #define EA_MAX_BLOCK_SIZE 516 /* ITEM NAME: <EA_DEV_ERROR_DETECT> SCOPE: <EA Module> DESCRIPTION: Pre-processor switch to enable and disable development error detection. true: Development error detection enabled. false: Development error detection disabled. */ #define EA_DEV_ERROR_DETECT STD_ON /* ITEM NAME: <EA_SET_MODE_SUPPORTED> SCOPE: <EA Module> DESCRIPTION: Compile switch to enable / disable the function Ea_SetMode */ #define EA_SET_MODE_SUPPORTED STD_ON /* ITEM NAME: <EA_VERSION_INFO_API> SCOPE: <EA Module> DESCRIPTION: Pre-processor switch to enable / disable the API to read out the modules version information. true: Version info API enabled. false: Version info API disabled. */ #define EA_VERSION_INFO_API STD_OFF /* ITEM NAME: <Ea_BlockConfigType> SCOPE: <Ea Module> DESCRIPTION: Configuration of block specific parameters for the EEPROM abstraction module. */ typedef struct { /*Block identifier (handle). 0x0000 and 0xFFFF shall not be used for block numbers (see EA006). Range: min = 2^NVM_DATA_SELECTION_BITS max = 0xFFFF -2^NVM_DATA_SELECTION_BITS Note: Depending on the number of bits set aside for dataset selection several other block numbers shall also be left out to ease implementation. NVM_DATA_SELECTION_BITS = 4 So range: 0x10 ~ 0xFFEF*/ uint16 EaBlockNumber; /*Size of a logical block in bytes.*/ /*@req EA117 */ uint16 EaBlockSize; /*Marker for high priority data. true: Block contains immediate data. false: Block does not contain immediate data.*/ boolean EaImmediateData; /*Device index (handle). Range: 0 .. 254 (0xFF reserved for broadcast call to GetStatus function). Type: Reference to EepGeneral item 'EepDriverIndex' dependency: This information is needed by the NVRAM manager respectively the Memory Abstraction Interface to address a certain logical block. It is listed in this specification to give a complete overview over all block related configuration parameters.*/ uint8 EaDeviceIndex; /*indicates the end of the Ea Block List*/ boolean EaBlockEOL; }Ea_BlockConfigType; /* ITEM NAME: <Ea_GeneralType> SCOPE: <Ea Module> DESCRIPTION: General configuration of the EEPROM abstraction module. This container lists block independent configuration parameters. */ typedef struct { /*Specifies the InstanceId of this module instance. If only one instance is present it shall have the Id 0.*/ uint8 EaIndex; /*Mapped to the job end notification routine provided by the upper layer module (NvM_JobEndNotification).*/ void (*EaNvmJobEndNotification)(void); /*Mapped to the job error notification routine provided by the upper layer module (NvM_JobErrorNotification). */ void (*EaNvmJobErrorNotification)(void); }Ea_GeneralType; extern const Ea_GeneralType Ea_GeneralData; extern const Ea_BlockConfigType Ea_BlockConfigData[]; #endif /*EA_CFG_H*/
2301_81045437/classic-platform
boards/generic/Ea_Cfg.h
C
unknown
4,394
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #include "Ea.h" #include "NvM_Cbk.h" /* ITEM NAME: <Ea_GeneralData> SCOPE: <Ea Module> DESCRIPTION: configuration for Ea_General. */ const Ea_GeneralType Ea_GeneralData = { 0, /*EaIndex*/ NvM_JobEndNotification, /*EaNvmJobEndNotification*/ NvM_JobErrorNotification, /*EaNvmJobEndNotification*/ }; /* ITEM NAME: <Ea_BlockConfigData> SCOPE: <Ea Module> DESCRIPTION: configuration for Ea_BlockConfig. This container mapped EEPROM with block of EA Module */ const Ea_BlockConfigType Ea_BlockConfigData[] = /*EaBlockNumber*/ /*EaBlockSize*/ /*EaImmediateData*/ /*EaDeviceIndex*/ /*EaBlockEOL*/ { {1, 260, false, 2, false}, {2, 516, false, 2, true}, };
2301_81045437/classic-platform
boards/generic/Ea_Lcfg.c
C
unknown
1,608
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #ifndef ECUM_CFG_H_ #define ECUM_CFG_H_ #define ECUM_VERSION_INFO_API STD_OFF #define ECUM_DEV_ERROR_DETECT STD_OFF #include "EcuM_Generated_Types.h" #define ECUM_MAIN_FUNCTION_PERIOD (200) #define ECUM_NVRAM_READALL_TIMEOUT (10000) #define ECUM_NVRAM_WRITEALL_TIMEOUT (10000) #define ECUM_NVRAM_MIN_RUN_DURATION (10000) typedef enum { ECUM_USER_User_1, ECUM_USER_ENDMARK // Must be the last in list! } EcuM_UserList; extern EcuM_ConfigType EcuMConfig; #endif /*ECUM_CFG_H_*/
2301_81045437/classic-platform
boards/generic/EcuM_Cfg.h
C
unknown
1,334
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #include "EcuM.h" #if defined(USE_CANSM) extern const CanSM_ConfigType CanSM_Config; #endif #if defined(USE_NM) extern const Nm_ConfigType Nm_Config; #endif #if defined(USE_CANNM) extern const CanNm_ConfigType CanNm_Config; #endif #if defined(USE_UDPNM) extern const UdpNm_ConfigType UdpNm_Config; #endif #if defined(USE_COMM) extern const ComM_ConfigType ComM_Config; #endif #if defined(USE_J1939TP) extern const J1939Tp_ConfigType J1939Tp_Config; #endif EcuM_ConfigType EcuMConfig = { .EcuMDefaultShutdownTarget = ECUM_STATE_RESET, .EcuMDefaultSleepMode = 0, // Don't care .EcuMDefaultAppMode = OSDEFAULTAPPMODE, .EcuMNvramReadAllTimeout = ECUM_NVRAM_READALL_TIMEOUT, .EcuMNvramWriteAllTimeout = ECUM_NVRAM_WRITEALL_TIMEOUT, .EcuMRunMinimumDuration = ECUM_NVRAM_MIN_RUN_DURATION, #if defined(USE_MCU) .McuConfig = McuConfigData, #endif #if defined(USE_PORT) .PortConfig = &PortConfigData, #endif #if defined(USE_CAN) .CanConfig = &CanConfigData, #endif #if defined(USE_CANIF) .CanIfConfig = &CanIf_Config, #endif #if defined(USE_CANSM) .CanSMConfig = &CanSM_Config, #endif #if defined(USE_CANNM) .CanNmConfig = &CanNm_Config, #endif #if defined(USE_UDPNM) .UdpNmConfig = &UdpNm_Config, #endif #if defined(USE_COM) .ComConfig = &ComConfiguration, #endif #if defined(USE_COMM) .ComMConfig = &ComM_Config, #endif #if defined(USE_J1939TP) .J1939TpConfig = &J1939Tp_Config, #endif #if defined(USE_NM) .NmConfig = &Nm_Config, #endif #if defined(USE_PDUR) .PduRConfig = &PduR_Config, #endif #if defined(USE_J1939TP) .J1939TpConfig = &J1939Tp_Config, #endif #if defined(USE_DMA) .DmaConfig = DmaConfig, #endif #if defined(USE_ADC) .AdcConfig = AdcConfig, #endif #if defined(USE_PWM) .PwmConfig = &PwmConfig, #endif #if defined(USE_WDG) .WdgConfig = &WdgConfig, #endif #if defined(USE_WDGM) .WdgMConfig = &WdgMConfig, #endif #if defined(USE_WDGIF) .WdgIfConfig = &WdgIfConfig, #endif #if defined(USE_GPT) .GptConfig = GptConfigData, #endif #if defined(USE_FLS) .FlashConfig = FlsConfigSet, #endif #if defined(USE_EEP) .EepConfig = EepConfigData, #endif #if defined(USE_SPI) .SpiConfig = &SpiConfigData, #endif };
2301_81045437/classic-platform
boards/generic/EcuM_PBcfg.c
C
unknown
3,215
/*-------------------------------- Arctic Core ------------------------------ * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com. * Contact: <contact@arccore.com> * * You may ONLY use this file: * 1)if you have a valid commercial ArcCore license and then in accordance with * the terms contained in the written license agreement between you and ArcCore, * or alternatively * 2)if you follow the terms found in GNU General Public License version 2 as * published by the Free Software Foundation and appearing in the file * LICENSE.GPL included in the packaging of this file or here * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt> *-------------------------------- Arctic Core -----------------------------*/ #warning "This default file may only be used as an example!" #include "Fee.h" #include "NvM_Cbk.h" const Fee_BlockConfigType BlockConfigList[] = { }; const Fee_ConfigType Fee_Config = { .General = { .NvmJobEndCallbackNotificationCallback = NULL, .NvmJobErrorCallbackNotificationCallback = NULL, }, .BlockConfig = BlockConfigList, };
2301_81045437/classic-platform
boards/generic/Fee_Cfg.c
C
unknown
1,158