hardsploit_gui 2.2 → 2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/hardsploit_gui +2 -2
- data/lib/{Firmware → Firmwares}/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd +0 -0
- data/lib/{Firmware/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd → Firmwares/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd} +0 -0
- data/lib/Firmwares/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd +0 -0
- data/lib/{Firmware/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd → Firmwares/FPGA/SPI/SPI_SNIFFER/HARDSPLOIT_FIRMWARE_FPGA_SPI_SNIFFER.rpd} +0 -0
- data/lib/Firmwares/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd +0 -0
- data/lib/{Firmware → Firmwares}/FPGA/TEST/TEST_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_TEST_INTERACT.rpd +0 -0
- data/lib/Firmwares/FPGA/UART/UART_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_UART_INTERACT.rpd +0 -0
- data/lib/{Firmware → Firmwares}/FPGA/VersionFPGA.rb +1 -1
- data/lib/{Firmware → Firmwares}/UC/HARDSPLOIT_FIRMWARE_UC.bin +0 -0
- data/lib/{Firmware → Firmwares}/UC/VersionUC.rb +1 -1
- data/lib/HardsploitAPI/Core/HardsploitAPI.rb +210 -0
- data/lib/HardsploitAPI/Core/HardsploitAPI_CONSTANT.rb +150 -0
- data/lib/HardsploitAPI/Core/HardsploitAPI_ERROR.rb +109 -0
- data/lib/HardsploitAPI/Core/HardsploitAPI_FIRMWARE.rb +305 -0
- data/lib/HardsploitAPI/{HardsploitAPI_PROGRESS.rb → Core/HardsploitAPI_PROGRESS.rb} +0 -0
- data/lib/HardsploitAPI/Core/HardsploitAPI_USB_COMMUNICATION.rb +166 -0
- data/lib/HardsploitAPI/Modules/I2C/HardsploitAPI_I2C.rb +356 -0
- data/lib/HardsploitAPI/{HardsploitAPI_NO_MUX_PARALLELE_MEMORY.rb → Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY.rb} +26 -49
- data/lib/HardsploitAPI/Modules/NRF24L01/HardsploitAPI_NRF24L01.rb +306 -0
- data/lib/HardsploitAPI/Modules/SPI/HardsploitAPI_SPI.rb +340 -0
- data/lib/HardsploitAPI/Modules/SPI_SNIFFER/HardsploitAPI_SPI_SNIFFER.rb +83 -0
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD.rb +367 -0
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_DEBUG.rb +89 -0
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb +61 -0
- data/lib/HardsploitAPI/{SWD → Modules/SWD}/HardsploitAPI_SWD_STM32.rb +32 -15
- data/lib/HardsploitAPI/{HardsploitAPI_TEST_INTERACT.rb → Modules/TEST/HardsploitAPI_TEST_INTERACT.rb} +1 -1
- data/lib/HardsploitAPI/Modules/UART/HardsploitAPI_UART.rb +196 -0
- data/lib/Hardsploit_gui.rb +96 -0
- data/lib/class/Chip_editor.rb +186 -330
- data/lib/class/Chip_management.rb +496 -0
- data/lib/class/Command_editor.rb +130 -182
- data/lib/class/Command_table.rb +16 -22
- data/lib/class/Console.rb +0 -2
- data/lib/class/ErrorMsg.rb +312 -0
- data/lib/class/Export.rb +140 -0
- data/lib/class/Export_manager.rb +43 -43
- data/lib/class/Firmware.rb +52 -11
- data/lib/class/Generic_commands.rb +180 -190
- data/lib/class/Import.rb +193 -0
- data/lib/class/Progress_bar.rb +1 -0
- data/lib/class/Signal_mapper.rb +120 -0
- data/lib/class/Wire_helper.rb +132 -148
- data/lib/class/{I2C → i2c}/I2c_command.rb +16 -13
- data/lib/class/i2c/I2c_export.rb +95 -0
- data/lib/class/i2c/I2c_import.rb +117 -0
- data/lib/class/i2c/I2c_scanner.rb +114 -0
- data/lib/class/i2c/I2c_settings.rb +148 -0
- data/lib/class/parallel/Parallel_export.rb +118 -0
- data/lib/class/parallel/Parallel_import.rb +113 -0
- data/lib/class/parallel/Parallel_settings.rb +81 -0
- data/lib/class/spi/Spi_export.rb +108 -0
- data/lib/class/spi/Spi_import.rb +159 -0
- data/lib/class/spi/Spi_settings.rb +108 -0
- data/lib/class/spi/Spi_sniffer.rb +101 -0
- data/lib/class/swd/Swd.rb +125 -0
- data/lib/class/swd/Swd_scanner.rb +121 -0
- data/lib/class/swd/Swd_settings.rb +76 -0
- data/lib/class/uart/Uart_baudrate.rb +62 -0
- data/lib/class/uart/Uart_console.rb +115 -0
- data/lib/class/uart/Uart_settings.rb +102 -0
- data/lib/db/associations.rb +42 -29
- data/lib/db/database.rb +4 -0
- data/lib/db/development.sqlite3 +0 -0
- data/lib/db/migrate/004_create_manufacturers.rb +13 -0
- data/lib/db/migrate/005_create_packages.rb +13 -0
- data/lib/db/migrate/006_create_chip_types.rb +11 -0
- data/lib/db/migrate/007_create_buses.rb +11 -0
- data/lib/db/migrate/008_create_signals.rb +14 -0
- data/lib/db/migrate/009_create_chips.rb +25 -0
- data/lib/db/migrate/010_create_commands.rb +21 -0
- data/lib/db/migrate/011_create_bytes.rb +19 -0
- data/lib/db/migrate/012_create_i2c_settings.rb +21 -0
- data/lib/db/migrate/013_create_spi_settings.rb +26 -0
- data/lib/db/migrate/014_create_parallel_settings.rb +21 -0
- data/lib/db/migrate/015_create_pins.rb +19 -0
- data/lib/db/migrate/016_create_uses.rb +17 -0
- data/lib/db/migrate/017_create_swd_settings.rb +19 -0
- data/lib/db/migrate/018_create_uart_settings.rb +22 -0
- data/lib/db/schema.rb +157 -0
- data/lib/db/seeds.rb +161 -0
- data/lib/gui/gui_chip_editor.rb +23 -22
- data/lib/gui/gui_chip_management.rb +43 -38
- data/lib/gui/gui_command_editor.rb +2 -1
- data/lib/gui/gui_export.rb +132 -0
- data/lib/gui/gui_generic_commands.rb +69 -31
- data/lib/gui/gui_generic_export.rb +18 -2
- data/lib/gui/gui_generic_import.rb +18 -2
- data/lib/gui/gui_i2c_command.rb +2 -1
- data/lib/gui/gui_i2c_settings.rb +2 -2
- data/lib/gui/gui_import.rb +131 -0
- data/lib/gui/gui_parallel_settings.rb +2 -1
- data/lib/gui/gui_progress_bar.rb +2 -1
- data/lib/gui/gui_signal_mapper.rb +121 -0
- data/lib/gui/gui_signal_scanner.rb +146 -0
- data/lib/gui/gui_spi_settings.rb +6 -2
- data/lib/gui/gui_spi_sniffer.rb +112 -0
- data/lib/gui/gui_swd_settings.rb +166 -0
- data/lib/gui/gui_uart_baudrate.rb +114 -0
- data/lib/gui/gui_uart_console.rb +164 -0
- data/lib/gui/gui_uart_settings.rb +243 -0
- data/lib/gui_designer/gui_chip_editor.ui +9 -6
- data/lib/gui_designer/gui_chip_management.ui +79 -35
- data/lib/gui_designer/gui_command_editor.ui +3 -0
- data/lib/gui_designer/gui_export.ui +171 -0
- data/lib/gui_designer/gui_generic_commands.ui +274 -190
- data/lib/gui_designer/gui_generic_export.ui +24 -1
- data/lib/gui_designer/gui_generic_import.ui +25 -2
- data/lib/gui_designer/gui_i2c_command.ui +3 -0
- data/lib/gui_designer/gui_i2c_settings.ui +2 -2
- data/lib/gui_designer/gui_import.ui +168 -0
- data/lib/gui_designer/gui_parallel_settings.ui +4 -1
- data/lib/gui_designer/gui_progress_bar.ui +3 -0
- data/lib/gui_designer/gui_signal_mapper.ui +179 -0
- data/lib/gui_designer/gui_signal_scanner.ui +261 -0
- data/lib/gui_designer/gui_spi_settings.ui +15 -2
- data/lib/gui_designer/gui_spi_sniffer.ui +156 -0
- data/lib/gui_designer/gui_swd_settings.ui +189 -0
- data/lib/gui_designer/gui_uart_baudrate.ui +161 -0
- data/lib/gui_designer/gui_uart_console.ui +284 -0
- data/lib/gui_designer/gui_uart_settings.ui +280 -0
- data/lib/logs/error.log +63 -0
- data/lib/models/bus.rb +19 -0
- data/lib/models/byte.rb +29 -0
- data/lib/models/chip.rb +41 -0
- data/lib/models/chip_type.rb +14 -0
- data/lib/models/command.rb +20 -0
- data/lib/models/i2c_setting.rb +41 -0
- data/lib/models/manufacturer.rb +14 -0
- data/lib/models/package.rb +26 -0
- data/lib/models/parallel_setting.rb +37 -0
- data/lib/models/pin.rb +14 -0
- data/lib/models/signall.rb +20 -0
- data/lib/models/spi_setting.rb +67 -0
- data/lib/models/swd_setting.rb +25 -0
- data/lib/models/uart_setting.rb +52 -0
- data/lib/models/use.rb +6 -0
- data/lib/startHardsploit.rb +2 -2
- metadata +106 -41
- data/lib/Firmware/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd +0 -0
- data/lib/HardsploitAPI/HardsploitAPI.rb +0 -133
- data/lib/HardsploitAPI/HardsploitAPI_CONSTANT.rb +0 -145
- data/lib/HardsploitAPI/HardsploitAPI_ERROR.rb +0 -38
- data/lib/HardsploitAPI/HardsploitAPI_FIRMWARE.rb +0 -311
- data/lib/HardsploitAPI/HardsploitAPI_I2C.rb +0 -360
- data/lib/HardsploitAPI/HardsploitAPI_SPI.rb +0 -369
- data/lib/HardsploitAPI/HardsploitAPI_USB_COMMUNICATION.rb +0 -148
- data/lib/HardsploitAPI/LICENSE.txt +0 -674
- data/lib/HardsploitAPI/README.md +0 -22
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD.rb +0 -249
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_DEBUG.rb +0 -102
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_MEM_AP.rb +0 -78
- data/lib/HardsploitAPI/TRADEMARK +0 -3
- data/lib/class/HardsploitGUI.rb +0 -463
- data/lib/class/I2C/I2c_export.rb +0 -118
- data/lib/class/I2C/I2c_import.rb +0 -79
- data/lib/class/I2C/I2c_settings.rb +0 -129
- data/lib/class/PARALLEL/Parallel_export.rb +0 -146
- data/lib/class/PARALLEL/Parallel_import.rb +0 -88
- data/lib/class/PARALLEL/Parallel_settings.rb +0 -102
- data/lib/class/SPI/Spi_export.rb +0 -138
- data/lib/class/SPI/Spi_import.rb +0 -113
- data/lib/class/SPI/Spi_settings.rb +0 -134
- data/lib/db/hs.db +0 -0
- data/lib/hardsploit.rb +0 -131
@@ -0,0 +1,96 @@
|
|
1
|
+
#===================================================
|
2
|
+
# Hardsploit GUI - By Opale Security
|
3
|
+
# www.opale-security.com || www.hardsploit.io
|
4
|
+
# License: GNU General Public License v3
|
5
|
+
# License URI: http://www.gnu.org/licenses/gpl.txt
|
6
|
+
#===================================================
|
7
|
+
|
8
|
+
require 'Qt4'
|
9
|
+
require 'sqlite3'
|
10
|
+
require 'active_record'
|
11
|
+
require_relative 'db/database.rb'
|
12
|
+
require_relative 'gui/gui_chip_management'
|
13
|
+
require_relative 'class/Chip_management'
|
14
|
+
require_relative 'HardsploitAPI/Core/HardsploitAPI'
|
15
|
+
require_relative 'Firmwares/UC/VersionUC'
|
16
|
+
require_relative 'Firmwares/FPGA/VersionFPGA'
|
17
|
+
include VersionFPGA::VERSION_FPGA
|
18
|
+
include VersionUC::VERSION_UC
|
19
|
+
|
20
|
+
class Hardsploit_gui
|
21
|
+
VERSION = "2.3"
|
22
|
+
def initialize
|
23
|
+
HardsploitAPI.callbackInfo = method(:callbackInfo)
|
24
|
+
HardsploitAPI.callbackData = method(:callbackData)
|
25
|
+
HardsploitAPI.callbackSpeedOfTransfert = method(:callbackSpeedOfTransfert)
|
26
|
+
HardsploitAPI.callbackProgress = method(:callbackProgress)
|
27
|
+
$file = nil
|
28
|
+
$currentFirmware = nil
|
29
|
+
$logFilePath = File.expand_path(File.dirname(__FILE__)) + "/logs/error.log"
|
30
|
+
$dbFilePath = File.expand_path(File.dirname(__FILE__)) + "/db/hs.db"
|
31
|
+
# Launch GUI
|
32
|
+
Qt::Application.new(ARGV) do
|
33
|
+
$app = self
|
34
|
+
w = Chip_management.new(VERSION)
|
35
|
+
centerWindow(w)
|
36
|
+
w.show
|
37
|
+
exec
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def callbackInfo(receiveData)
|
42
|
+
print receiveData + "\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
def callbackProgress(percent:, startTime:, endTime:)
|
46
|
+
print "\r\e[#{31}mIn progress : #{percent}%\e[0m"
|
47
|
+
$pgb.update_value(percent) unless $pgb.nil?
|
48
|
+
if percent == 100
|
49
|
+
duration = (endTime-startTime).round(2)
|
50
|
+
$pgb.display_time("Total duration: #{duration} second(s)")
|
51
|
+
end
|
52
|
+
$app.processEvents
|
53
|
+
end
|
54
|
+
|
55
|
+
def callbackSpeedOfTransfert(receiveData)
|
56
|
+
#puts receiveData
|
57
|
+
end
|
58
|
+
|
59
|
+
def callbackData(receiveData)
|
60
|
+
$file.write(receiveData.pack('C*'))
|
61
|
+
end
|
62
|
+
|
63
|
+
def check_ReceivedData
|
64
|
+
result = HardsploitAPI.receiveDATA(2000)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def check_for_errors(result)
|
69
|
+
return false if result.errors.messages.empty?
|
70
|
+
error_message = ""
|
71
|
+
result.errors.messages.each do |msg|
|
72
|
+
error_message << "Error: #{msg[0]} #{msg[1][0]}\n"
|
73
|
+
end
|
74
|
+
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Warning', error_message).exec
|
75
|
+
return true
|
76
|
+
end
|
77
|
+
|
78
|
+
def inputRestrict(lineEdit, type)
|
79
|
+
case type
|
80
|
+
when 0 ; reg = Qt::RegExp.new("[0-9]+")
|
81
|
+
when 1 ; reg = Qt::RegExp.new("^[a-zA-Z_@-]+( [a-zA-Z_@-]+)*$")
|
82
|
+
when 2 ; reg = Qt::RegExp.new("^[a-zA-Z0-9_@-]+( [a-zA-Z0-9_@-]+)*$")
|
83
|
+
when 3 ; reg = Qt::RegExp.new("^[A-Fa-f0-9]{2}")
|
84
|
+
when 4 ; reg = Qt::RegExp.new("^[A-Fa-f0-9]{8}")
|
85
|
+
end
|
86
|
+
regVal = Qt::RegExpValidator.new(reg, self)
|
87
|
+
lineEdit.setValidator(regVal)
|
88
|
+
end
|
89
|
+
|
90
|
+
def centerWindow(win)
|
91
|
+
desktop = Qt::DesktopWidget.new
|
92
|
+
rect = desktop.screenGeometry(desktop.primaryScreen)
|
93
|
+
centerX = (rect.width - win.width ) / 2
|
94
|
+
centerY = (rect.height - win.height) / 2
|
95
|
+
win.move(centerX,centerY)
|
96
|
+
end
|
data/lib/class/Chip_editor.rb
CHANGED
@@ -18,431 +18,287 @@ class Chip_editor < Qt::Widget
|
|
18
18
|
|
19
19
|
def initialize(parent, chip, action)
|
20
20
|
super()
|
21
|
-
@
|
21
|
+
@view = Ui_Chip_editor.new
|
22
22
|
centerWindow(self)
|
23
|
-
@
|
23
|
+
@view.setupUi(self)
|
24
24
|
@parent = parent
|
25
25
|
@chip = chip
|
26
26
|
|
27
|
-
inputRestrict(@
|
28
|
-
inputRestrict(@
|
29
|
-
inputRestrict(@
|
30
|
-
inputRestrict(@
|
31
|
-
inputRestrict(@
|
32
|
-
inputRestrict(@
|
27
|
+
inputRestrict(@view.lie_pack_name, 2)
|
28
|
+
inputRestrict(@view.lie_pack_pin, 0)
|
29
|
+
inputRestrict(@view.lie_manu_name, 2)
|
30
|
+
inputRestrict(@view.lie_type_name, 2)
|
31
|
+
inputRestrict(@view.lie_reference, 2)
|
32
|
+
inputRestrict(@view.lie_description, 2)
|
33
33
|
|
34
34
|
# Combobox
|
35
|
-
|
36
|
-
|
37
|
-
package.each do |p|
|
38
|
-
@gui_chip_editor.cbx_package.addItem(p.package_name)
|
35
|
+
Package.all.each do |p|
|
36
|
+
@view.cbx_package.addItem(p.name)
|
39
37
|
end
|
40
|
-
|
41
|
-
|
42
|
-
manufacturer.each do |p|
|
43
|
-
@gui_chip_editor.cbx_manufacturer.addItem(p.manufacturer_name)
|
38
|
+
Manufacturer.all.each do |m|
|
39
|
+
@view.cbx_manufacturer.addItem(m.name)
|
44
40
|
end
|
45
|
-
|
46
|
-
|
47
|
-
c_type.each do |p|
|
48
|
-
@gui_chip_editor.cbx_type.addItem(p.cType_name)
|
41
|
+
ChipType.all.each do |c|
|
42
|
+
@view.cbx_type.addItem(c.name)
|
49
43
|
end
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
@
|
60
|
-
@
|
61
|
-
@
|
62
|
-
@
|
63
|
-
@
|
64
|
-
@
|
65
|
-
@
|
66
|
-
@
|
67
|
-
@
|
68
|
-
@
|
69
|
-
@gui_chip_editor.rbn_square.setEnabled(false)
|
70
|
-
if @chip.chip_voltage.zero?
|
71
|
-
@gui_chip_editor.rbn_5v.setChecked(true)
|
72
|
-
else
|
73
|
-
@gui_chip_editor.rbn_3v.setChecked(true)
|
74
|
-
end
|
75
|
-
package_shape = Package.find_by(package_id: @chip.chip_package).package_shape
|
76
|
-
if package_shape.zero?
|
77
|
-
@gui_chip_editor.rbn_square.setChecked(true)
|
78
|
-
else
|
79
|
-
@gui_chip_editor.rbn_rectangular.setChecked(true)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Line Edit
|
83
|
-
# Name
|
84
|
-
if action == 'edit'
|
85
|
-
@gui_chip_editor.lie_reference.setText(@chip.chip_reference)
|
86
|
-
end
|
87
|
-
# Load pin array
|
45
|
+
unless action == 'new'
|
46
|
+
package_name = chip.package.name
|
47
|
+
manufacturer_name = chip.manufacturer.name
|
48
|
+
chip_type_name = chip.chip_type.name
|
49
|
+
@view.cbx_package.setCurrentIndex(@view.cbx_package.findText(package_name))
|
50
|
+
@view.lie_pack_name.setText(package_name)
|
51
|
+
@view.lie_pack_name.setEnabled(false)
|
52
|
+
@view.cbx_manufacturer.setCurrentIndex(@view.cbx_manufacturer.findText(manufacturer_name))
|
53
|
+
@view.lie_manu_name.setText(manufacturer_name)
|
54
|
+
@view.lie_manu_name.setEnabled(false)
|
55
|
+
@view.cbx_type.setCurrentIndex(@view.cbx_type.findText(chip_type_name))
|
56
|
+
@view.lie_type_name.setText(chip_type_name)
|
57
|
+
@view.lie_type_name.setEnabled(false)
|
58
|
+
@view.rbn_rectangular.setEnabled(false)
|
59
|
+
@view.rbn_square.setEnabled(false)
|
60
|
+
chip.voltage.zero? ? @view.rbn_5v.setChecked(true) : @view.rbn_3v.setChecked(true)
|
61
|
+
chip.package.shape.zero? ? @view.rbn_square.setChecked(true) : @view.rbn_rectangular.setChecked(true)
|
62
|
+
@view.lie_reference.setText(@chip.reference) if action == 'edit'
|
88
63
|
fill_pin_table('edit')
|
89
|
-
|
90
|
-
@gui_chip_editor.lie_description.setText(@chip.chip_detail)
|
64
|
+
@view.lie_description.setText(@chip.description)
|
91
65
|
end
|
92
66
|
|
93
67
|
# Array struct
|
94
|
-
@
|
95
|
-
@
|
68
|
+
@view.tbl_pins.horizontalHeader.stretchLastSection = true
|
69
|
+
@view.tbl_pins.verticalHeader.setVisible(false)
|
96
70
|
|
97
71
|
# Button text
|
98
72
|
if action == 'edit'
|
99
|
-
@
|
100
|
-
Qt::Object.connect(@
|
73
|
+
@view.btn_add.setText('Edit')
|
74
|
+
Qt::Object.connect(@view.btn_add, SIGNAL('clicked()'), self, SLOT('edit_chip()'))
|
101
75
|
else
|
102
|
-
@
|
103
|
-
Qt::Object.connect(@
|
76
|
+
@view.btn_add.setText('Add')
|
77
|
+
Qt::Object.connect(@view.btn_add, SIGNAL('clicked()'), self, SLOT('add_chip()'))
|
104
78
|
end
|
105
79
|
rescue Exception => msg
|
106
|
-
|
107
|
-
logger.error msg
|
108
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured when opening the chip wizard interface. Consult the log for more details').exec
|
80
|
+
ErrorMsg.new.unknown(msg)
|
109
81
|
end
|
110
82
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
# Package
|
115
|
-
if @gui_chip_editor.lie_pack_name.text.empty?
|
116
|
-
error = 'Package reference missing'
|
117
|
-
# Pin number
|
118
|
-
elsif @gui_chip_editor.lie_pack_pin.text.empty?
|
119
|
-
error = 'Package pin number missing'
|
120
|
-
elsif @gui_chip_editor.tbl_pins.rowCount != @gui_chip_editor.lie_pack_pin.text.to_i
|
121
|
-
error = 'The pin number and the line count in the pin array does not match'
|
122
|
-
# Reference
|
123
|
-
elsif @gui_chip_editor.lie_reference.text.empty?
|
124
|
-
error = 'Chip reference missing'
|
125
|
-
# Manufacturer
|
126
|
-
elsif @gui_chip_editor.lie_manu_name.text.empty?
|
127
|
-
error = 'Chip manufacturer missing'
|
128
|
-
# Type
|
129
|
-
elsif @gui_chip_editor.lie_type_name.text.empty?
|
130
|
-
error = 'Chip type missing'
|
131
|
-
end
|
132
|
-
unless error.empty?
|
133
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Invalid form', error).exec
|
134
|
-
return false
|
135
|
-
else
|
136
|
-
return true
|
83
|
+
def closeEvent(event)
|
84
|
+
unless @chip == 'none' || Chip.exists?(@chip.id)
|
85
|
+
@parent.instance_variable_get('@view').tw_chip.clear
|
137
86
|
end
|
138
87
|
end
|
139
88
|
|
140
|
-
def
|
141
|
-
msg = Qt::MessageBox.new
|
142
|
-
msg.setWindowTitle('Delete element')
|
143
|
-
msg.setText('By deleting this element, all the chips and commands linked to him will be deleted too. Continue ?')
|
144
|
-
msg.setIcon(Qt::MessageBox::Warning)
|
145
|
-
msg.setStandardButtons(Qt::MessageBox::Cancel | Qt::MessageBox::Ok)
|
146
|
-
msg.setDefaultButton(Qt::MessageBox::Cancel)
|
147
|
-
if msg.exec == Qt::MessageBox::Ok
|
148
|
-
case sender.objectName
|
149
|
-
when 'btn_removePackage'
|
150
|
-
if @gui_chip_editor.cbx_package.currentIndex == 0
|
151
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Warning', 'Please select a valid element to delete').exec
|
152
|
-
else
|
153
|
-
package = Package.find_by(package_name: @gui_chip_editor.cbx_package.currentText)
|
154
|
-
chips = Chip.where(chip_package: package)
|
155
|
-
chips.each do |chip|
|
156
|
-
chip.cmd.destroy_all
|
157
|
-
end
|
158
|
-
chips.destroy_all
|
159
|
-
package.destroy
|
160
|
-
@gui_chip_editor.cbx_package.removeItem(@gui_chip_editor.cbx_package.currentIndex)
|
161
|
-
@gui_chip_editor.cbx_package.setCurrentIndex(0)
|
162
|
-
end
|
163
|
-
when 'btn_removeManufacturer'
|
164
|
-
if @gui_chip_editor.cbx_manufacturer.currentIndex == 0
|
165
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Warning', 'Please select a valid element to delete').exec
|
166
|
-
else
|
167
|
-
manufacturer = Manufacturer.find_by(manufacturer_name: @gui_chip_editor.cbx_manufacturer.currentText)
|
168
|
-
chips = Chip.where(chip_manufacturer: manufacturer)
|
169
|
-
chips.each do |chip|
|
170
|
-
chip.cmd.destroy_all
|
171
|
-
end
|
172
|
-
chips.destroy_all
|
173
|
-
manufacturer.destroy
|
174
|
-
@gui_chip_editor.cbx_manufacturer.removeItem(@gui_chip_editor.cbx_manufacturer.currentIndex)
|
175
|
-
@gui_chip_editor.cbx_manufacturer.setCurrentIndex(0)
|
176
|
-
end
|
177
|
-
when 'btn_removeType'
|
178
|
-
if @gui_chip_editor.cbx_type.currentIndex == 0
|
179
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Warning', 'Please select a valid element to delete').exec
|
180
|
-
else
|
181
|
-
type = CType.find_by(cType_name: @gui_chip_editor.cbx_type.currentText)
|
182
|
-
chips = Chip.where(chip_type: type)
|
183
|
-
chips.each do |chip|
|
184
|
-
chip.cmd.destroy_all
|
185
|
-
end
|
186
|
-
chips.destroy_all
|
187
|
-
type.destroy
|
188
|
-
@gui_chip_editor.cbx_type.removeItem(@gui_chip_editor.cbx_type.currentIndex)
|
189
|
-
@gui_chip_editor.cbx_type.setCurrentIndex(0)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
@parent.feed_chip_array
|
193
|
-
end
|
194
|
-
rescue Exception => msg
|
195
|
-
logger = Logger.new($logFilePath)
|
196
|
-
logger.error msg
|
197
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while deleting the element. Consult the log for more details').exec
|
198
|
-
end
|
199
|
-
|
200
|
-
# Add chip in database
|
201
|
-
def add_chip
|
202
|
-
unless control_form_val
|
203
|
-
return
|
204
|
-
end
|
205
|
-
if Chip.exists?(chip_reference: @gui_chip_editor.lie_reference.text)
|
206
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Invalid form', 'This chip reference already exists').exec
|
207
|
-
return
|
208
|
-
end
|
209
|
-
chip = Chip.new
|
210
|
-
# Reference
|
211
|
-
chip.chip_reference = @gui_chip_editor.lie_reference.text
|
212
|
-
# Custom
|
213
|
-
chip.chip_custom = 1
|
89
|
+
def prepare_rq
|
214
90
|
# Manufacturer
|
215
|
-
|
216
|
-
|
91
|
+
@manufacturer = Manufacturer.find_or_create_by(name: @view.lie_manu_name.text)
|
92
|
+
return false if check_for_errors(@manufacturer)
|
217
93
|
# Package
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
end
|
226
|
-
Package.create(
|
227
|
-
package_name: @gui_chip_editor.lie_pack_name.text,
|
228
|
-
package_pinNumber: @gui_chip_editor.lie_pack_pin.text,
|
229
|
-
package_shape: shape
|
230
|
-
)
|
231
|
-
chip.chip_package = Package.ids.last
|
232
|
-
end
|
94
|
+
@view.rbn_square.checked ? @shape = 0 : @shape = 1
|
95
|
+
@package = Package.find_or_create_by(
|
96
|
+
name: @view.lie_pack_name.text,
|
97
|
+
pin_number: @view.lie_pack_pin.text,
|
98
|
+
shape: @shape
|
99
|
+
)
|
100
|
+
return false if check_for_errors(@package)
|
233
101
|
# Type
|
234
|
-
|
235
|
-
|
102
|
+
@chip_type = ChipType.find_or_create_by(name: @view.lie_type_name.text)
|
103
|
+
return false if check_for_errors(@chip_type)
|
236
104
|
# Voltage
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
pin_bus = @gui_chip_editor.tbl_pins.cellWidget(i, 1)
|
251
|
-
if pin_bus.currentIndex == 0
|
252
|
-
signal = 62
|
253
|
-
else
|
254
|
-
signal = Signall.find_by(signal_name: pin_signal.currentText).signal_id
|
255
|
-
end
|
256
|
-
Pin.create(
|
257
|
-
pin_number: pin_num.text.to_i,
|
258
|
-
pin_chip: chip.chip_id,
|
259
|
-
pin_signal: signal
|
105
|
+
@view.rbn_3v.checked? ? @voltage = 1 : @voltage = 0
|
106
|
+
return true
|
107
|
+
end
|
108
|
+
|
109
|
+
def add_chip
|
110
|
+
if prepare_rq
|
111
|
+
@chip = Chip.create(
|
112
|
+
reference: @view.lie_reference.text,
|
113
|
+
description: @view.lie_description.text,
|
114
|
+
voltage: @voltage,
|
115
|
+
manufacturer_id: @manufacturer.id,
|
116
|
+
package_id: @package.id,
|
117
|
+
chip_type_id: @chip_type.id
|
260
118
|
)
|
119
|
+
unless check_for_errors(@chip)
|
120
|
+
add_pins
|
121
|
+
end
|
261
122
|
end
|
262
|
-
# Reloading array
|
263
|
-
@parent.feed_chip_array
|
264
|
-
close
|
265
123
|
end
|
266
124
|
|
267
|
-
# Edit the chip
|
268
125
|
def edit_chip
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
if @gui_chip_editor.rbn_square.isChecked
|
283
|
-
shape = 0
|
284
|
-
else
|
285
|
-
shape = 1
|
286
|
-
end
|
287
|
-
package = Package.find_or_create_by(
|
288
|
-
package_name: @gui_chip_editor.lie_pack_name.text,
|
289
|
-
package_pinNumber: @gui_chip_editor.lie_pack_pin.text,
|
290
|
-
package_shape: shape
|
291
|
-
)
|
292
|
-
if @chip.chip_package != package.package_id
|
293
|
-
@chip.update(chip_package: package.package_id)
|
294
|
-
end
|
295
|
-
# Type
|
296
|
-
ctype = CType.find_or_create_by(cType_name: @gui_chip_editor.lie_type_name.text)
|
297
|
-
if @chip.chip_type != ctype.cType_id
|
298
|
-
@chip.update(chip_type: ctype.cType_id)
|
299
|
-
end
|
300
|
-
# Voltage
|
301
|
-
if @gui_chip_editor.rbn_3v.checked
|
302
|
-
voltage = 1
|
303
|
-
else
|
304
|
-
voltage = 0
|
305
|
-
end
|
306
|
-
if @chip.chip_voltage != voltage
|
307
|
-
@chip.update(chip_voltage: voltage)
|
308
|
-
end
|
309
|
-
# Divers
|
310
|
-
if @chip.chip_detail != @gui_chip_editor.lie_description.text
|
311
|
-
@chip.update(chip_detail: @gui_chip_editor.lie_description.text)
|
126
|
+
if prepare_rq
|
127
|
+
@chip.update(
|
128
|
+
reference: @view.lie_reference.text,
|
129
|
+
description: @view.lie_description.text,
|
130
|
+
voltage: @voltage,
|
131
|
+
manufacturer_id: @manufacturer.id,
|
132
|
+
package_id: @package.id,
|
133
|
+
chip_type_id: @chip_type.id
|
134
|
+
)
|
135
|
+
unless check_for_errors(@chip)
|
136
|
+
@chip.pins.reload.destroy_all
|
137
|
+
add_pins
|
138
|
+
end
|
312
139
|
end
|
140
|
+
rescue Exception => msg
|
141
|
+
ErrorMsg.new.unknown(msg)
|
142
|
+
end
|
313
143
|
|
314
|
-
|
315
|
-
@
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
pin_bus = @gui_chip_editor.tbl_pins.cellWidget(i, 1)
|
144
|
+
def add_pins
|
145
|
+
for i in 0..(@view.lie_pack_pin.text.to_i) - 1 do
|
146
|
+
pin_num = @view.tbl_pins.item(i, 0)
|
147
|
+
pin_signal = @view.tbl_pins.cellWidget(i, 2)
|
148
|
+
pin_bus = @view.tbl_pins.cellWidget(i, 1)
|
320
149
|
if pin_bus.currentIndex == 0
|
321
|
-
signal =
|
150
|
+
signal = 1
|
322
151
|
else
|
323
|
-
signal = Signall.find_by(
|
152
|
+
signal = Signall.find_by(name: pin_signal.currentText).id
|
324
153
|
end
|
325
|
-
Pin.create(
|
326
|
-
|
327
|
-
|
328
|
-
|
154
|
+
pin = Pin.create(
|
155
|
+
number: pin_num.text.to_i,
|
156
|
+
chip_id: @chip.id,
|
157
|
+
signal_id: signal
|
329
158
|
)
|
159
|
+
check_for_errors(pin)
|
330
160
|
end
|
331
|
-
# Reloading array
|
332
161
|
@parent.feed_chip_array
|
333
162
|
close
|
334
|
-
rescue Exception => msg
|
335
|
-
logger = Logger.new($logFilePath)
|
336
|
-
logger.error msg
|
337
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while editing the chip. Consult the log for more details').exec
|
338
163
|
end
|
339
164
|
|
340
165
|
# Package combobox
|
341
166
|
def select_package
|
342
|
-
|
343
|
-
|
344
|
-
@
|
345
|
-
@
|
346
|
-
@
|
347
|
-
@
|
348
|
-
@
|
349
|
-
@
|
350
|
-
if
|
351
|
-
@
|
167
|
+
unless @view.cbx_package.currentIndex.zero?
|
168
|
+
selected_package = Package.find_by(name: @view.cbx_package.currentText)
|
169
|
+
@view.lie_pack_name.setEnabled(false)
|
170
|
+
@view.lie_pack_name.setText(selected_package.name)
|
171
|
+
@view.lie_pack_pin.setEnabled(false)
|
172
|
+
@view.lie_pack_pin.setText(selected_package.pin_number.to_s)
|
173
|
+
@view.rbn_square.setEnabled(false)
|
174
|
+
@view.rbn_rectangular.setEnabled(false)
|
175
|
+
if selected_package.shape.zero?
|
176
|
+
@view.rbn_square.setChecked(true)
|
352
177
|
else
|
353
|
-
@
|
178
|
+
@view.rbn_rectangular.setChecked(true)
|
354
179
|
end
|
355
180
|
fill_pin_table
|
356
181
|
else
|
357
|
-
@
|
358
|
-
@
|
359
|
-
@
|
360
|
-
@
|
361
|
-
@
|
362
|
-
@
|
363
|
-
@
|
364
|
-
@
|
365
|
-
@
|
182
|
+
@view.lie_pack_name.setEnabled(true)
|
183
|
+
@view.lie_pack_name.clear
|
184
|
+
@view.lie_pack_pin.setEnabled(true)
|
185
|
+
@view.lie_pack_pin.clear
|
186
|
+
@view.rbn_square.setChecked(true)
|
187
|
+
@view.rbn_rectangular.setEnabled(true)
|
188
|
+
@view.rbn_square.setEnabled(true)
|
189
|
+
@view.tbl_pins.clear
|
190
|
+
@view.tbl_pins.setRowCount(0)
|
366
191
|
end
|
367
192
|
end
|
368
193
|
|
369
194
|
# Manufacturer combobox
|
370
195
|
def select_manufacturer
|
371
|
-
|
372
|
-
@
|
373
|
-
@
|
196
|
+
unless @view.cbx_manufacturer.currentIndex.zero?
|
197
|
+
@view.lie_manu_name.setEnabled(false)
|
198
|
+
@view.lie_manu_name.setText(@view.cbx_manufacturer.currentText)
|
374
199
|
else
|
375
|
-
@
|
376
|
-
@
|
200
|
+
@view.lie_manu_name.setEnabled(true)
|
201
|
+
@view.lie_manu_name.setText('')
|
377
202
|
end
|
378
203
|
end
|
379
204
|
|
380
205
|
# Type combobox
|
381
206
|
def select_type
|
382
|
-
|
383
|
-
@
|
384
|
-
@
|
207
|
+
unless @view.cbx_type.currentIndex.zero?
|
208
|
+
@view.lie_type_name.setEnabled(false)
|
209
|
+
@view.lie_type_name.setText(@view.cbx_type.currentText)
|
385
210
|
else
|
386
|
-
@
|
387
|
-
@
|
211
|
+
@view.lie_type_name.setEnabled(true)
|
212
|
+
@view.lie_type_name.setText('')
|
388
213
|
end
|
389
214
|
end
|
390
215
|
|
391
216
|
def fill_pin_table(action = '')
|
392
|
-
if @
|
393
|
-
@
|
394
|
-
|
217
|
+
if @view.lie_pack_pin.text.to_i <= 144 && @view.lie_pack_pin.text.to_i >= 4
|
218
|
+
@view.tbl_pins.setRowCount(@view.lie_pack_pin.text.to_i)
|
219
|
+
full_bus_list = Bus.all
|
220
|
+
@view.lie_pack_pin.text.to_i.times do |i|
|
395
221
|
cbx_bus = Qt::ComboBox.new
|
396
222
|
row = Qt::Variant.new(i)
|
397
223
|
cbx_bus.setProperty('row', row)
|
398
|
-
@
|
224
|
+
@view.tbl_pins.setCellWidget(i, 1, cbx_bus)
|
399
225
|
cbx_signal = Qt::ComboBox.new
|
400
|
-
@
|
226
|
+
@view.tbl_pins.setCellWidget(i, 2, cbx_signal)
|
401
227
|
item = Qt::TableWidgetItem.new
|
402
228
|
item.setFlags(Qt::ItemIsEnabled)
|
403
229
|
item.setData(0, Qt::Variant.new(i.next))
|
404
|
-
@
|
230
|
+
@view.tbl_pins.setItem(i, 0, item)
|
405
231
|
cbx_bus.addItem('Bus...')
|
406
|
-
|
407
|
-
cbx_bus.addItem(b.
|
232
|
+
full_bus_list.each do |b|
|
233
|
+
cbx_bus.addItem(b.name)
|
408
234
|
end
|
409
235
|
if action == 'edit'
|
410
|
-
pin = Pin.find_by(
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
236
|
+
pin = Pin.find_by(number: i.next, chip_id: @chip.id)
|
237
|
+
unless pin.signal_id == 1
|
238
|
+
current_bus = pin.signall.buses
|
239
|
+
cbx_bus.setCurrentIndex(cbx_bus.findText(current_bus[0].name))
|
240
|
+
current_signals = current_bus[0].signalls
|
241
|
+
current_signals.each do |s|
|
242
|
+
cbx_signal.addItem(s.name)
|
243
|
+
end
|
244
|
+
cbx_signal.setCurrentIndex(cbx_signal.findText(pin.signall.name))
|
415
245
|
end
|
416
|
-
cbx_signal.setCurrentIndex(cbx_signal.findText(pin.signall.signal_name))
|
417
246
|
end
|
418
247
|
Qt::Object.connect(cbx_bus, SIGNAL('currentIndexChanged(int)'), self, SLOT('filter_cbx()'))
|
419
248
|
end
|
420
249
|
else
|
421
|
-
|
250
|
+
ErrorMsg.new.invalid_pin_nbr
|
251
|
+
end
|
252
|
+
rescue Exception => msg
|
253
|
+
ErrorMsg.new.unknown(msg)
|
254
|
+
end
|
255
|
+
|
256
|
+
def delete_cbx_element
|
257
|
+
msg = Qt::MessageBox.new
|
258
|
+
msg.setWindowTitle('Delete element')
|
259
|
+
msg.setText('Chips and commands associated with it will be deleted too.')
|
260
|
+
msg.setIcon(Qt::MessageBox::Warning)
|
261
|
+
msg.setStandardButtons(Qt::MessageBox::Cancel | Qt::MessageBox::Ok)
|
262
|
+
msg.setDefaultButton(Qt::MessageBox::Cancel)
|
263
|
+
if msg.exec == Qt::MessageBox::Ok
|
264
|
+
case sender.objectName
|
265
|
+
when 'btn_delete_package'
|
266
|
+
return false if @view.cbx_package.currentIndex == 0
|
267
|
+
Package.find_by(name: @view.cbx_package.currentText).destroy
|
268
|
+
@view.cbx_package.removeItem(@view.cbx_package.currentIndex)
|
269
|
+
@view.cbx_package.setCurrentIndex(0)
|
270
|
+
when 'btn_delete_manufacturer'
|
271
|
+
return false if @view.cbx_manufacturer.currentIndex == 0
|
272
|
+
Manufacturer.find_by(name: @view.cbx_manufacturer.currentText).destroy
|
273
|
+
@view.cbx_manufacturer.removeItem(@view.cbx_manufacturer.currentIndex)
|
274
|
+
@view.cbx_manufacturer.setCurrentIndex(0)
|
275
|
+
when 'btn_delete_type'
|
276
|
+
return false if @view.cbx_type.currentIndex == 0
|
277
|
+
ChipType.find_by(name: @view.cbx_type.currentText).destroy
|
278
|
+
@view.cbx_type.removeItem(@view.cbx_type.currentIndex)
|
279
|
+
@view.cbx_type.setCurrentIndex(0)
|
280
|
+
end
|
281
|
+
@parent.feed_chip_array
|
422
282
|
end
|
423
283
|
rescue Exception => msg
|
424
|
-
|
425
|
-
logger.error msg
|
426
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while adding pins to the table. Consult the log for more details').exec
|
284
|
+
ErrorMsg.new.unknown(msg)
|
427
285
|
end
|
428
286
|
|
429
287
|
# Filter signals by bus
|
430
288
|
def filter_cbx
|
431
289
|
bus_item_row = sender.property('row').to_i
|
432
|
-
busItem = @
|
433
|
-
associated_signal_item = @
|
290
|
+
busItem = @view.tbl_pins.cellWidget(bus_item_row, 1)
|
291
|
+
associated_signal_item = @view.tbl_pins.cellWidget(bus_item_row, 2)
|
434
292
|
associated_signal_item.clear
|
435
293
|
if busItem.currentText != 'Bus...'
|
436
|
-
bus = Bus.find_by(
|
294
|
+
bus = Bus.find_by(name: busItem.currentText).id
|
437
295
|
filtered_signal_list = Use.where(bus_id: bus)
|
438
296
|
filtered_signal_list.each do |s|
|
439
|
-
|
440
|
-
associated_signal_item.addItem(
|
297
|
+
signal_name = Signall.find_by(id: s.signal_id).name
|
298
|
+
associated_signal_item.addItem(signal_name)
|
441
299
|
end
|
442
300
|
end
|
443
301
|
rescue Exception => msg
|
444
|
-
|
445
|
-
logger.error msg
|
446
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while filtering the signals. Consult the log for more details').exec
|
302
|
+
ErrorMsg.new.unknown(msg)
|
447
303
|
end
|
448
304
|
end
|