mirror of
https://github.com/sergeyyarkov/modbus-logger.git
synced 2026-10-11 10:28:51 +03:00
removed is_logging column
This commit is contained in:
parent
3dd5ce81c9
commit
0252681847
@ -60,7 +60,7 @@ export const modbusController = {
|
|||||||
*/
|
*/
|
||||||
async createDevice(req, res, next) {
|
async createDevice(req, res, next) {
|
||||||
try {
|
try {
|
||||||
const { id, name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label, is_logging } =
|
const { id, name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label } =
|
||||||
req.body;
|
req.body;
|
||||||
await db.run(
|
await db.run(
|
||||||
`INSERT INTO "modbus_slaves" (
|
`INSERT INTO "modbus_slaves" (
|
||||||
@ -69,10 +69,9 @@ export const modbusController = {
|
|||||||
"g_display_reg_addr",
|
"g_display_reg_addr",
|
||||||
"g_display_reg_format",
|
"g_display_reg_format",
|
||||||
"g_display_reg_type",
|
"g_display_reg_type",
|
||||||
"g_y_label",
|
"g_y_label")
|
||||||
"is_logging")
|
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||||
[id, name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label, is_logging],
|
[id, name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label],
|
||||||
);
|
);
|
||||||
return res.status(200).json({ message: "Device created." });
|
return res.status(200).json({ message: "Device created." });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -4,7 +4,6 @@ SELECT
|
|||||||
g_display_reg_addr,
|
g_display_reg_addr,
|
||||||
g_display_reg_format,
|
g_display_reg_format,
|
||||||
g_y_label,
|
g_y_label,
|
||||||
is_logging,
|
|
||||||
CASE
|
CASE
|
||||||
WHEN COUNT(dv.id) = 0 THEN '[]'
|
WHEN COUNT(dv.id) = 0 THEN '[]'
|
||||||
ELSE '[' || GROUP_CONCAT(
|
ELSE '[' || GROUP_CONCAT(
|
||||||
|
|||||||
1
index.d.ts
vendored
1
index.d.ts
vendored
@ -30,7 +30,6 @@ export type ModbusDevice = {
|
|||||||
g_display_reg_format: NumberType | null;
|
g_display_reg_format: NumberType | null;
|
||||||
g_display_reg_type: "HR" | "IR";
|
g_display_reg_type: "HR" | "IR";
|
||||||
g_y_label: string | null;
|
g_y_label: string | null;
|
||||||
is_logging: boolean;
|
|
||||||
display_values?: DisplayValue[]
|
display_values?: DisplayValue[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,6 @@ CREATE TABLE IF NOT EXISTS "modbus_slaves" (
|
|||||||
"g_display_reg_type" VARCHAR(3) CHECK(g_display_reg_type IN("HR", "IR")) DEFAULT "IR",
|
"g_display_reg_type" VARCHAR(3) CHECK(g_display_reg_type IN("HR", "IR")) DEFAULT "IR",
|
||||||
"g_display_reg_format" VARCHAR(5) CHECK(g_display_reg_format IN("UI16", "I16", "UI32", "I32", "FP32")) DEFAULT "UI16",
|
"g_display_reg_format" VARCHAR(5) CHECK(g_display_reg_format IN("UI16", "I16", "UI32", "I32", "FP32")) DEFAULT "UI16",
|
||||||
"g_y_label" VARCHAR(40) DEFAULT "Label",
|
"g_y_label" VARCHAR(40) DEFAULT "Label",
|
||||||
"is_logging" BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
PRIMARY KEY("id")
|
PRIMARY KEY("id")
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -56,12 +55,12 @@ CREATE TABLE IF NOT EXISTS "display_values" (
|
|||||||
-- )
|
-- )
|
||||||
|
|
||||||
INSERT INTO "modbus_slaves" (
|
INSERT INTO "modbus_slaves" (
|
||||||
"id", "name", "g_display_reg_addr", "g_display_reg_type", "g_display_reg_format", "g_y_label", "is_logging"
|
"id", "name", "g_display_reg_addr", "g_display_reg_type", "g_display_reg_format", "g_y_label"
|
||||||
) VALUES
|
) VALUES
|
||||||
(1, "Device #1", 0, "IR", "UI16", "Label 1", 1),
|
(1, "Device #1", 0, "IR", "UI16", "Label 1"),
|
||||||
(2, "Device #2", 1, "IR", "UI32", "Label 2", 1),
|
(2, "Device #2", 1, "IR", "UI32", "Label 2"),
|
||||||
(3, "Device #3", 3, "IR", "UI16", "Label 3", 0),
|
(3, "Device #3", 3, "IR", "UI16", "Label 3"),
|
||||||
(4, "Device #4", NULL, NULL, NULL, "Label 4", 0);
|
(4, "Device #4", NULL, NULL, NULL, "Label 4");
|
||||||
|
|
||||||
INSERT INTO "display_values" (
|
INSERT INTO "display_values" (
|
||||||
"id", "name", "slave_id", "reg_addr", "reg_format", "reg_type"
|
"id", "name", "slave_id", "reg_addr", "reg_format", "reg_type"
|
||||||
|
|||||||
@ -66,7 +66,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<form @submit.prevent="create(() => graphView = 'none')" action="#">
|
<form @submit.prevent="create(() => graphView = 'none')" action="#">
|
||||||
<div
|
<div
|
||||||
x-id="['id', 'name', 'graph-display', 'g_display_reg_addr', 'g_display_reg_format', 'g_y_label', 'is_logging']"
|
x-id="['id', 'name', 'graph-display', 'g_display_reg_addr', 'g_display_reg_format', 'g_y_label']"
|
||||||
class="flex flex-col space-y-2"
|
class="flex flex-col space-y-2"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
@ -158,15 +158,6 @@
|
|||||||
<option value="FP32">Floating Point 32</option>
|
<option value="FP32">Floating Point 32</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<input
|
|
||||||
x-model="data.is_logging"
|
|
||||||
:id="$id('is_logging')"
|
|
||||||
name="is_logging"
|
|
||||||
type="checkbox"
|
|
||||||
/>
|
|
||||||
<label :for="$id('is_logging')">Logging</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@ -70,7 +70,6 @@ document.addEventListener("alpine:init", async () => {
|
|||||||
g_display_reg_format: "UI16",
|
g_display_reg_format: "UI16",
|
||||||
g_display_reg_type: "IR",
|
g_display_reg_type: "IR",
|
||||||
g_y_label: "",
|
g_y_label: "",
|
||||||
is_logging: false,
|
|
||||||
},
|
},
|
||||||
resetDataFields() {
|
resetDataFields() {
|
||||||
this.data.id = null;
|
this.data.id = null;
|
||||||
@ -79,7 +78,6 @@ document.addEventListener("alpine:init", async () => {
|
|||||||
this.data.g_display_reg_format = "UI16";
|
this.data.g_display_reg_format = "UI16";
|
||||||
this.g_display_reg_type = "IR";
|
this.g_display_reg_type = "IR";
|
||||||
this.data.g_y_label = "";
|
this.data.g_y_label = "";
|
||||||
this.data.is_logging = false;
|
|
||||||
},
|
},
|
||||||
async create(cb) {
|
async create(cb) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -123,7 +123,7 @@ export const modbusService = {
|
|||||||
async getDevices() {
|
async getDevices() {
|
||||||
/** @type {import("..").ModbusDevice[]} */
|
/** @type {import("..").ModbusDevice[]} */
|
||||||
const devices = await db.all(`
|
const devices = await db.all(`
|
||||||
SELECT ms.id AS id, ms.name AS name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label, is_logging,
|
SELECT ms.id AS id, ms.name AS name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label,
|
||||||
CASE
|
CASE
|
||||||
WHEN COUNT(dv.id) = 0 THEN '[]'
|
WHEN COUNT(dv.id) = 0 THEN '[]'
|
||||||
ELSE '[' || GROUP_CONCAT(
|
ELSE '[' || GROUP_CONCAT(
|
||||||
|
|||||||
@ -7,7 +7,6 @@ export const modbusDeviceSchema = object({
|
|||||||
g_display_reg_format: string().oneOf(["UI16", "I16", "UI32", "I32", "FP32"]).nullable(),
|
g_display_reg_format: string().oneOf(["UI16", "I16", "UI32", "I32", "FP32"]).nullable(),
|
||||||
g_display_reg_type: string().oneOf(["HR", "IR"]).nullable(),
|
g_display_reg_type: string().oneOf(["HR", "IR"]).nullable(),
|
||||||
g_y_label: string().max(40).nullable(),
|
g_y_label: string().max(40).nullable(),
|
||||||
is_logging: boolean().required()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const removeModbusDeviceSchema = modbusDeviceSchema.pick(['id']);
|
export const removeModbusDeviceSchema = modbusDeviceSchema.pick(['id']);
|
||||||
Loading…
x
Reference in New Issue
Block a user