improve a name

This commit is contained in:
torque 2024-07-11 16:32:53 -07:00
parent 011f300f0a
commit e5d8a716b0
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk
3 changed files with 14 additions and 14 deletions

View File

@ -1,6 +1,6 @@
const std = @import("std"); const std = @import("std");
const AzEl = @import("./LabjackYaesu.zig").AzEl; const AzEl = @import("./YaesuController.zig").AzEl;
const lj = @import("./labjack.zig"); const lj = @import("./labjack.zig");
const Config = @This(); const Config = @This();

View File

@ -2,7 +2,7 @@ const std = @import("std");
const Config = @import("./Config.zig"); const Config = @import("./Config.zig");
const config = Config.global; const config = Config.global;
const LabjackYaesu = @import("./LabjackYaesu.zig"); const YaesuController = @import("./YaesuController.zig");
const RotCtl = @This(); const RotCtl = @This();
@ -10,7 +10,7 @@ const log = std.log.scoped(.RotCtl);
writer: std.io.BufferedWriter(512, std.net.Stream.Writer), writer: std.io.BufferedWriter(512, std.net.Stream.Writer),
running: bool, running: bool,
rotator: LabjackYaesu, rotator: YaesuController,
pub fn run(allocator: std.mem.Allocator) !void { pub fn run(allocator: std.mem.Allocator) !void {
// var server = std.net.StreamServer.init(.{ .reuse_address = true }); // var server = std.net.StreamServer.init(.{ .reuse_address = true });
@ -30,7 +30,7 @@ pub fn run(allocator: std.mem.Allocator) !void {
var interface: RotCtl = .{ var interface: RotCtl = .{
.writer = undefined, .writer = undefined,
.running = true, .running = true,
.rotator = try LabjackYaesu.init(allocator), .rotator = try YaesuController.init(allocator),
}; };
while (true) { while (true) {

View File

@ -4,9 +4,9 @@ const lj = @import("./labjack.zig");
const Config = @import("./Config.zig"); const Config = @import("./Config.zig");
const config = Config.global; const config = Config.global;
const log = std.log.scoped(.labjack_yaesu); const log = std.log.scoped(.yaesu_controller);
const LabjackYaesu = @This(); const YaesuController = @This();
control_thread: std.Thread, control_thread: std.Thread,
lock: *std.Thread.Mutex, lock: *std.Thread.Mutex,
@ -17,7 +17,7 @@ pub const AzEl = struct {
elevation: f64, elevation: f64,
}; };
pub fn init(allocator: std.mem.Allocator) !LabjackYaesu { pub fn init(allocator: std.mem.Allocator) !YaesuController {
const lock = try allocator.create(std.Thread.Mutex); const lock = try allocator.create(std.Thread.Mutex);
errdefer allocator.destroy(lock); errdefer allocator.destroy(lock);
lock.* = .{}; lock.* = .{};
@ -56,7 +56,7 @@ fn inRange(request: f64, comptime dof: enum { azimuth, elevation }) bool {
}; };
} }
pub fn setTarget(self: LabjackYaesu, target: AzEl) error{OutOfRange}!void { pub fn setTarget(self: YaesuController, target: AzEl) error{OutOfRange}!void {
self.lock.lock(); self.lock.lock();
defer self.lock.unlock(); defer self.lock.unlock();
@ -76,14 +76,14 @@ pub fn setTarget(self: LabjackYaesu, target: AzEl) error{OutOfRange}!void {
controller.requested_state = .running; controller.requested_state = .running;
} }
pub fn currentPosition(self: LabjackYaesu) AzEl { pub fn currentPosition(self: YaesuController) AzEl {
self.lock.lock(); self.lock.lock();
defer self.lock.unlock(); defer self.lock.unlock();
return self.controller.position; return self.controller.position;
} }
pub fn startCalibration(self: LabjackYaesu) void { pub fn startCalibration(self: YaesuController) void {
// there are two different types of calibration: // there are two different types of calibration:
// 1. feedback calibration, running to the extents of the rotator // 1. feedback calibration, running to the extents of the rotator
// 2. sun calibration, which determines the azimuth and elevation angle // 2. sun calibration, which determines the azimuth and elevation angle
@ -95,7 +95,7 @@ pub fn startCalibration(self: LabjackYaesu) void {
_ = self; _ = self;
} }
pub fn quit(self: LabjackYaesu) void { pub fn quit(self: YaesuController) void {
self.lock.lock(); self.lock.lock();
defer self.lock.unlock(); defer self.lock.unlock();
@ -103,7 +103,7 @@ pub fn quit(self: LabjackYaesu) void {
controller.requested_state = .stopped; controller.requested_state = .stopped;
} }
pub fn stop(self: LabjackYaesu) void { pub fn stop(self: YaesuController) void {
self.lock.lock(); self.lock.lock();
defer self.lock.unlock(); defer self.lock.unlock();
@ -112,14 +112,14 @@ pub fn stop(self: LabjackYaesu) void {
controller.requested_state = .idle; controller.requested_state = .idle;
} }
pub fn startPark(self: LabjackYaesu) void { pub fn startPark(self: YaesuController) void {
self.setTarget(config.controller.parking_posture) catch unreachable; self.setTarget(config.controller.parking_posture) catch unreachable;
} }
fn runController(controller: *Controller) void { fn runController(controller: *Controller) void {
controller.run() catch { controller.run() catch {
log.err( log.err(
"the labjack control loop has terminated unexpectedly!!!!", "the rotator control loop has terminated unexpectedly!!!!",
.{}, .{},
); );
}; };