main.qml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. import QtQuick 2.7
  2. import QtQuick.Window 2.2
  3. import gfa.plugins.qml.tivaflash 1.0
  4. Window {
  5. visible: true
  6. width: 640
  7. height: 480
  8. property int statNr: 1
  9. property int mbAddr: 100
  10. Rectangle {
  11. anchors.fill: parent
  12. gradient: Gradient {
  13. GradientStop { position: 0.0; color: "gray" }
  14. GradientStop { position: 0.5; color: "black" }
  15. GradientStop { position: 1.0; color: "dimgray" }
  16. }
  17. }
  18. Text {
  19. id: headline
  20. x: 250
  21. y: 5
  22. color: "white"
  23. font.pixelSize: 24
  24. text: qsTr("GfA Tiva Flash Utility")
  25. }
  26. Rectangle {
  27. id: line
  28. x: 5
  29. y: 40
  30. width: 790
  31. height: 2
  32. color: "white"
  33. }
  34. Rectangle
  35. {
  36. x: 5
  37. y: 75
  38. width: 50
  39. height: 40
  40. color: "darkred"
  41. Text {
  42. text: statNr
  43. anchors.centerIn: parent
  44. color: "white"
  45. }
  46. }
  47. Rectangle
  48. {
  49. x: 60
  50. y: 75
  51. width: 120
  52. height: 20
  53. color: "darkred"
  54. Text {
  55. id: materialEepromText
  56. anchors.centerIn: parent
  57. color: "white"
  58. font.pixelSize: 14
  59. text: idTivaFlash.materialEeprom[statNr]
  60. }
  61. }
  62. Rectangle
  63. {
  64. x: 60
  65. y: 95
  66. width: 120
  67. height: 20
  68. color: "darkred"
  69. Text {
  70. id: serialEepromText
  71. anchors.centerIn: parent
  72. color: "white"
  73. font.pixelSize: 14
  74. text: idTivaFlash.serialEeprom[statNr]
  75. }
  76. }
  77. Rectangle
  78. {
  79. x: 185
  80. y: 75
  81. width: 40
  82. height: 40
  83. color: "darkblue"
  84. Text {
  85. id: idUploadPercent
  86. anchors.centerIn: parent
  87. color: "white"
  88. font.pixelSize: 14
  89. text: ""
  90. }
  91. }
  92. Rectangle
  93. {
  94. x: 230
  95. y: 75
  96. width: 120
  97. height: 20
  98. color: "darkblue"
  99. Text {
  100. anchors.centerIn: parent
  101. color: "white"
  102. font.pixelSize: 14
  103. text: idTivaFlash.imgSizeApp[statNr]
  104. }
  105. }
  106. Rectangle
  107. {
  108. x: 230
  109. y: 95
  110. width: 120
  111. height: 20
  112. color: "darkblue"
  113. Text {
  114. anchors.centerIn: parent
  115. color: "white"
  116. font.pixelSize: 14
  117. text: idTivaFlash.imgCRC32App[statNr].toString(16)
  118. }
  119. }
  120. Rectangle
  121. {
  122. x: 355
  123. y: 75
  124. width: 120
  125. height: 20
  126. color: "darkblue"
  127. Text {
  128. anchors.centerIn: parent
  129. color: "white"
  130. font.pixelSize: 14
  131. text: idTivaFlash.imgMaterialApp[statNr]
  132. }
  133. }
  134. Rectangle
  135. {
  136. x: 355
  137. y: 95
  138. width: 120
  139. height: 20
  140. color: "darkblue"
  141. Text {
  142. anchors.centerIn: parent
  143. color: "white"
  144. font.pixelSize: 14
  145. text: idTivaFlash.imgBuildApp[statNr]
  146. }
  147. }
  148. Rectangle
  149. {
  150. x: 500
  151. y: 75
  152. width: 200
  153. height: 40
  154. color: idTivaFlash.executing ? "red" : "green"
  155. Text {
  156. text: "uploadImgFile"
  157. anchors.centerIn: parent
  158. color: "white"
  159. }
  160. MouseArea
  161. {
  162. anchors.fill: parent
  163. enabled: !idTivaFlash.executing
  164. onClicked:
  165. {
  166. idExecOut.text = "";
  167. idTivaFlash.uploadImgFile(statNr, mbAddr);
  168. }
  169. }
  170. }
  171. Rectangle
  172. {
  173. x: 500
  174. y: 125
  175. width: 200
  176. height: 40
  177. color: idTivaFlash.executing ? "red" : "green"
  178. Text {
  179. text: "startBootloader"
  180. anchors.centerIn: parent
  181. color: "white"
  182. }
  183. MouseArea
  184. {
  185. anchors.fill: parent
  186. enabled: !idTivaFlash.executing
  187. onClicked:
  188. {
  189. idExecOut.text = "";
  190. idTivaFlash.startBootloader(statNr);
  191. }
  192. }
  193. }
  194. Rectangle
  195. {
  196. x: 500
  197. y: 175
  198. width: 200
  199. height: 40
  200. color: idTivaFlash.executing ? "red" : "green"
  201. Text {
  202. text: "resetBootloader"
  203. anchors.centerIn: parent
  204. color: "white"
  205. }
  206. MouseArea
  207. {
  208. anchors.fill: parent
  209. enabled: !idTivaFlash.executing
  210. onClicked:
  211. {
  212. idExecOut.text = "";
  213. idTivaFlash.resetBootloader(statNr);
  214. }
  215. }
  216. }
  217. Rectangle
  218. {
  219. x: 500
  220. y: 225
  221. width: 200
  222. height: 40
  223. color: idTivaFlash.executing ? "red" : "green"
  224. Text {
  225. text: "pingTarget"
  226. anchors.centerIn: parent
  227. color: "white"
  228. }
  229. MouseArea
  230. {
  231. anchors.fill: parent
  232. enabled: !idTivaFlash.executing
  233. onClicked:
  234. {
  235. idExecOut.text = "";
  236. idTivaFlash.pingTarget(statNr);
  237. }
  238. }
  239. }
  240. Rectangle
  241. {
  242. x: 500
  243. y: 275
  244. width: 200
  245. height: 40
  246. color: idTivaFlash.executing ? "red" : "green"
  247. Text {
  248. text: "getTargetImgInfo"
  249. anchors.centerIn: parent
  250. color: "white"
  251. }
  252. MouseArea
  253. {
  254. anchors.fill: parent
  255. enabled: !idTivaFlash.executing
  256. onClicked:
  257. {
  258. idExecOut.text = "";
  259. idTivaFlash.getTargetImgInfo(statNr);
  260. }
  261. }
  262. }
  263. Rectangle
  264. {
  265. x: 500
  266. y: 325
  267. width: 200
  268. height: 40
  269. color: idTivaFlash.executing ? "red" : "green"
  270. Text {
  271. text: "validateImgFile"
  272. anchors.centerIn: parent
  273. color: "white"
  274. }
  275. MouseArea
  276. {
  277. anchors.fill: parent
  278. enabled: !idTivaFlash.executing
  279. onClicked:
  280. {
  281. idExecOut.text = "";
  282. idTivaFlash.validateImgFile(statNr);
  283. }
  284. }
  285. }
  286. Rectangle
  287. {
  288. x: 500
  289. y: 375
  290. width: 200
  291. height: 40
  292. color: idTivaFlash.executing ? "red" : "green"
  293. Text {
  294. text: "getMatSer"
  295. anchors.centerIn: parent
  296. color: "white"
  297. }
  298. MouseArea
  299. {
  300. anchors.fill: parent
  301. enabled: !idTivaFlash.executing
  302. onClicked:
  303. {
  304. idExecOut.text = "";
  305. idTivaFlash.getMatSer(statNr);
  306. }
  307. }
  308. }
  309. Rectangle
  310. {
  311. x: 500
  312. y: 425
  313. width: 200
  314. height: 40
  315. color: idTivaFlash.executing ? "red" : "green"
  316. Text {
  317. text: "clearImgInfo"
  318. anchors.centerIn: parent
  319. color: "white"
  320. }
  321. MouseArea
  322. {
  323. anchors.fill: parent
  324. enabled: !idTivaFlash.executing
  325. onClicked:
  326. {
  327. idExecOut.text = "";
  328. idUploadPercent.text = "";
  329. idTivaFlash.clearImgInfo(statNr);
  330. }
  331. }
  332. }
  333. Text {
  334. id: idExecOut
  335. x: 5
  336. y: 150
  337. width: 495
  338. height: 300
  339. color: "white"
  340. font.pixelSize: 14
  341. }
  342. TivaFlash {
  343. id: idTivaFlash
  344. tivaFlashUtilPath: "/opt/GfA/tivaflashutil/gfativaflashutil"
  345. itfName: "/dev/ttyO4"
  346. xBaudRate: 115200
  347. slvIdIsNodeAddr: false
  348. imgFile: "/opt/GfA/tivaflashutil/OLS-1V1_0009_crc.bin"
  349. verbosity: 2
  350. onProcessStarted: // arguments: slv (number, Slave ID)
  351. {
  352. console.info("Process started");
  353. }
  354. onProcessFinished: // arguments: slv (number, Slave ID), exitcode (number Exit code), normalExit (bool, Normal exit or crash)
  355. {
  356. console.info("Process finished - exitcode: " + (normalExit ? exitcode : "crashed!"));
  357. }
  358. onProcessOutput: // arguments: slv (number, Slave ID), ctx (number, 1=error, 2=info, 3=status), msg (string, Message)
  359. {
  360. idExecOut.text += msg + "\n";
  361. }
  362. onImgUploadProgress: // arguments: stat (object ImgUploadStatus)
  363. {
  364. switch(stat.ctx)
  365. {
  366. case ImgUploadStatus.EraseFlashStart:
  367. idUploadPercent.text = "";
  368. break;
  369. case ImgUploadStatus.EraseFlashEnd:
  370. break;
  371. case ImgUploadStatus.ImgUploadStart:
  372. idUploadPercent.text = "0";
  373. break;
  374. case ImgUploadStatus.ImgUploadBlock:
  375. idUploadPercent.text = stat.percentSent;
  376. break;
  377. case ImgUploadStatus.ImgUploadSuccess:
  378. idUploadPercent.text = "Ok";
  379. break;
  380. case ImgUploadStatus.ImgUploadError:
  381. idUploadPercent.text = "Err";
  382. break;
  383. }
  384. }
  385. }
  386. }