improve a name
This commit is contained in:
parent
011f300f0a
commit
e5d8a716b0
@ -1,6 +1,6 @@
|
||||
const std = @import("std");
|
||||
|
||||
const AzEl = @import("./LabjackYaesu.zig").AzEl;
|
||||
const AzEl = @import("./YaesuController.zig").AzEl;
|
||||
const lj = @import("./labjack.zig");
|
||||
|
||||
const Config = @This();
|
||||
|
@ -2,7 +2,7 @@ const std = @import("std");
|
||||
|
||||
const Config = @import("./Config.zig");
|
||||
const config = Config.global;
|
||||
const LabjackYaesu = @import("./LabjackYaesu.zig");
|
||||
const YaesuController = @import("./YaesuController.zig");
|
||||
|
||||
const RotCtl = @This();
|
||||
|
||||
@ -10,7 +10,7 @@ const log = std.log.scoped(.RotCtl);
|
||||
|
||||
writer: std.io.BufferedWriter(512, std.net.Stream.Writer),
|
||||
running: bool,
|
||||
rotator: LabjackYaesu,
|
||||
rotator: YaesuController,
|
||||
|
||||
pub fn run(allocator: std.mem.Allocator) !void {
|
||||
// var server = std.net.StreamServer.init(.{ .reuse_address = true });
|
||||
@ -30,7 +30,7 @@ pub fn run(allocator: std.mem.Allocator) !void {
|
||||
var interface: RotCtl = .{
|
||||
.writer = undefined,
|
||||
.running = true,
|
||||
.rotator = try LabjackYaesu.init(allocator),
|
||||
.rotator = try YaesuController.init(allocator),
|
||||
};
|
||||
|
||||
while (true) {
|
||||
|
@ -4,9 +4,9 @@ const lj = @import("./labjack.zig");
|
||||
const Config = @import("./Config.zig");
|
||||
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,
|
||||
lock: *std.Thread.Mutex,
|
||||
@ -17,7 +17,7 @@ pub const AzEl = struct {
|
||||
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);
|
||||
errdefer allocator.destroy(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();
|
||||
defer self.lock.unlock();
|
||||
|
||||
@ -76,14 +76,14 @@ pub fn setTarget(self: LabjackYaesu, target: AzEl) error{OutOfRange}!void {
|
||||
controller.requested_state = .running;
|
||||
}
|
||||
|
||||
pub fn currentPosition(self: LabjackYaesu) AzEl {
|
||||
pub fn currentPosition(self: YaesuController) AzEl {
|
||||
self.lock.lock();
|
||||
defer self.lock.unlock();
|
||||
|
||||
return self.controller.position;
|
||||
}
|
||||
|
||||
pub fn startCalibration(self: LabjackYaesu) void {
|
||||
pub fn startCalibration(self: YaesuController) void {
|
||||
// there are two different types of calibration:
|
||||
// 1. feedback calibration, running to the extents of the rotator
|
||||
// 2. sun calibration, which determines the azimuth and elevation angle
|
||||
@ -95,7 +95,7 @@ pub fn startCalibration(self: LabjackYaesu) void {
|
||||
_ = self;
|
||||
}
|
||||
|
||||
pub fn quit(self: LabjackYaesu) void {
|
||||
pub fn quit(self: YaesuController) void {
|
||||
self.lock.lock();
|
||||
defer self.lock.unlock();
|
||||
|
||||
@ -103,7 +103,7 @@ pub fn quit(self: LabjackYaesu) void {
|
||||
controller.requested_state = .stopped;
|
||||
}
|
||||
|
||||
pub fn stop(self: LabjackYaesu) void {
|
||||
pub fn stop(self: YaesuController) void {
|
||||
self.lock.lock();
|
||||
defer self.lock.unlock();
|
||||
|
||||
@ -112,14 +112,14 @@ pub fn stop(self: LabjackYaesu) void {
|
||||
controller.requested_state = .idle;
|
||||
}
|
||||
|
||||
pub fn startPark(self: LabjackYaesu) void {
|
||||
pub fn startPark(self: YaesuController) void {
|
||||
self.setTarget(config.controller.parking_posture) catch unreachable;
|
||||
}
|
||||
|
||||
fn runController(controller: *Controller) void {
|
||||
controller.run() catch {
|
||||
log.err(
|
||||
"the labjack control loop has terminated unexpectedly!!!!",
|
||||
"the rotator control loop has terminated unexpectedly!!!!",
|
||||
.{},
|
||||
);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user