提交 | 用户 | 时间 | ||
a6de49 | 1 | package com.iailab.common.utils; |
H | 2 | |
3 | import cn.hutool.core.util.ReflectUtil; | |
4 | import com.iailab.module.model.IAILModel; | |
5 | import lombok.extern.slf4j.Slf4j; | |
6 | ||
7 | import java.lang.reflect.Method; | |
8 | import java.util.HashMap; | |
9 | ||
10 | /** | |
11 | * @author PanZhibao | |
12 | * @Description | |
13 | * @createTime 2023年01月11日 11:03:00 | |
14 | */ | |
15 | @Slf4j | |
16 | public class MatlabUtil { | |
17 | ||
18 | public static HashMap<String, Object> execML(IAILModel model, Object[] paramValues) { | |
19 | ||
20 | //获取预测项的预测程序的类 | |
21 | HashMap<String, Object> tMap = null; | |
22 | try { | |
23 | // double[][] realTimeData ={{12.1,5.1,1.45},{12.2,5.2,1.43},{12,3,5.3,1.425},{13.4,5.4,1.46},{14.5,5.5,1.48},{11.6,5.6,1.5},{12.7,5.7,1.47},{12.8,5.8,1.45},{12.9,5.9,1.43},{12.6,6,1.425},{12.1,5.1,1.46},{12.2,5.2,1.47} ,{12.3,5.3,1.5},{13.4,5.4,1.47},{14.5,5.5,1.45},{11.6,5.6,1.43},{12.7,5.7,1.425}, {12.8,5.8,1.46},{12.9,5.9,1.48},{12.6,6,1.5},{12.1,5.1,1.47},{12.2,5.2,1.45},{12.3,5.3,1.43},{13.4,5.4,1.425},{14.5,5.5,1.46},{11.6,5.6,1.47},{12.7,5.7,1.5},{12.8,5.8,1.47},{12.9,5.9,1.45},{12.6,6,1.45}}; | |
24 | ||
25 | Class<?> clazz = Class.forName(model.getClassName()); | |
26 | ||
27 | Method method = ReflectUtil.getPublicMethod(clazz, model.getMethodName(), model.getParamsArray()); | |
28 | ||
29 | //tMap = ReflectUtil.invoke(clazz.newInstance(), method, paramValues); | |
30 | ||
31 | tMap = (HashMap<String, Object>) method.invoke(clazz.newInstance(), paramValues); | |
32 | } catch (Exception e) { | |
33 | e.printStackTrace(); | |
34 | log.error("exception message : {}", e.getMessage()); | |
35 | } | |
36 | return tMap; | |
37 | } | |
38 | } |