-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_wasm.html
More file actions
124 lines (109 loc) · 3.41 KB
/
test_wasm.html
File metadata and controls
124 lines (109 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>XMUtil WASM Test</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1200px;
margin: 20px auto;
padding: 20px;
}
textarea {
width: 100%;
height: 200px;
font-family: monospace;
margin: 10px 0;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
.output {
background: #f5f5f5;
padding: 10px;
border: 1px solid #ddd;
margin: 10px 0;
}
pre {
white-space: pre-wrap;
word-wrap: break-word;
}
</style>
</head>
<body>
<h1>XMUtil WASM - MDL to XMILE Converter</h1>
<h2>Input MDL:</h2>
<textarea id="mdlInput" placeholder="Paste MDL content here...">
{UTF-8}
Population = 100
~ Person
~ |
********************************************************
.Control
********************************************************~
Simulation Control Parameters
|
FINAL TIME = 100
~ Month
~ The final time for the simulation.
|
INITIAL TIME = 0
~ Month
~ The initial time for the simulation.
|
SAVEPER =
TIME STEP
~ Month [0,?]
~ The frequency with which output is stored.
|
TIME STEP = 1
~ Month [0,?]
~ The time step for the simulation.
|
\\\---/// Sketch information - do not modify anything except names
V300 Do not put anything below this section - it will be ignored
*View 1
</textarea>
<button onclick="convert()">Convert to XMILE</button>
<h2>Output XMILE:</h2>
<div class="output">
<pre id="xmileOutput">Click "Convert to XMILE" to see the output...</pre>
</div>
<script src="out/Release/xmutil.js"></script>
<script>
let xmutilModule;
createXMUtilModule().then(function(Module) {
xmutilModule = Module;
console.log('XMUtil WASM module loaded successfully');
document.getElementById('xmileOutput').textContent = 'Module loaded! Ready to convert.';
}).catch(function(err) {
console.error('Failed to load XMUtil WASM module:', err);
document.getElementById('xmileOutput').textContent = 'Error loading WASM module: ' + err;
});
function convert() {
if (!xmutilModule) {
alert('WASM module not yet loaded. Please wait and try again.');
return;
}
const mdlContent = document.getElementById('mdlInput').value;
const outputElement = document.getElementById('xmileOutput');
try {
// Call with default parameters (only mdlContent is required)
const xmileResult = xmutilModule.convertMdlToXmile(mdlContent);
if (xmileResult && xmileResult.length > 0) {
outputElement.textContent = xmileResult;
} else {
outputElement.textContent = 'Error: Conversion returned empty result. Check console for details.';
}
} catch (error) {
outputElement.textContent = 'Error during conversion: ' + error.message + '\n\nStack: ' + error.stack;
console.error('Conversion error:', error);
}
}
</script>
</body>
</html>