Compare commits

..
7 changed files with 58 additions and 54 deletions

No files matched your search

Generated
+2 -1
View File
@@ -1680,10 +1680,11 @@ dependencies = [
[[package]]
name = "modbus"
version = "0.1.0"
source = "git+https://github.com/just-some-entity/modbus-rs.git#f1fff0ebd09334d6de29b2faa00336d031741dbb"
source = "git+https://github.com/just-some-entity/modbus-rs.git#07d0f3396a62cac23ca171e5a783c3c1616e9be8"
dependencies = [
"crc",
"heapless",
"libc",
"strum_macros 0.27.2",
]
@@ -10,7 +10,7 @@ import { Label } from "@/control/Label";
import { usePellet1 as usePellet1 } from "./usePelletizer";
import { SelectionGroupBoolean } from "@/control/SelectionGroup";
import { SelectionGroup, SelectionGroupBoolean } from "@/control/SelectionGroup";
import { createTimeSeries, TimeSeries } from "@/lib/timeseries";
import { roundToDecimals } from "@/lib/decimal";
import { Badge } from "@/components/ui/badge";
@@ -48,31 +48,62 @@ export function Pellet1ControlPage() {
return (
<Page>
<ControlGrid columns={2}>
<ControlCard title="Motor Configuration">
<SelectionGroupBoolean
value={running}
optionTrue={{ children: "On" }}
optionFalse={{ children: "Off" }}
onChange={(v) => {
SetRunning(v)
<ControlCard title="Motor">
<SelectionGroup<"Off" | "On">
value={running ? "On" : "Off"}
orientation="vertical"
className="grid grid-cols-2 gap-2"
options={{
Off: {
children: "Off",
icon: "lu:CirclePause",
isActiveClassName: "bg-red-600",
className: "h-full",
},
On: {
children: "On",
icon: "lu:CirclePlay",
isActiveClassName: "bg-green-600",
className: "h-full",
},
}}
onChange={(v) => SetRunning(v == "On")}
/>
<Label label="Speed">
<EditValue
title="Speed"
value={frequency_target * 2}
unit="%"
step={0.5}
min={0}
max={100}
renderValue={(value) => value.toFixed(1)}
onChange={(val) => {
SetFrequencyTarget(val / 2);
}}
defaultValue={5}
/>
<div className="flex flex-row flex-wrap gap-4">
<EditValue
title="Speed"
value={frequency_target / 14.3}
unit="rpm"
step={0.1}
min={0}
max={3.5}
renderValue={(value) => value.toFixed(1)}
onChange={(val) => {
SetFrequencyTarget(val * 14.3);
}}
defaultValue={2}
/>
<EditValue
h-full v-full
title="Speed"
value={frequency_target * 2}
unit="%"
step={0.5}
min={0}
max={100}
renderValue={(value) => value.toFixed(1)}
onChange={(val) => {
SetFrequencyTarget(val / 2);
}}
defaultValue={5}
/>
</div>
</Label>
</ControlCard>
<ControlCard title="Inverter Status">
+1 -1
View File
@@ -32,7 +32,7 @@ tracing = { version = "0.1.44", features = ["attributes"] }
tonic = { version = "0.13.1", optional = true }
# modbus interfaces
modbus = { git = "https://github.com/just-some-entity/modbus-rs.git" }
modbus = { git = "https://github.com/just-some-entity/modbus-rs.git", features = ["linux-rtu-transport"] }
# enum stuff
strum = "0.26"
+1 -15
View File
@@ -32,49 +32,35 @@ impl MachineAct for Pelletizer
if let Some(value) = self.mutation_request.running.take()
{
tracing::warn!("Setting running to: {}", value);
inverter.set_running(value);
mutated = true;
}
if let Some(value) = self.mutation_request.direction.take()
{
tracing::warn!("Setting direction to: {}", value);
inverter.set_direction(value);
mutated = true;
}
if let Some(value) = self.mutation_request.frequency.take()
{
tracing::warn!("Setting to: {}", value);
inverter.set_frequency_target((value * 10.0) as u16);
mutated = true;
}
if let Some(value) = self.mutation_request.accleration_level.take()
{
tracing::warn!("Setting to: {}", value);
inverter.set_acceleration_level(value);
mutated = true;
}
if let Some(value) = self.mutation_request.decleration_level.take()
{
tracing::warn!("Setting to: {}", value);
inverter.set_deceleration_level(value);
mutated = true;
}
if should_emit {
inverter.refresh_status();
}
if should_emit { inverter.refresh_status(); }
if mutated { }
-2
View File
@@ -92,8 +92,6 @@ impl MachineApi for Pelletizer {
fn api_mutate(&mut self, request_body: Value) -> Result<(), anyhow::Error>
{
tracing::error!("Received: {:?}", &request_body);
let mutation: Mutation = serde_json::from_value(request_body)?;
match mutation
+1 -3
View File
@@ -27,9 +27,7 @@ impl Pelletizer
let inverter = smol::block_on(async {
self.inverter.read().await
});
tracing::error!("EMIT STATE: {:?}", inverter.config);
StateEvent
{
is_default_state: !self.emitted_default_state,
+1 -11
View File
@@ -108,10 +108,7 @@ impl US3202510
{
match self.interface.dispatch_next_request()
{
Ok(_) =>
{
tracing::error!("Success sending request: {:?}", self.interface);
},
Ok(_) => {},
Err(e) =>
{
match e
@@ -163,8 +160,6 @@ impl US3202510
{
if self.config.running == running { return; }
tracing::error!("Setting running to: {}", running);
match running
{
true =>
@@ -189,9 +184,6 @@ impl US3202510
{
let value: u16 = if direction { 1 } else { 3 };
tracing::error!("Setting direction to: {}", value);
self.queue_request(Request::SetRotationState(value));
}
@@ -222,8 +214,6 @@ impl US3202510
{
RequestResult::ReadHoldingRegisters(data) =>
{
tracing::error!("BRANCH: HIT: {:?}", data);
let frequency_target: u16 =
*data.result.get(0)
.unwrap_or(&0);