Einheit in Analoge Eingänge
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
var win_analogInputsValues = [4.771072, 5.665244, 0.005467, -0.007468, 0.000002, 0.000001, 0.000001, 0.000007];
|
var win_analogInputsValues = [4.771072, 5.665244, 0.005467, -0.007468, 0.000002, 0.000001, 0.000001, 0.000007];
|
||||||
var win_analogInputsNames = ["AE5", "AE 2", "AE 3", "AE 4", "AE 5", "AE 6", "AE 7", "AE 8"];
|
var win_analogInputsNames = ["AE5", "AE 2", "AE 3", "AE 4", "AE 5", "AE 6", "AE 7", "AE 8"];
|
||||||
var win_analogInputsOffset = [5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
|
var win_analogInputsOffset = [11.001, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0.0];
|
||||||
var win_analogInputsFactor = [5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
|
var win_analogInputsFactor = [12.001, 1.0, 1.0, 1, 1.0, 1.0, 1.0, 1.0];
|
||||||
var win_analogInputsloggerIntervall = [5, 10, 10, 10, 10, 10, 10, 10];
|
var win_analogInputsloggerIntervall = [5, 10, 10, 10, 10, 10, 10, 10];
|
||||||
var win_analogInputsUnits = ["V", "V", "V", "V", "mA", "mA", "mA", "mA"];
|
var win_analogInputsUnits = ["V", "V", "V", "V", "mA", "mA", "mA", "mA"];
|
||||||
var win_analogInputsWeighting = [0, 0, 0, 0, 0, 0, 0, 0];
|
var win_analogInputsWeighting = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
|
|||||||
@@ -7,23 +7,37 @@ interface Props {
|
|||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function AnalogInputsSettingsModal({
|
export default function AnalogInputSettingsModal({
|
||||||
selectedInput,
|
selectedInput,
|
||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
const [offset, setOffset] = useState(0);
|
const [offset, setOffset] = useState("0.000000");
|
||||||
const [factor, setFactor] = useState(1);
|
const [factor, setFactor] = useState("1.000000");
|
||||||
const [loggerInterval, setLoggerInterval] = useState(10);
|
const [loggerInterval, setLoggerInterval] = useState("10");
|
||||||
|
const [unit, setUnit] = useState("V");
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedInput && isOpen) {
|
if (selectedInput && isOpen) {
|
||||||
setName(selectedInput.name || "");
|
setName(selectedInput.name || "");
|
||||||
setOffset(selectedInput.offset || 0);
|
setOffset(
|
||||||
setFactor(selectedInput.factor || 1);
|
typeof selectedInput.offset === "number"
|
||||||
setLoggerInterval(selectedInput.loggerInterval || 10);
|
? selectedInput.offset.toFixed(6)
|
||||||
|
: selectedInput.offset || "0.000000"
|
||||||
|
);
|
||||||
|
setFactor(
|
||||||
|
typeof selectedInput.factor === "number"
|
||||||
|
? selectedInput.factor.toFixed(6)
|
||||||
|
: selectedInput.factor || "1.000000"
|
||||||
|
);
|
||||||
|
setLoggerInterval(
|
||||||
|
selectedInput.loggerInterval !== undefined
|
||||||
|
? selectedInput.loggerInterval.toString()
|
||||||
|
: "10"
|
||||||
|
);
|
||||||
|
setUnit(selectedInput.unit || "V");
|
||||||
}
|
}
|
||||||
}, [selectedInput, isOpen]);
|
}, [selectedInput, isOpen]);
|
||||||
|
|
||||||
@@ -31,39 +45,46 @@ export default function AnalogInputsSettingsModal({
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
|
|
||||||
const slot = selectedInput.id;
|
const slot = selectedInput.id;
|
||||||
const isDev = window.location.hostname === "localhost";
|
const isDev = window.location.hostname === "localhost";
|
||||||
|
|
||||||
|
const offsetParam = offset.replace(",", ".");
|
||||||
|
const factorParam = factor.replace(",", ".");
|
||||||
|
const loggerParam = loggerInterval;
|
||||||
const acn = encodeURIComponent(name);
|
const acn = encodeURIComponent(name);
|
||||||
const offsetParam = offset.toString().replace(",", ".");
|
const acu = encodeURIComponent(unit);
|
||||||
const factorParam = factor.toString().replace(",", ".");
|
|
||||||
const loggerParam = loggerInterval.toString();
|
|
||||||
|
|
||||||
const url = `/CPL?/Service/ae.ACP&ACN${slot}=${acn}&ACO${slot}=${offsetParam}&ACF${slot}=${factorParam}&ACL${slot}=${loggerParam}`;
|
const url = `/CPL?/Service/ae.ACP&ACN${slot}=${acn}&ACO${slot}=${offsetParam}&ACF${slot}=${factorParam}&ACL${slot}=${loggerParam}&ACU${slot}=${acu}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
// Entwicklung: lokale Mock-API
|
|
||||||
await fetch("/api/cpl/updateAnalogInputsSettingsAPIHandler", {
|
await fetch("/api/cpl/updateAnalogInputsSettingsAPIHandler", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
updates: [
|
updates: [
|
||||||
{ key: "win_analogInputsNames", index: slot - 1, value: name },
|
{ key: "win_analogInputsNames", index: slot - 1, value: name },
|
||||||
{ key: "win_analogInputsOffset", index: slot - 1, value: offset },
|
{
|
||||||
{ key: "win_analogInputsFactor", index: slot - 1, value: factor },
|
key: "win_analogInputsOffset",
|
||||||
|
index: slot - 1,
|
||||||
|
value: parseFloat(offsetParam),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "win_analogInputsFactor",
|
||||||
|
index: slot - 1,
|
||||||
|
value: parseFloat(factorParam),
|
||||||
|
},
|
||||||
|
{ key: "win_analogInputsUnits", index: slot - 1, value: unit },
|
||||||
{
|
{
|
||||||
key: "win_analogInputsloggerIntervall",
|
key: "win_analogInputsloggerIntervall",
|
||||||
index: slot - 1,
|
index: slot - 1,
|
||||||
value: loggerInterval,
|
value: parseInt(loggerParam),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
alert("Mockdaten gespeichert.");
|
alert("Mockdaten gespeichert.");
|
||||||
} else {
|
} else {
|
||||||
// Produktion: direkter CGI-Befehl
|
|
||||||
const result = await fetch(url);
|
const result = await fetch(url);
|
||||||
if (!result.ok) throw new Error("Fehler bei CGI-Aufruf");
|
if (!result.ok) throw new Error("Fehler bei CGI-Aufruf");
|
||||||
alert("Einstellungen gespeichert (Produktion).");
|
alert("Einstellungen gespeichert (Produktion).");
|
||||||
@@ -97,19 +118,34 @@ export default function AnalogInputsSettingsModal({
|
|||||||
<label className="block mb-2 text-sm font-medium">Offset</label>
|
<label className="block mb-2 text-sm font-medium">Offset</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.000001"
|
||||||
className="w-full border rounded px-3 py-1 mb-4"
|
className="w-full border rounded px-3 py-1 mb-4"
|
||||||
value={offset}
|
value={offset}
|
||||||
onChange={(e) => setOffset(parseFloat(e.target.value))}
|
onChange={(e) => setOffset(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<label className="block mb-2 text-sm font-medium">Faktor</label>
|
<label className="block mb-2 text-sm font-medium">Faktor</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.000001"
|
||||||
className="w-full border rounded px-3 py-1 mb-4"
|
className="w-full border rounded px-3 py-1 mb-4"
|
||||||
value={factor}
|
value={factor}
|
||||||
onChange={(e) => setFactor(parseFloat(e.target.value))}
|
onChange={(e) => setFactor(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<label className="block mb-2 text-sm font-medium">Einheit</label>
|
||||||
|
<select
|
||||||
|
className="w-full border rounded px-3 py-1 mb-4"
|
||||||
|
value={unit}
|
||||||
|
onChange={(e) => setUnit(e.target.value)}
|
||||||
|
>
|
||||||
|
<option value="V">V</option>
|
||||||
|
<option value="mA">mA</option>
|
||||||
|
<option value="°C">°C</option>
|
||||||
|
<option value="bar">bar</option>
|
||||||
|
<option value="%">%</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
<label className="block mb-2 text-sm font-medium">
|
<label className="block mb-2 text-sm font-medium">
|
||||||
Loggerintervall (s)
|
Loggerintervall (s)
|
||||||
</label>
|
</label>
|
||||||
@@ -117,12 +153,13 @@ export default function AnalogInputsSettingsModal({
|
|||||||
type="number"
|
type="number"
|
||||||
className="w-full border rounded px-3 py-1 mb-4"
|
className="w-full border rounded px-3 py-1 mb-4"
|
||||||
value={loggerInterval}
|
value={loggerInterval}
|
||||||
onChange={(e) => setLoggerInterval(parseInt(e.target.value))}
|
onChange={(e) => setLoggerInterval(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="flex justify-end gap-2">
|
<div className="flex justify-end gap-2">
|
||||||
<button
|
<button
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
|
disabled={isSaving}
|
||||||
className="px-4 py-2 bg-gray-300 rounded hover:bg-gray-400"
|
className="px-4 py-2 bg-gray-300 rounded hover:bg-gray-400"
|
||||||
>
|
>
|
||||||
Abbrechen
|
Abbrechen
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export default function AnalogeEingaengeTable({
|
|||||||
<th className="border p-1 text-left">Eingang</th>
|
<th className="border p-1 text-left">Eingang</th>
|
||||||
<th className="border p-3 text-left">Messwert</th>
|
<th className="border p-3 text-left">Messwert</th>
|
||||||
<th className="border p-3 text-left">Bezeichnung</th>
|
<th className="border p-3 text-left">Bezeichnung</th>
|
||||||
|
<th className="border p-3 text-left">Einheit</th>
|
||||||
<th className="border p-3 text-left">Aktion</th>
|
<th className="border p-3 text-left">Aktion</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -61,6 +62,7 @@ export default function AnalogeEingaengeTable({
|
|||||||
>
|
>
|
||||||
{e.name || "----"}
|
{e.name || "----"}
|
||||||
</td>
|
</td>
|
||||||
|
<td className="border p-3">{e.unit || "-"}</td>
|
||||||
<td className="border p-3 text-center">
|
<td className="border p-3 text-center">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
const webVersion = "1.6.340";
|
const webVersion = "1.6.341";
|
||||||
export default webVersion;
|
export default webVersion;
|
||||||
|
|||||||
Reference in New Issue
Block a user