2 Commits

7 changed files with 135 additions and 74 deletions

View File

@@ -1 +1,42 @@
# TimeCrafters Configuration Tool for Desktop
A desktop app for editing, either locally or remotely, JSON configuration files on the Robot Controller/Rev Control Hub.
![Screenshot of Editor](https://raw.githubusercontent.com/TimeCrafters/timecrafters_configuration_tool_desktop/master/media/screenshots/screenshot_editor.png)
## Features
* TACNET - **T**imeCrafters **A**uxiliary **C**onfiguration **NET**work.
* Enables syncing configurations between devices.
* Multiple Configurations
* Create multiple configurations for specific robots/projects.
* Presets
* Save Groups or Actions as Presets to quickly add pre-configurated Groups and Actions.
* Search
* Search through the active configurations Groups, Actions, Variables and Presets.
* Built-in practice clock
* Supports multiple screens or network remote control.
* Supports official clock sounds (must be added manually.)
* Built-in jukebox.
* Simulator
* Create a simple 2D simulation of your robot's path.
* Field Planner
* Estimate distances on the field using imperial or metric units.
## Usage
* Download from [Releases](https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop/releases/latest)
## Developing
* Install [Ruby](https://ruby-lang.org)
* Run `bundle install`
* Run `bundle exec ruby timecrafters_configuration_tool.rb`
## Contributing
* Clone this repo and create a new branch for your feature/patch.
* Author your changes
* Commit your changes and push to your fork
* Open a pull request

View File

@@ -71,6 +71,10 @@ module TAC
end
end
def particle_count
@particles.size
end
def clock_active!
@clock_active = true
@particles.each(&:clock_active!)

View File

@@ -17,6 +17,7 @@ module TAC
@clock = Clock.new
@clock.controller = nil
@last_clock_display_value = @clock.value
@last_clock_title_value = @clock.title.text
@particle_emitters = [
PracticeGameClock::ParticleEmitter.new
@@ -72,17 +73,17 @@ module TAC
stack width: 0.4, padding_left: 50 do
background @menu_background
flow do
flow(width: 1.0) do
label "♫ Now playing:"
@current_song_label = label "♫ ♫ ♫"
end
flow do
flow(width: 1.0) do
label "Volume:"
@current_volume_label = label "100%"
end
flow do
flow(width: 1.0) do
button get_image("#{ROOT_PATH}/media/icons/previous.png") do
@jukebox.previous_track
end
@@ -137,7 +138,7 @@ module TAC
end
end
stack width: 1.0 do
stack(width: 1.0) do
button "Randomizer", width: 1.0, **TAC::THEME_DANGER_BUTTON do
unless @clock.active?
push_state(Randomizer)
@@ -195,11 +196,19 @@ module TAC
if @clock.value != @last_clock_display_value
@last_clock_display_value = @clock.value
request_repaint
if @remote_control_mode && @server.active_client
@server.active_client.puts(ClockNet::PacketHandler.packet_clock_time(@last_clock_display_value))
end
end
if @clock.title.text != @last_clock_title_value
@last_clock_title_value = @clock.title.text
request_repaint
end
if @last_track_name != @jukebox.current_track
track_changed(@jukebox.current_track)
end
@@ -213,6 +222,14 @@ module TAC
@last_clock_state = @clock.active?
end
def request_repaint
if @particle_emitters && @particle_emitters.map(&:particle_count).sum.positive?
true
else
super
end
end
def update_non_gui
if @remote_control_mode
while (o = RemoteControl.server.proxy_object.queue.shift)

View File

@@ -7,18 +7,20 @@ module TAC
header_bar("Drive Team Rotation Generator")
@roster ||= [
"Alexander",
"Aubrey",
"Cayden",
"Dan",
"Gabe",
"Spencer",
"Olivia"
"Sodi",
"Trent"
]
@roles ||= [
"Coach",
"Driver A",
"Driver B"
"Driver B",
"Human"
]
menu_bar.clear do
@@ -37,12 +39,12 @@ module TAC
body.clear do
flow(margin_left: 20, width: 1.0, height: 1.0) do
stack(width: 0.25) do
stack(width: 0.25, height: 1.0) do
title "Roles", width: 1.0, margin_bottom: 4, text_align: :center
flow(width: 1.0, margin_bottom: 20) do
@role_name = edit_line "", placeholder: "Add role", width: 0.9
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 0.1, tip: "Add role" do
flow(width: 1.0, height: 32, margin_bottom: 20) do
@role_name = edit_line "", placeholder: "Add role", fill: true, height: 1.0
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_height: 1.0, tip: "Add role" do
if @role_name.value.strip.length.positive?
@roles.push(@role_name.value.strip)
@role_name.value = ""
@@ -52,16 +54,16 @@ module TAC
end
end
@roles_container = stack(width: 1.0, height: 0.835, scroll: true) do
@roles_container = stack(width: 1.0, fill: true, scroll: true) do
end
end
stack(margin_left: 20, width: 0.25, height: 1.0) do
title "Roster", width: 1.0, margin_bottom: 4, text_align: :center
flow(width: 1.0, margin_bottom: 20) do
@roster_name = edit_line "", placeholder: "Add name", width: 0.9
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 0.1, tip: "Add name" do
flow(width: 1.0, height: 32, margin_bottom: 20) do
@roster_name = edit_line "", placeholder: "Add name", height: 1.0, fill: true
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_height: 1.0, tip: "Add name" do
if @roster_name.value.strip.length.positive?
@roster.push(@roster_name.value.strip)
@roster_name.value = ""
@@ -71,14 +73,14 @@ module TAC
end
end
@roster_container = stack(width: 1.0, height: 0.835, scroll: true) do
@roster_container = stack(width: 1.0, fill: true, scroll: true) do
end
end
stack(margin_left: 20, margin_right: 20, width: 0.5, height: 1.0) do
stack(margin_left: 20, margin_right: 20, fill: true, height: 1.0) do
title "Rotation", width: 1.0, margin_bottom: 4, text_align: :center
@rotation_container = stack(width: 1.0, height: 0.835, scroll: true) do
@rotation_container = stack(width: 1.0, fill: true, scroll: true) do
end
end
end
@@ -92,11 +94,11 @@ module TAC
def populate_roles
@roles_container.clear do
@roles.each_with_index do |name, i|
flow(width: 1.0, padding: 2) do
flow(width: 1.0, height: 32, padding: 2) do
background i.even? ? 0xff_007000 : 0xff_006000
tagline name, width: 0.9
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 0.1, tip: "Remove role", **THEME_DANGER_BUTTON do
tagline name, fill: true
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_height: 1.0, tip: "Remove role", **THEME_DANGER_BUTTON do
@roles.delete(name)
populate_roles
end
@@ -108,11 +110,11 @@ module TAC
def populate_roster
@roster_container.clear do
@roster.each_with_index do |name, i|
flow(width: 1.0, padding: 2) do
flow(width: 1.0, height: 32, padding: 2) do
background i.even? ? 0xff_007000 : 0xff_006000
tagline name, width: 0.9
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 0.1, tip: "Remove name", **THEME_DANGER_BUTTON do
tagline name, fill: true
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_height: 1.0, tip: "Remove name", **THEME_DANGER_BUTTON do
@roster.delete(name)
populate_roster
end
@@ -125,13 +127,11 @@ module TAC
@rotation = Generator.new(roster: @roster, team_size: @roles.count)
@rotation_container.clear do
fraction = (1.0 / @rotation.team_size) - 0.02
flow(width: 1.0, padding: 2) do
flow(width: 1.0, height: 32, padding: 2) do
background Gosu::Color::BLACK
@roles.each do |role|
tagline "<b>#{role}</b>", width: fraction
tagline "<b>#{role}</b>", fill: true
end
end
@@ -139,11 +139,11 @@ module TAC
teams = @rotation.teams.shuffle if @shuffle_teams&.value
teams.each_with_index do |team, i|
flow(width: 1.0, padding: 2) do
flow(width: 1.0, height: 32, padding: 2) do
background i.even? ? 0xff_007000 : 0xff_006000
team.each do |player|
tagline player, width: fraction
tagline player, fill: true
end
end
end

View File

@@ -1,6 +1,6 @@
module TAC
class TACNET
DEFAULT_HOSTNAME = "192.168.49.1"
DEFAULT_HOSTNAME = "192.168.49.1".freeze
DEFAULT_PORT = 8962
SYNC_INTERVAL = 250 # ms
@@ -30,7 +30,7 @@ module TAC
end
def full_status
_status = status.to_s.split("_").map { |c| c.capitalize }.join(" ")
_status = status.to_s.split("_").map(&:capitalize).join(" ")
if connected?
net_stats = ""
@@ -42,7 +42,7 @@ module TAC
"<b>Status:</b> #{_status}\n\n#{net_stats}"
elsif @connection&.client && @connection.client.socket_error?
"<b>Status:</b> #{_status}\n\n#{@connection.client.last_socket_error.to_s}"
"<b>Status:</b> #{_status}\n\n#{@connection.client.last_socket_error}"
else
"<b>Status:</b> #{_status}"
end
@@ -53,10 +53,10 @@ module TAC
end
def close
if connected?
@connection.close
@connection = nil
end
return unless connected?
@connection.close
@connection = nil
end
def client
@@ -75,4 +75,4 @@ module TAC
Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
end
end
end
end

View File

@@ -8,7 +8,9 @@ module TAC
attr_reader :uuid, :read_queue, :write_queue, :socket,
:packets_sent, :packets_received,
:data_sent, :data_received
attr_accessor :sync_interval, :last_socket_error, :socket_error
def initialize
@uuid = SecureRandom.uuid
@read_queue = []
@@ -20,8 +22,11 @@ module TAC
@socket_error = false
@bound = false
@packets_sent, @packets_received = 0, 0
@data_sent, @data_received = 0, 0
@packets_sent = 0
@packets_received = 0
@data_sent = 0
@data_received = 0
end
def uuid=(id)
@@ -39,17 +44,15 @@ module TAC
Thread.new do
while connected?
# Read from socket
while message_in = read
if message_in.empty?
break
else
log.i(TAG, "Read: " + message_in)
while (message_in = read)
break if message_in.empty?
@read_queue << message_in
log.i(TAG, "Read: #{message_in}")
@packets_received += 1
@data_received += message_in.length
end
@read_queue << message_in
@packets_received += 1
@data_received += message_in.length
end
sleep @sync_interval / 1000.0
@@ -59,12 +62,12 @@ module TAC
Thread.new do
while connected?
# Write to socket
while message_out = @write_queue.shift
while (message_out = @write_queue.shift)
write(message_out)
@packets_sent += 1
@data_sent += message_out.to_s.length
log.i(TAG, "Write: " + message_out.to_s)
log.i(TAG, "Write: #{message_out}")
end
sleep @sync_interval / 1000.0
@@ -82,7 +85,7 @@ module TAC
while message
puts(message)
log.i(TAG, "Writing to Queue: " + message)
log.i(TAG, "Writing to Queue: #{message}")
message = gets
end
@@ -101,34 +104,29 @@ module TAC
end
def closed?
@socket.closed? if @socket
@socket&.closed?
end
def write(message)
begin
@socket.puts("#{message}#{PACKET_TAIL}")
rescue => error
@last_socket_error = error
@socket_error = true
@socket.puts("#{message}#{PACKET_TAIL}") if connected?
rescue => error
@last_socket_error = error
@socket_error = true
log.e(TAG, error.message)
log.e(TAG, error.message)
close
end
close
end
def read
begin
@socket.gets&.strip
@socket&.gets&.strip if connected?
rescue => error
@last_socket_error = error
@socket_error = true
rescue => error
@last_socket_error = error
@socket_error = true
log.e(TAG, error.message)
log.e(TAG, error.message)
""
end
close
end
def puts(message)
@@ -140,11 +138,11 @@ module TAC
end
def encode(message)
return message
message
end
def decode(blob)
return blob
blob
end
def flush
@@ -153,8 +151,9 @@ module TAC
def close(reason = nil)
write(reason) if reason
@socket.close if @socket
@socket&.close
end
end
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB