main.qml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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. visible: idTivaFlash.imgUploadStatus.uploadInProgress
  85. Text {
  86. id: idUploadPercent
  87. anchors.centerIn: parent
  88. color: "white"
  89. font.pixelSize: 14
  90. text: idTivaFlash.imgUploadStatus.percentSent
  91. }
  92. }
  93. Rectangle
  94. {
  95. x: 230
  96. y: 75
  97. width: 120
  98. height: 20
  99. color: "darkblue"
  100. Text {
  101. anchors.centerIn: parent
  102. color: "white"
  103. font.pixelSize: 14
  104. text: idTivaFlash.imgSizeApp[statNr]
  105. }
  106. }
  107. Rectangle
  108. {
  109. x: 230
  110. y: 95
  111. width: 120
  112. height: 20
  113. color: "darkblue"
  114. Text {
  115. anchors.centerIn: parent
  116. color: "white"
  117. font.pixelSize: 14
  118. text: idTivaFlash.imgCRC32App[statNr].toString(16)
  119. }
  120. }
  121. Rectangle
  122. {
  123. x: 355
  124. y: 75
  125. width: 120
  126. height: 20
  127. color: "darkblue"
  128. Text {
  129. anchors.centerIn: parent
  130. color: "white"
  131. font.pixelSize: 14
  132. text: idTivaFlash.imgMaterialApp[statNr]
  133. }
  134. }
  135. Rectangle
  136. {
  137. x: 355
  138. y: 95
  139. width: 120
  140. height: 20
  141. color: "darkblue"
  142. Text {
  143. anchors.centerIn: parent
  144. color: "white"
  145. font.pixelSize: 14
  146. text: idTivaFlash.imgBuildApp[statNr]
  147. }
  148. }
  149. Rectangle
  150. {
  151. x: 500
  152. y: 75
  153. width: 200
  154. height: 40
  155. color: idTivaFlash.executing ? "red" : "green"
  156. Text {
  157. text: "uploadImgFile"
  158. anchors.centerIn: parent
  159. color: "white"
  160. }
  161. MouseArea
  162. {
  163. anchors.fill: parent
  164. enabled: !idTivaFlash.executing
  165. onClicked:
  166. {
  167. idExecOut.text = "";
  168. idTivaFlash.uploadImgFile(statNr, mbAddr);
  169. }
  170. }
  171. }
  172. Rectangle
  173. {
  174. x: 500
  175. y: 125
  176. width: 200
  177. height: 40
  178. color: idTivaFlash.executing ? "red" : "green"
  179. Text {
  180. text: "startBootloader"
  181. anchors.centerIn: parent
  182. color: "white"
  183. }
  184. MouseArea
  185. {
  186. anchors.fill: parent
  187. enabled: !idTivaFlash.executing
  188. onClicked:
  189. {
  190. idExecOut.text = "";
  191. idTivaFlash.startBootloader(statNr);
  192. }
  193. }
  194. }
  195. Rectangle
  196. {
  197. x: 500
  198. y: 175
  199. width: 200
  200. height: 40
  201. color: idTivaFlash.executing ? "red" : "green"
  202. Text {
  203. text: "resetBootloader"
  204. anchors.centerIn: parent
  205. color: "white"
  206. }
  207. MouseArea
  208. {
  209. anchors.fill: parent
  210. enabled: !idTivaFlash.executing
  211. onClicked:
  212. {
  213. idExecOut.text = "";
  214. idTivaFlash.resetBootloader(statNr);
  215. }
  216. }
  217. }
  218. Rectangle
  219. {
  220. x: 500
  221. y: 225
  222. width: 200
  223. height: 40
  224. color: idTivaFlash.executing ? "red" : "green"
  225. Text {
  226. text: "pingTarget"
  227. anchors.centerIn: parent
  228. color: "white"
  229. }
  230. MouseArea
  231. {
  232. anchors.fill: parent
  233. enabled: !idTivaFlash.executing
  234. onClicked:
  235. {
  236. idExecOut.text = "";
  237. idTivaFlash.pingTarget(statNr);
  238. }
  239. }
  240. }
  241. Rectangle
  242. {
  243. x: 500
  244. y: 275
  245. width: 200
  246. height: 40
  247. color: idTivaFlash.executing ? "red" : "green"
  248. Text {
  249. text: "getTargetImgInfo"
  250. anchors.centerIn: parent
  251. color: "white"
  252. }
  253. MouseArea
  254. {
  255. anchors.fill: parent
  256. enabled: !idTivaFlash.executing
  257. onClicked:
  258. {
  259. idExecOut.text = "";
  260. idTivaFlash.getTargetImgInfo(statNr);
  261. }
  262. }
  263. }
  264. Rectangle
  265. {
  266. x: 500
  267. y: 325
  268. width: 200
  269. height: 40
  270. color: idTivaFlash.executing ? "red" : "green"
  271. Text {
  272. text: "validateImgFile"
  273. anchors.centerIn: parent
  274. color: "white"
  275. }
  276. MouseArea
  277. {
  278. anchors.fill: parent
  279. enabled: !idTivaFlash.executing
  280. onClicked:
  281. {
  282. idExecOut.text = "";
  283. idTivaFlash.validateImgFile(statNr);
  284. }
  285. }
  286. }
  287. Rectangle
  288. {
  289. x: 500
  290. y: 375
  291. width: 200
  292. height: 40
  293. color: idTivaFlash.executing ? "red" : "green"
  294. Text {
  295. text: "getMatSer"
  296. anchors.centerIn: parent
  297. color: "white"
  298. }
  299. MouseArea
  300. {
  301. anchors.fill: parent
  302. enabled: !idTivaFlash.executing
  303. onClicked:
  304. {
  305. idExecOut.text = "";
  306. idTivaFlash.getMatSer(statNr);
  307. }
  308. }
  309. }
  310. Rectangle
  311. {
  312. x: 500
  313. y: 425
  314. width: 200
  315. height: 40
  316. color: idTivaFlash.executing ? "red" : "green"
  317. Text {
  318. text: "clearImgInfo"
  319. anchors.centerIn: parent
  320. color: "white"
  321. }
  322. MouseArea
  323. {
  324. anchors.fill: parent
  325. enabled: !idTivaFlash.executing
  326. onClicked:
  327. {
  328. idExecOut.text = "";
  329. // idUploadPercent.text = "";
  330. idTivaFlash.clearImgInfo(statNr);
  331. }
  332. }
  333. }
  334. Text {
  335. id: idExecOut
  336. x: 5
  337. y: 150
  338. width: 495
  339. height: 300
  340. color: "white"
  341. font.pixelSize: 14
  342. }
  343. TivaFlash {
  344. id: idTivaFlash
  345. tivaFlashUtilPath: "/opt/GfA/tivaflashutil/gfativaflashutil"
  346. itfName: "/dev/ttyO4"
  347. xBaudRate: 115200
  348. slvIdIsNodeAddr: false
  349. imgFile: "/opt/GfA/tivaflashutil/OLS-1V1_0009_crc.bin"
  350. verbosity: 2
  351. onProcessStarted: // arguments: slv (number, Slave ID)
  352. {
  353. console.info("Process started");
  354. }
  355. onProcessFinished: // arguments: slv (number, Slave ID), exitcode (number Exit code), normalExit (bool, Normal exit or crash)
  356. {
  357. console.info("Process finished - exitcode: " + (normalExit ? exitcode : "crashed!"));
  358. }
  359. onProcessOutput: // arguments: slv (number, Slave ID), ctx (number, 1=error, 2=info, 3=status), msg (string, Message)
  360. {
  361. idExecOut.text += msg + "\n";
  362. }
  363. onImgUploadProgress: // arguments: stat (object ImgUploadStatus)
  364. {
  365. switch(stat.ctx)
  366. {
  367. case ImgUploadStatus.EraseFlashStart:
  368. // idUploadPercent.text = "";
  369. break;
  370. case ImgUploadStatus.EraseFlashEnd:
  371. break;
  372. case ImgUploadStatus.ImgUploadStart:
  373. // idUploadPercent.text = "0";
  374. break;
  375. case ImgUploadStatus.ImgUploadBlock:
  376. // idUploadPercent.text = stat.percentSent;
  377. break;
  378. case ImgUploadStatus.ImgUploadSuccess:
  379. // idUploadPercent.text = "Ok";
  380. break;
  381. case ImgUploadStatus.ImgUploadError:
  382. // idUploadPercent.text = "Err";
  383. break;
  384. }
  385. }
  386. }
  387. }