现有组件功能与Amesim组件比较对齐,补全功能;仿真服务启动环境检测,旧版json工程文件适配读取

This commit is contained in:
ljz committed 2026-09-13 20:01:56 +08:00
1 parent b6c22a54f8
commit 6fc9afe41d
119 files changed
+260114 -351

No files matched your search

+7 -3
View File
@@ -2,9 +2,11 @@
#include <math.h>
double native_signal(double t, double start, int stages, int cyclic, const double *data) {
double elapsed = fmax(t-start,0), duration = 0, offset = 0;
if (t < start) return data[0];
double elapsed = t-start, duration = 0, offset = 0;
for (int i=0;i<stages;i++) duration += data[16+i];
if (cyclic && duration > 0) elapsed = fmod(elapsed,duration);
else if (elapsed >= duration) return data[8+stages-1];
for (int i=0;i<stages;i++) {
double d = data[16+i];
if (elapsed < offset+d || i == stages-1)
@@ -18,7 +20,9 @@ double native_signal_break(double t, double end, double start, int stages,
int cyclic, const double *data) {
double duration=0, offset=0, result=end;
for (int i=0;i<stages;i++) duration += data[16+i];
for (int i=0;i<stages;i++) {
/* A cyclic endpoint is already the next cycle's start. Listing both can
create two nearly equal floating-point break times for one event. */
for (int i=0;i<stages+(cyclic?0:1);i++) {
double event=start+offset;
if (cyclic && duration > 0 && event <= t) {
double cycle=fmax(0,floor((t-event)/duration)+1);
@@ -26,7 +30,7 @@ double native_signal_break(double t, double end, double start, int stages,
if (event <= t) event += duration;
}
if (event > t) result=fmin(result,event);
offset += data[16+i];
if (i < stages) offset += data[16+i];
}
return result;
}