Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading with write conversion #1066

Merged
4 commits merged into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions autohotkey/config/tools/cmd_sequence/cmd_sequence.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Declare a custom export class
EXPORTER cmd_sequence_exporter.rb
52 changes: 52 additions & 0 deletions autohotkey/lib/cmd_sequence_exporter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

require 'cosmos'
require 'cosmos/ccsds/ccsds_packet'

module Cosmos
class CmdSequenceExporter
def initialize(parent)
@parent = parent
end

def export(filename, sequence_dir, sequence_list)
basename = File.basename(filename, ".*")
filename = Qt::FileDialog::getSaveFileName(@parent, # parent
'Export', # caption
sequence_dir + "/#{basename}.bin", # dir
'Sequence Binary (*.bin)') # filter
return if filename.nil? || filename.empty?

data = ''
sequence_list.each do |item|
begin
time = Time.parse(item.time)
day, ms, us = Time.mdy2ccsds(time.year, time.month, time.day, time.hour, time.min, time.sec, time.usec)
data << [day].pack("N") # UINT32
data << [ms].pack("N") # UINT32
rescue
time = item.time.to_f * 1000
data << [0].pack("N") # UINT32
data << [time].pack("N") # UINT32
end
data << item.command.buffer
end
ccsds = CcsdsPacket.new
ccsds.write("CCSDSTYPE", CcsdsPacket::COMMAND)
ccsds.write('CCSDSSHF', 0)
ccsds.write("CCSDSAPID", 505)
ccsds.write("CCSDSSEQFLAGS", CcsdsPacket::STANDALONE)
ccsds.write("CCSDSDATA", data)
ccsds.write("CCSDSLENGTH", data.length - 1)
File.open(filename, 'wb') { |file| file.write ccsds.buffer }
end
end
end
18 changes: 18 additions & 0 deletions autohotkey/tools/CmdSenderAHK2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env ruby
# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

require_relative 'autohotkey.rb'
autohotkey('CmdSender2', 'cmd_sender2.ahk') do
require 'cosmos/tools/cmd_sender/cmd_sender'
require 'cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui'
Cosmos::CmdSender.run
end

40 changes: 34 additions & 6 deletions autohotkey/tools/cmd_sender.ahk
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
SetWinDelay 1000
WinWaitActive Command Sender
Sleep 500
Click 85 100 ; Target dropdown
Sleep 500
Click 75 128 ; INST2
Sleep 500
Click 365 100 ; Command dropdown
Sleep 500
Click 365 140 ; ASCIICMD
Sleep 500
Click 600 100 ; Send
WinWaitActive Error ; Error connecting to CTS
Sleep 1000
Send {Enter}
WinWaitActive Command Sender
Run ruby.exe %A_ScriptDir%/CmdTlmServer
Sleep 4000
WinActivate Command Sender
Expand Down Expand Up @@ -34,6 +47,8 @@ WinWaitActive Command Sender
Sleep 500
Click 85 100 ; Target dropdown CMD-1
Sleep 500
Click 85 115 ; INST
Sleep 500
Click 610 100 ; Send CMD-2
Sleep 500
Click 365 100 ; Command dropdown CMD-1
Expand All @@ -45,6 +60,7 @@ Sleep 500
WinWaitActive Error
Sleep 500
Send {Enter}
WinWaitActive Command Sender
Click 240 210 ; Click in the TYPE parameter CMD-5
Sleep 500
Send 5{Enter}
Expand Down Expand Up @@ -135,15 +151,27 @@ Click 215 475 ; Select File
WinWaitActive Insert
Sleep 500
Send cmd.bin{Enter}
WinWaitActive Command Sender
Sleep 500
Click 85 100 ; Target dropdown
Sleep 500
Click 75 128 ; INST2
WinActivate Command Sender
Sleep 500
Click 365 100 ; Command dropdown
Click 70 70 ; Search box
Send I
Sleep 100
Send N
Sleep 100
Send S
Sleep 100
Send T
Sleep 100
Send 2
Sleep 100
Send {Space}
Sleep 100
Send C
Sleep 100
Send O
Sleep 500
Click 365 165 ; Collect command
Send {Enter}
Sleep 500
Click 180 390 ; Click on Type
Sleep 500
Expand Down
4 changes: 4 additions & 0 deletions autohotkey/tools/cmd_sender2.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SetWinDelay 1000
WinWaitActive Command Sender
Sleep 500
Send ^q
29 changes: 21 additions & 8 deletions autohotkey/tools/cmd_sequence.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,24 @@ Sleep 500
Send a ; Save As
WinWaitActive Save
Send test_sequence.txt{Enter}
Sleep 500
Send y ; Just in case test_sequence.txt already exists we say 'y' to overwrites
WinWaitActive Command Sequence

Send ^e ; Export
Sleep 500
WinWaitActive Export
Send sequence.bin{Enter}
Sleep 500
Send y ; Just in case sequence.bin already exists we say 'y' to overwrites
WinWaitActive Command Sequence

Send !a ; Actions menu
Sleep 500
Send e ; Expand All
Sleep 1000
Click 190 180 ; Click on sequence item to collapse it
Sleep 1000
Send !a ; Actions menu
Sleep 500
Send d ; Display state values in hex
Expand All @@ -57,28 +69,29 @@ Sleep 500
Send s ; Show ignored items
Sleep 500

Click right 170 355 ; Right click collect type
Click right 170 335 ; Right click collect type
Sleep 500
Send {Tab}{Enter}
WinWaitActive INST
Sleep 500
Send {Enter}
WinWaitActive Command Sequence

Click right 170 355 ; Right click collect type
Click right 170 335 ; Right click collect type
Sleep 500
Send {Tab 2}{Enter} ; Insert filename
WinWaitActive Insert
Sleep 500
Send {Esc}
WinWaitActive Command Sequence
Sleep 500
WinActivate Command Sequence ; Not sure why but we have to explicitly activate here

Click 260 355 2 ; Double click the collect type manual entry
Click 260 335 2 ; Double click the collect type manual entry
Sleep 500
Send 9{Enter}
Sleep 500

Click 170 355 2 ; Double click the collect Type
Click 170 335 2 ; Double click the collect Type
Sleep 500
Click ; Click again to activate the drop down
Sleep 500
Expand Down Expand Up @@ -129,11 +142,11 @@ Click 610 124 ; Add Abort command
Sleep 500
Click 610 124 ; Add Abort command
Sleep 500
Click 450 124 ; Click the command dropdown
Click 100 100 ; Click the search box
Sleep 500
Send {Down 2}{Enter} ; ASCIICMD
Send ASCIICMD
Sleep 500
Click 610 124 ; Add ASCIICMD
Send {Enter} ; Add ASCICMD
Sleep 500
Click 300 234 ; Click on the ASCIICMD to expand it
Sleep 500
Expand Down
2 changes: 1 addition & 1 deletion demo/config/targets/INST/cmd_tlm/inst_cmds.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ COMMAND INST SETPARAMS BIG_ENDIAN "Sets numbered parameters"

# New more flexible ERB syntax:
<% (1..5).each do |i| %>
APPEND_PARAMETER VALUE<%= i %> 16 UINT 0 5 0 "Value <%= i %> setting"
APPEND_PARAMETER VALUE<%= i %> 16 UINT 0 5 1 "Value <%= i %> setting"
<% end %>

SELECT_PARAMETER VALUE5
Expand Down
Loading