PageRenderTime 30ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/bticino/it.polito.elite.dog.drivers.bticino.network/src/com/bticino/core/OpenWebNet.java

https://github.com/shineit/dog
Java | 1573 lines | 907 code | 123 blank | 543 comment | 243 complexity | 08dc82d1c73b9aa8e6f54cb311f08165 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1
  1. package com.bticino.core;
  2. /***************************************************************************
  3. * OpenWebNet.java *
  4. * -------------------------- *
  5. * date : Feb 22, 2005 *
  6. * Copyright (c) : (C) 2005 by Bticino S.p.A. Erba (CO) - Italy *
  7. * Embedded Software Development Laboratory *
  8. * license : GPL *
  9. * email : *
  10. * web site : www.bticino.it; www.myhome-bticino.it *
  11. ***************************************************************************/
  12. /***************************************************************************
  13. * *
  14. * This program is free software; you can redistribute it and/or modify *
  15. * it under the terms of the GNU General Public License as published by *
  16. * the Free Software Foundation; either version 2 of the License, or *
  17. * (at your option) any later version. *
  18. * *
  19. ***************************************************************************/
  20. /**
  21. * Description: Class to manage the OPEN protocol
  22. *
  23. */
  24. public class OpenWebNet implements InterfaceOpenWebNet
  25. {
  26. // created frame open
  27. private String frameOpen = new String();
  28. // tipo di frame open
  29. private int tipoFrame;
  30. // lunghezza frame
  31. private int lengthFrameOpen;
  32. // indica le frame estese
  33. private boolean estesa;
  34. // numero valori
  35. int numValori;
  36. // numero indirizzo
  37. int numIndirizzo;
  38. // contenuti della frame normale
  39. private String chi = "";
  40. private String indirizzo[] = new String[MAX_INDIRIZZO];
  41. private String cosa = "";
  42. private String dove = "";
  43. private String livello = "";
  44. private String interfaccia = "";
  45. private String quando = "";
  46. private String grandezza = "";
  47. private String valori[] = new String[MAX_NUM_VALORI];
  48. /**
  49. * Costruttore Crea una NULL_FRAME
  50. *
  51. */
  52. public OpenWebNet()
  53. {
  54. // richiamo la procedura createNullMsgOpen
  55. createNullMsgOpen();
  56. }
  57. /**
  58. * Costruttore
  59. *
  60. * @param message
  61. * Frame open
  62. */
  63. public OpenWebNet(String message)
  64. {
  65. // richiamo la procedura CreateMsgOpen(String message)
  66. createMsgOpen(message);
  67. }
  68. /**
  69. * Crea il messaggio OPEN *chi*cosa*dove*quando##
  70. *
  71. * @param who
  72. * Campo chi
  73. * @param what
  74. * Campo cosa
  75. * @param where
  76. * Campo dove
  77. * @param when
  78. * Campo quando
  79. */
  80. public OpenWebNet(String who, String what, String where, String when)
  81. {
  82. // richiamo la procedura CreateMsgOpen()
  83. createMsgOpen(who, what, where, when);
  84. }
  85. /**
  86. * Crea il messaggio OPEN tramite la stringa passata come parametro
  87. *
  88. * @param message
  89. * Frame open
  90. */
  91. public void createMsgOpen(String message)
  92. {
  93. // System.out.println("creo msg open da stringa");
  94. // richiamo la procedura CreateNullMsgOpen()
  95. createNullMsgOpen();
  96. // salva il tipo di frame e la sua lunghezza
  97. frameOpen = message;
  98. lengthFrameOpen = frameOpen.length();
  99. // elimino i caratteri di controllo ....
  100. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  101. lengthFrameOpen--;
  102. if ((frameOpen.charAt(lengthFrameOpen - 2) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 2) == '\r')))
  103. lengthFrameOpen--;
  104. // per scrupolo ...
  105. // frameOpen[lengthFrameOpen] = '\0';
  106. // controlla se sintassi corretta ...
  107. isCorrect();
  108. }
  109. /**
  110. * Crea il messaggio OPEN *chi*cosa*dove*quando##
  111. *
  112. * @param who
  113. * Campo chi
  114. * @param what
  115. * Campo cosa
  116. * @param where
  117. * Campo dove
  118. * @param when
  119. * Campo quando
  120. */
  121. public void createMsgOpen(String who, String what, String where, String when)
  122. {
  123. // richiamo la procedura CreateNullMsgOpen()
  124. // System.out.println("creo msg open tramite chi cosa dove quando");
  125. createNullMsgOpen();
  126. // creo il messaggio open
  127. frameOpen = "*";
  128. frameOpen = frameOpen.concat(who);
  129. frameOpen = frameOpen.concat("*");
  130. frameOpen = frameOpen.concat(what);
  131. frameOpen = frameOpen.concat("*");
  132. frameOpen = frameOpen.concat(where);
  133. // per togliere l'asterisco finale
  134. if (!when.equals(""))
  135. {
  136. frameOpen = frameOpen.concat("*");
  137. }
  138. frameOpen = frameOpen.concat(when);
  139. frameOpen = frameOpen.concat("##");
  140. lengthFrameOpen = frameOpen.length();
  141. // elimino i caratteri di controllo ....
  142. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  143. lengthFrameOpen--;
  144. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  145. lengthFrameOpen--;
  146. // per scrupolo ...
  147. // frameOpen[lengthFrameOpen] = '\0';
  148. // controlla se sintassi corretta ...
  149. isCorrect();
  150. }
  151. /**
  152. * Crea il messaggio OPEN *chi*cosa*dove#livello#interfaccia*quando##
  153. *
  154. * @param who
  155. * Campo chi
  156. * @param what
  157. * Campo cosa
  158. * @param where
  159. * Campo dove
  160. * @param lev
  161. * Campo livello
  162. * @param interfac
  163. * Campo interfaccia
  164. * @param when
  165. * Campo quando
  166. */
  167. public void createMsgOpen(String who, String what, String where, String lev, String interfac, String when)
  168. {
  169. // richiamo la procedura CreateNullMsgOpen()
  170. createNullMsgOpen();
  171. frameOpen = "*";
  172. frameOpen = frameOpen.concat(who);
  173. frameOpen = frameOpen.concat("*");
  174. frameOpen = frameOpen.concat(what);
  175. frameOpen = frameOpen.concat("*");
  176. frameOpen = frameOpen.concat(where);
  177. frameOpen = frameOpen.concat("#");
  178. if (lev.equals(""))
  179. {
  180. frameOpen = frameOpen.concat("4");
  181. // strcat(frameOpen, "4");
  182. }
  183. else
  184. {
  185. frameOpen = frameOpen.concat(lev);
  186. // strcat(frameOpen, lev);
  187. }
  188. frameOpen = frameOpen.concat("#");
  189. frameOpen = frameOpen.concat(interfac);
  190. // per togliere l'asterisco finale
  191. if (when.equals(""))
  192. {
  193. frameOpen = frameOpen.concat("*");
  194. }
  195. frameOpen = frameOpen.concat("when");
  196. frameOpen = frameOpen.concat("##");
  197. lengthFrameOpen = frameOpen.length();
  198. // elimino i caratteri di controllo ....
  199. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  200. lengthFrameOpen--;
  201. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  202. lengthFrameOpen--;
  203. // per scrupolo ...
  204. // frameOpen[lengthFrameOpen] = '\0';
  205. // controlla se sintassi corretta ...
  206. isCorrect();
  207. }
  208. /**
  209. * Crea il messaggio OPEN *#chi*dove##
  210. *
  211. * @param who
  212. * Campo chi
  213. * @param where
  214. * Campo dove
  215. */
  216. public void CreateStateMsgOpen(String who, String where)
  217. {
  218. // richiamo la procedura CreateNullMsgOpen()
  219. createNullMsgOpen();
  220. // creo il messaggio open
  221. frameOpen = "*#";
  222. frameOpen = frameOpen.concat(who);
  223. frameOpen = frameOpen.concat("*");
  224. frameOpen = frameOpen.concat(where);
  225. frameOpen = frameOpen.concat("##");
  226. lengthFrameOpen = frameOpen.length();
  227. // elimino i caratteri di controllo ....
  228. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  229. lengthFrameOpen--;
  230. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  231. lengthFrameOpen--;
  232. // controlla se sintassi corretta ...
  233. isCorrect();
  234. }
  235. /**
  236. * Crea il messaggio OPEN *#chi*dove#livello#interfaccia##
  237. *
  238. * @param who
  239. * Campo chi
  240. * @param where
  241. * Campo dove
  242. * @param lev
  243. * Campo livello
  244. * @param interfac
  245. * Campo interfaccia
  246. */
  247. public void CreateStateMsgOpen(String who, String where, String lev, String interfac)
  248. {
  249. // richiamo la procedura CreateNullMsgOpen()
  250. createNullMsgOpen();
  251. frameOpen = "*#";
  252. frameOpen = frameOpen.concat(who);
  253. frameOpen = frameOpen.concat("*");
  254. frameOpen = frameOpen.concat(where);
  255. frameOpen = frameOpen.concat("#");
  256. if (lev.equals(""))
  257. {
  258. frameOpen = frameOpen.concat("4");
  259. }
  260. else
  261. {
  262. frameOpen = frameOpen.concat(lev);
  263. }
  264. frameOpen = frameOpen.concat("#");
  265. frameOpen = frameOpen.concat(interfac);
  266. frameOpen = frameOpen.concat("##");
  267. lengthFrameOpen = frameOpen.length();
  268. // elimino i caratteri di controllo ....
  269. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  270. lengthFrameOpen--;
  271. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  272. lengthFrameOpen--;
  273. // controlla se sintassi corretta ...
  274. isCorrect();
  275. }
  276. /**
  277. * Crea il messaggio OPEN *#chi*dove*grandezza##
  278. *
  279. * @param who
  280. * Campo chi
  281. * @param where
  282. * Campo dove
  283. * @param dimension
  284. * Campo grandezza
  285. */
  286. public void CreateDimensionMsgOpen(String who, String where, String dimension)
  287. {
  288. // richiamo la procedura CreateNullMsgOpen()
  289. createNullMsgOpen();
  290. // creo il messaggio open
  291. frameOpen = "*#";
  292. frameOpen = frameOpen.concat(who);
  293. frameOpen = frameOpen.concat("*");
  294. frameOpen = frameOpen.concat(where);
  295. // per togliere l'asterisco finale
  296. if (!dimension.equals(""))
  297. {
  298. frameOpen = frameOpen.concat("*");
  299. }
  300. frameOpen = frameOpen.concat(dimension);
  301. frameOpen = frameOpen.concat("##");
  302. lengthFrameOpen = frameOpen.length();
  303. // elimino i caratteri di controllo ....
  304. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  305. lengthFrameOpen--;
  306. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  307. lengthFrameOpen--;
  308. // controlla se sintassi corretta ...
  309. isCorrect();
  310. }
  311. /**
  312. * Crea il messaggio OPEN *#chi*dove#livello#interfaccia*grandezza##
  313. *
  314. * @param who
  315. * Campo chi
  316. * @param where
  317. * Campo dove
  318. * @param lev
  319. * Campo livello
  320. * @param interfac
  321. * Campo interfaccia
  322. * @param dimension
  323. * Campo grandezza
  324. */
  325. public void CreateDimensionMsgOpen(String who, String where, String lev, String interfac, String dimension)
  326. {
  327. // richiamo la procedura CreateNullMsgOpen()
  328. createNullMsgOpen();
  329. frameOpen = "*#";
  330. frameOpen = frameOpen.concat(who);
  331. frameOpen = frameOpen.concat("*");
  332. frameOpen = frameOpen.concat(where);
  333. frameOpen = frameOpen.concat("#");
  334. if (lev.equals(""))
  335. {
  336. frameOpen = frameOpen.concat("4");
  337. }
  338. else
  339. {
  340. frameOpen = frameOpen.concat(lev);
  341. }
  342. frameOpen = frameOpen.concat("#");
  343. frameOpen = frameOpen.concat(interfac);
  344. // per togliere l'asterisco finale
  345. if (!dimension.equals(""))
  346. {
  347. frameOpen = frameOpen.concat("*");
  348. }
  349. frameOpen = frameOpen.concat(dimension);
  350. frameOpen = frameOpen.concat("##");
  351. lengthFrameOpen = frameOpen.length();
  352. // elimino i caratteri di controllo ....
  353. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  354. lengthFrameOpen--;
  355. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  356. lengthFrameOpen--;
  357. // controlla se sintassi corretta ...
  358. isCorrect();
  359. }
  360. /**
  361. * Crea il messaggio OPEN *#chi*dove*#grandezza*val_1*val_2*....*val_n##
  362. *
  363. * @param who
  364. * Campo chi
  365. * @param where
  366. * Campo dove
  367. * @param dimension
  368. * Campo grandezza
  369. * @param value
  370. * Campo contenente i valori
  371. * @param numValori
  372. * Numero di valori
  373. */
  374. public void CreateWrDimensionMsgOpen(String who, String where, String dimension, String value[], int numValue)
  375. {
  376. // richiamo la procedura CreateNullMsgOpen()
  377. createNullMsgOpen();
  378. // creo il messaggio open
  379. frameOpen = "*#";
  380. frameOpen = frameOpen.concat(who);
  381. frameOpen = frameOpen.concat("*");
  382. frameOpen = frameOpen.concat(where);
  383. frameOpen = frameOpen.concat("*#");
  384. frameOpen = frameOpen.concat(dimension);
  385. for (int i = 0; i < numValue; i++)
  386. {
  387. frameOpen = frameOpen.concat("*");
  388. frameOpen = frameOpen.concat(value[i]);
  389. }
  390. frameOpen = frameOpen.concat("##");
  391. lengthFrameOpen = frameOpen.length();
  392. // elimino i caratteri di controllo ....
  393. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  394. lengthFrameOpen--;
  395. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  396. lengthFrameOpen--;
  397. // controlla se sintassi corretta ...
  398. isCorrect();
  399. }
  400. /**
  401. * Crea il messaggio OPEN
  402. * *#chi*dove#livello#interfaccia*#grandezza*val_1*val_2*....*val_n##
  403. *
  404. * @param who
  405. * Campo chi
  406. * @param where
  407. * Campo dove
  408. * @param lev
  409. * Campo livello
  410. * @param interfac
  411. * Campo interfaccia
  412. * @param dimension
  413. * Campo grandezza
  414. * @param value
  415. * Campo contenente i valori
  416. * @param numValori
  417. * Numero di valori
  418. */
  419. public void CreateWrDimensionMsgOpen(String who, String where, String lev, String interfac, String dimension,
  420. String value[], int numValue)
  421. {
  422. // richiamo la procedura CreateNullMsgOpen()
  423. createNullMsgOpen();
  424. // creo il messaggio open
  425. frameOpen = "*#";
  426. frameOpen = frameOpen.concat(who);
  427. frameOpen = frameOpen.concat("*");
  428. frameOpen = frameOpen.concat(where);
  429. frameOpen = frameOpen.concat("#");
  430. if (lev.equals(""))
  431. {
  432. frameOpen = frameOpen.concat("4");
  433. }
  434. else
  435. {
  436. frameOpen = frameOpen.concat(lev);
  437. }
  438. frameOpen = frameOpen.concat("#");
  439. frameOpen = frameOpen.concat(interfac);
  440. frameOpen = frameOpen.concat("*#");
  441. frameOpen = frameOpen.concat(dimension);
  442. for (int i = 0; i < numValue; i++)
  443. {
  444. frameOpen = frameOpen.concat("*");
  445. frameOpen = frameOpen.concat(value[i]);
  446. }
  447. frameOpen = frameOpen.concat("##");
  448. lengthFrameOpen = frameOpen.length();
  449. // elimino i caratteri di controllo ....
  450. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  451. lengthFrameOpen--;
  452. if ((frameOpen.charAt(lengthFrameOpen - 1) == '\n') || ((frameOpen.charAt(lengthFrameOpen - 1) == '\r')))
  453. lengthFrameOpen--;
  454. // controlla se sintassi corretta ...
  455. isCorrect();
  456. }
  457. /**
  458. * Crea il messaggio OPEN ****##
  459. *
  460. */
  461. public void createNullMsgOpen()
  462. {
  463. // azzera tutto
  464. frameOpen = null;
  465. tipoFrame = NULL_FRAME;
  466. lengthFrameOpen = 0;
  467. estesa = false;
  468. // azzera tutto
  469. // numIndirizzo = 0;
  470. // for (i = 0; i < MAX_INDIRIZZO; i++)
  471. // memset(indirizzo[i], '\0', indirizzo[i].length);
  472. // numValori = 0;
  473. // for (i = 0; i < MAX_NUM_VALORI; i++)
  474. // memset(valori[i], '\0', valori[i].length);
  475. chi = "";
  476. cosa = "";
  477. dove = "";
  478. livello = "";
  479. interfaccia = "";
  480. quando = "";
  481. grandezza = "";
  482. }
  483. // public boolean isEqual(OpenWebNet msgToCompare){
  484. // // controlla se sintassi corretta ...
  485. // isCorrect();
  486. //
  487. // //conttrollo che sia la stessa tipologia
  488. // if(msgToCompare.tipoFrame != tipoFrame)
  489. // return false;
  490. //
  491. // //controllo che siano entrambe due frame estese o meno
  492. // if(msgToCompare.estesa != estesa)
  493. // return false;
  494. //
  495. // if(!estesa)
  496. // {
  497. // if ((msgToCompare.getChi() == chi) &&
  498. // (msgToCompare.getCosa() == cosa) &&
  499. // (msgToCompare.getDove() == dove) &&
  500. // (msgToCompare.getQuando() == quando) &&
  501. // (msgToCompare.getGrandezza() == grandezza))
  502. //
  503. //
  504. // return true;
  505. // else
  506. // return false;
  507. // }
  508. // else
  509. // {
  510. // System.out.println("%%%%%%%%%%%%");
  511. // System.out.println(msgToCompare.getChi()+" "+chi);
  512. // System.out.println(msgToCompare.getCosa()+" "+cosa);
  513. // System.out.println(msgToCompare.getDove()+" "+dove);
  514. // System.out.println(msgToCompare.getLivello()+" "+livello);
  515. // System.out.println(msgToCompare.getInterfaccia()+" "+interfaccia);
  516. // System.out.println(msgToCompare.getQuando()+" "+quando);
  517. // System.out.println(msgToCompare.getGrandezza()+" "+grandezza);
  518. // if ((msgToCompare.getChi().equals(chi)) &&
  519. // ((String)msgToCompare.getCosa() == (String)cosa) &&
  520. // ((String)msgToCompare.getDove() == dove) &&
  521. // ((String)msgToCompare.getLivello() == livello) &&
  522. // ((String)msgToCompare.getInterfaccia() == interfaccia) &&
  523. // ((String)msgToCompare.getQuando() == quando) &&
  524. // ((String)msgToCompare.getGrandezza() == grandezza))
  525. // return true;
  526. // else
  527. // return false;
  528. // }
  529. // }
  530. /**
  531. * Esegue il controllo sintattico
  532. */
  533. private void isCorrect()
  534. {
  535. int j = 0;
  536. int i = 0;
  537. // char sup[] = new char[MAX_LENGTH_OPEN];
  538. // char campo[] = new char[MAX_LENGTH];
  539. String sup = null;
  540. String campo = null;
  541. // se frame ACK -->
  542. if (frameOpen.equals(MSG_OPEN_OK))
  543. {
  544. // System.out.println("frame di tipo ack");
  545. tipoFrame = OK_FRAME;
  546. return;
  547. }
  548. // se frame NACK -->
  549. if (frameOpen.equals(MSG_OPEN_KO))
  550. {
  551. // System.out.println("frame di tipo nack");
  552. tipoFrame = KO_FRAME;
  553. return;
  554. }
  555. // se il primo carattere non è *
  556. // oppure la frame è troppo lunga
  557. // oppure se non termina con due '#'
  558. if ((frameOpen.charAt(0) != '*') || (lengthFrameOpen > MAX_LENGTH_OPEN)
  559. || (frameOpen.charAt(lengthFrameOpen - 1) != '#') || (frameOpen.charAt(lengthFrameOpen - 2) != '#'))
  560. {
  561. System.out.println("*** FRAME ERRORE ***");
  562. tipoFrame = ERROR_FRAME;
  563. return;
  564. }
  565. // Controllo se sono stati digitati dei caratteri
  566. for (j = 0; j < lengthFrameOpen; j++)
  567. {
  568. if (!Character.isDigit(frameOpen.charAt(j)))
  569. {
  570. if ((frameOpen.charAt(j) != '*') && (frameOpen.charAt(j) != '#'))
  571. {
  572. System.out.println("°°° FRAME ERROR °°°");
  573. tipoFrame = ERROR_FRAME;
  574. return;
  575. }
  576. }
  577. }
  578. // frame normale ...
  579. // *chi#indirizzo*cosa*dove#livello#indirizzo*quando##
  580. if (frameOpen.charAt(1) != '#')
  581. {
  582. // System.out.println("frame normale");
  583. tipoFrame = NORMAL_FRAME;
  584. // estraggo i vari campi della frame open nella prima modalità
  585. // (chi+indirizzo e dove+livello+interfaccia)
  586. assegnaChiCosaDoveQuando();
  587. // estraggo gli eventuali valori di indirizzo
  588. assegnaIndirizzo();
  589. // estraggo gli eventuali valori di livello ed interfaccia
  590. assegnaLivelloInterfaccia();
  591. return;
  592. }
  593. // frame password ...
  594. // *#pwd##
  595. if (contains(frameOpen.substring(2), '*') == false)
  596. {
  597. // System.out.println("frame password");
  598. tipoFrame = PWD_FRAME;
  599. // estraggo il chi
  600. assegnaChi();
  601. return;
  602. }
  603. // per le altre tipologie di frame
  604. sup = null;
  605. sup = frameOpen.substring(2, frameOpen.length());
  606. // sprintf(sup, "%s", frameOpen+2);
  607. campo = null;
  608. i = 0;
  609. while (sup.charAt(i) != '*')
  610. {
  611. i++;
  612. }
  613. campo = sup.substring(0, i);
  614. // sprintf(campo, "%s", strtok(sup, "*"));
  615. sup = null;
  616. sup = frameOpen.substring(2 + campo.length() + 1, frameOpen.length());
  617. // sprintf(sup, "%s", frameOpen+2+strlen(campo)+1);
  618. if (sup.charAt(0) != '*')
  619. {
  620. i = 0;
  621. boolean trovato = false;
  622. while (i < sup.length())
  623. {
  624. if (sup.charAt(i) == '*')
  625. {
  626. trovato = true;
  627. break;
  628. }
  629. i++;
  630. }
  631. if (trovato)
  632. campo = campo.concat(sup.substring(0, i));
  633. // sprintf(campo, "%s%s", campo, strtok(sup, "*"));
  634. sup = null;
  635. sup = frameOpen.substring(2 + campo.length() + 1, frameOpen.length());
  636. // sprintf(sup, "%s", frameOpen+2+strlen(campo)+1);
  637. }
  638. // frame richiesta state ...
  639. // *#chi*dove##
  640. if (sup.charAt(0) != '*')
  641. {
  642. // System.out.println("frame state");
  643. tipoFrame = STATE_FRAME;
  644. // estraggo i vari campi della frame open nella prima modalit�
  645. // (chi+indirizzo e dove+livello+interfaccia)
  646. assegnaChiDove();
  647. // estraggo gli eventuali valori di indirizzo
  648. assegnaIndirizzo();
  649. // estraggo gli eventuali valori di livello ed interfaccia
  650. assegnaLivelloInterfaccia();
  651. return;
  652. }
  653. else
  654. {
  655. // frame di richiesta misura ...
  656. // *#chi*dove*grandezza## o *#chi*dove*#grandezza*valore_N�##
  657. if (sup.charAt(1) != '#')
  658. {
  659. // System.out.println("Measure state");
  660. tipoFrame = MEASURE_FRAME;
  661. // estraggo i vari campi della frame open nella prima modalit�
  662. // (chi+indirizzo e dove+livello+interfaccia)
  663. assegnaChiDoveGrandezza();
  664. // estraggo gli eventuali valori di indirizzo
  665. assegnaIndirizzo();
  666. // estraggo gli eventuali valori di livello ed interfaccia
  667. assegnaLivelloInterfaccia();
  668. return;
  669. }
  670. // frame di scrittura grandezza ...
  671. // *#chi*dove*#grandezza*valore_N�##
  672. else
  673. {
  674. // System.out.println("frame write");
  675. tipoFrame = WRITE_FRAME;
  676. // estraggo i vari campi della frame open nella prima modalit�
  677. // (chi+indirizzo e dove+livello+interfaccia)
  678. assegnaChiDoveGrandezzaValori();
  679. // estraggo gli eventuali valori di indirizzo
  680. assegnaIndirizzo();
  681. // estraggo gli eventuali valori di livello ed interfaccia
  682. assegnaLivelloInterfaccia();
  683. return;
  684. }
  685. }
  686. }
  687. /**
  688. * Assegna chi dove e la grandezza richiesta per le frame di richiesta
  689. * grandezze
  690. *
  691. */
  692. private void assegnaChiDoveGrandezza()
  693. {
  694. // System.out.println("assegno chi dove grandezza");
  695. // char sup[MAX_LENGTH_OPEN];
  696. String sup = null;
  697. int len = 0;
  698. int j = 0;
  699. int i = 0;
  700. // CHI
  701. sup = null;
  702. sup = frameOpen.substring(2, frameOpen.length());
  703. // sprintf(sup, "%s", frameOpen+2);
  704. if (sup.charAt(0) != '*')
  705. {
  706. i = 0;
  707. while (sup.charAt(i) != '*')
  708. {
  709. i++;
  710. }
  711. chi = sup.substring(0, i);
  712. // sprintf(chi, "%s", strtok(sup, "*"));
  713. }
  714. // DOVE
  715. sup = null;
  716. sup = frameOpen.substring(2 + chi.length() + 1, frameOpen.length());
  717. // sprintf(sup, "%s", frameOpen+2+strlen(chi)+1);
  718. if (contains(sup, '*') == false)
  719. {
  720. dove = sup.substring(0, sup.length() - 2);
  721. // strncpy(dove, sup, strlen(sup)-2);
  722. }
  723. else
  724. {
  725. if (sup.charAt(0) != '*')
  726. {
  727. i = 0;
  728. while (sup.charAt(i) != '*')
  729. {
  730. i++;
  731. }
  732. dove = sup.substring(0, i);
  733. // sprintf(dove, "%s", strtok(sup, "*"));
  734. }
  735. // GRANDEZZA
  736. sup = null;
  737. sup = frameOpen.substring(2 + chi.length() + 1 + dove.length() + 1, frameOpen.length());
  738. // sprintf(sup, "%s", frameOpen+2+strlen(chi)+1+strlen(dove)+1);
  739. if (contains(sup, '*') == false)
  740. {
  741. grandezza = sup.substring(0, sup.length() - 2);
  742. // strncpy(grandezza, sup, strlen(sup)-2);
  743. }
  744. else
  745. {
  746. if (sup.charAt(0) != '*')
  747. {
  748. i = 0;
  749. while (sup.charAt(i) != '*')
  750. {
  751. i++;
  752. }
  753. grandezza = sup.substring(0, i);
  754. // sprintf(grandezza, "%s", strtok(sup, "*"));
  755. }
  756. // VALORI
  757. sup = null;
  758. sup = frameOpen.substring(2 + chi.length() + 1 + dove.length() + 1 + grandezza.length() + 1,
  759. frameOpen.length());
  760. // sprintf(sup, "%s",
  761. // frameOpen+2+strlen(chi)+1+strlen(dove)+1+strlen(grandezza)+1);
  762. j = 0;
  763. len = 2 + chi.length() + 1 + dove.length() + 1 + grandezza.length() + 1;
  764. // len = 2+strlen(chi)+1+strlen(dove)+1+strlen(grandezza)+1;
  765. while (contains(sup, '*') != false)
  766. {
  767. i = 0;
  768. while (sup.charAt(i) != '*')
  769. {
  770. i++;
  771. }
  772. valori[j] = sup.substring(0, i);
  773. // sprintf(valori[j], "%s", strtok(sup, "*"));
  774. sup = null;
  775. len = len + valori[j].length() + 1;
  776. sup = frameOpen.substring(len, frameOpen.length());
  777. // sprintf(sup, "%s", frameOpen+len);
  778. j++;
  779. }
  780. valori[j] = sup.substring(sup.length() - 2, sup.length());
  781. // strncpy(valori[j], sup, strlen(sup)-2);
  782. }
  783. }
  784. // assegno numero valori
  785. numValori = j + 1;
  786. return;
  787. }
  788. /**
  789. * Assegna chi e dove per le frame di richiesta state
  790. *
  791. */
  792. private void assegnaChiDove()
  793. {
  794. // System.out.println("assegno chi dove");
  795. // char sup[MAX_LENGTH_OPEN];
  796. String sup = null;
  797. int i = 0;
  798. // CHI
  799. sup = null;
  800. sup = frameOpen.substring(2, frameOpen.length());
  801. // sprintf(sup, "%s", frameOpen+2);
  802. if (sup.charAt(0) != '*')
  803. {
  804. i = 0;
  805. while (sup.charAt(i) != '*')
  806. {
  807. i++;
  808. }
  809. chi = sup.substring(0, i);
  810. // sprintf(chi, "%s", strtok(sup, "*"));
  811. }
  812. // DOVE
  813. sup = null;
  814. sup = frameOpen.substring(2 + chi.length() + 1, frameOpen.length());
  815. // sprintf(sup, "%s", frameOpen+2+strlen(chi)+1);
  816. if (contains(sup, '*') == false)
  817. {
  818. dove = sup.substring(0, sup.length() - 2);
  819. // strncpy(dove, sup, strlen(sup)-2);
  820. }
  821. else
  822. {
  823. if (sup.charAt(0) != '*')
  824. {
  825. i = 0;
  826. while (sup.charAt(i) != '*')
  827. {
  828. i++;
  829. }
  830. dove = sup.substring(0, i);
  831. // sprintf(dove, "%s", strtok(sup, "*"));
  832. }
  833. }
  834. return;
  835. }
  836. /**
  837. * Assegna chi cosa dove e quando per le frame "normali"
  838. *
  839. */
  840. private void assegnaChiCosaDoveQuando()
  841. {
  842. // System.out.println("assegno chi cosa dove quando");
  843. int i = 0;
  844. String sup = null;
  845. // System.out.println("chi prima "+chi);
  846. // CHI
  847. // copio in temp la frame open togliendo il primo carattere, dovrebbe
  848. // essere *
  849. try
  850. {
  851. sup = frameOpen.substring(1, frameOpen.length());
  852. if (sup.charAt(0) != '#')
  853. {
  854. i = 0;
  855. while (Character.getType(sup.charAt(i)) == Character.DECIMAL_DIGIT_NUMBER)
  856. {
  857. i++;
  858. }
  859. chi = sup.substring(0, i);
  860. }
  861. // System.out.println("Chi: "+ chi);
  862. // COSA
  863. sup = null;
  864. sup = frameOpen.substring(1 + chi.length() + 1, frameOpen.length());
  865. if (contains(sup, '*') == false)
  866. cosa = sup.substring(0, sup.length() - 2);
  867. else
  868. {
  869. if (sup.charAt(0) != '*')
  870. {
  871. i = 0;
  872. while (Character.getType(sup.charAt(i)) == Character.DECIMAL_DIGIT_NUMBER)
  873. {
  874. i++;
  875. }
  876. cosa = sup.substring(0, i);
  877. }
  878. else
  879. {
  880. cosa = "";
  881. }
  882. // System.out.println("Cosa: "+ cosa);
  883. // DOVE
  884. sup = null;
  885. sup = frameOpen.substring(1 + chi.length() + 1 + cosa.length() + 1, frameOpen.length());
  886. if (contains(sup, '*') == false)
  887. {
  888. dove = sup.substring(0, sup.length() - 2);
  889. }
  890. else
  891. {
  892. if (sup.charAt(0) != '*')
  893. {
  894. i = 0;
  895. while (Character.getType(sup.charAt(i)) == Character.DECIMAL_DIGIT_NUMBER)
  896. {
  897. i++;
  898. }
  899. dove = sup.substring(0, i);
  900. }
  901. // System.out.println("Dove: "+ dove);
  902. // System.out.println("chi "+chi);
  903. // System.out.println("cosa "+cosa);
  904. // QUANDO
  905. sup = null;
  906. sup = frameOpen.substring(1 + chi.length() + 1 + cosa.length() + 1 + dove.length() + 1,
  907. frameOpen.length());
  908. if (contains(sup, '*') == false)
  909. {
  910. quando = sup.substring(0, sup.length() - 2);
  911. }
  912. else
  913. {
  914. if (sup.charAt(0) != '*')
  915. {
  916. i = 0;
  917. while (Character.getType(sup.charAt(i)) == Character.DECIMAL_DIGIT_NUMBER)
  918. {
  919. i++;
  920. }
  921. quando = sup.substring(0, i);
  922. }
  923. // System.out.println("Quando: "+ quando);
  924. }
  925. }
  926. }
  927. }
  928. catch (StringIndexOutOfBoundsException e)
  929. {
  930. System.out.println("Eccezione1");
  931. tipoFrame = ERROR_FRAME;
  932. }
  933. return;
  934. }
  935. /**
  936. * Assegna chi dove grandezza e i valori per le frame di scrittura grandezze
  937. *
  938. */
  939. private void assegnaChiDoveGrandezzaValori()
  940. {
  941. // System.out.println("assegno chi dove grandezza valori");
  942. // char sup[MAX_LENGTH_OPEN];
  943. String sup = null;
  944. int len = 0;
  945. int j = 0;
  946. int i = 0;
  947. // CHI
  948. sup = null;
  949. sup = frameOpen.substring(2, frameOpen.length());
  950. // sprintf(sup, "%s", frameOpen+2);
  951. if (sup.charAt(0) != '*')
  952. {
  953. i = 0;
  954. while (sup.charAt(i) != '*')
  955. {
  956. i++;
  957. }
  958. chi = sup.substring(0, i);
  959. // sprintf(chi, "%s", strtok(sup, "*"));
  960. }
  961. // DOVE
  962. sup = null;
  963. sup = frameOpen.substring(2 + chi.length() + 1, frameOpen.length());
  964. // sprintf(sup, "%s", frameOpen+2+strlen(chi)+1);
  965. if (contains(sup, '*') == false)
  966. {
  967. dove = sup.substring(0, sup.length() - 2);
  968. // strncpy(dove, sup, strlen(sup)-2);
  969. }
  970. else
  971. {
  972. if (sup.charAt(0) != '*')
  973. {
  974. i = 0;
  975. while (sup.charAt(i) != '*')
  976. {
  977. i++;
  978. }
  979. dove = sup.substring(0, i);
  980. // sprintf(dove, "%s", strtok(sup, "*"));
  981. }
  982. // GRANDEZZA
  983. sup = null;
  984. sup = frameOpen.substring(2 + chi.length() + 1 + dove.length() + 2, frameOpen.length());
  985. // sprintf(sup, "%s", frameOpen+2+strlen(chi)+1+strlen(dove)+2);
  986. if (contains(sup, '*') == false)
  987. {
  988. tipoFrame = ERROR_FRAME;
  989. }
  990. else
  991. {
  992. if (sup.charAt(0) != '*')
  993. {
  994. i = 0;
  995. while (sup.charAt(i) != '*')
  996. {
  997. i++;
  998. }
  999. grandezza = sup.substring(0, i);
  1000. // sprintf(grandezza, "%s", strtok(sup, "*"));
  1001. }
  1002. // VALORI
  1003. sup = null;
  1004. sup = frameOpen.substring(2 + chi.length() + 1 + dove.length() + 2 + grandezza.length() + 1,
  1005. frameOpen.length());
  1006. // sprintf(sup, "%s",
  1007. // frameOpen+2+strlen(chi)+1+strlen(dove)+2+strlen(grandezza)+1);
  1008. j = 0;
  1009. len = 2 + chi.length() + 1 + dove.length() + 2 + grandezza.length() + 1;
  1010. while (contains(sup, '*') != false)
  1011. {
  1012. i = 0;
  1013. while (sup.charAt(i) != '*')
  1014. {
  1015. i++;
  1016. }
  1017. valori[j] = sup.substring(0, i);
  1018. // sprintf(valori[j], "%s", strtok(sup, "*"));
  1019. sup = null;
  1020. len = len + valori[j].length() + 1;
  1021. sup = frameOpen.substring(len, frameOpen.length());
  1022. // sprintf(sup, "%s", frameOpen+len);
  1023. j++;
  1024. }
  1025. valori[j] = sup.substring(0, sup.length() - 2);
  1026. // strncpy(valori[j], sup, strlen(sup)-2);
  1027. }
  1028. }
  1029. // assegno numero valori
  1030. numValori = j + 1;
  1031. return;
  1032. }
  1033. /**
  1034. * Assegna chi per le frame di risultato elaborazione password
  1035. *
  1036. */
  1037. private void assegnaChi()
  1038. {
  1039. // System.out.println("assegno chi");
  1040. int i = 0;
  1041. String sup = null;
  1042. // CHI
  1043. sup = frameOpen.substring(2, frameOpen.length());
  1044. // sprintf(sup, "%s", frameOpen+2);
  1045. if (sup.charAt(0) != '#')
  1046. {
  1047. i = 0;
  1048. while (sup.charAt(i) != '#')
  1049. {
  1050. i++;
  1051. }
  1052. chi = sup.substring(0, i);
  1053. // sprintf(chi, "%s", strtok(sup, "#"));
  1054. }
  1055. else
  1056. {
  1057. tipoFrame = ERROR_FRAME;
  1058. }
  1059. sup = null;
  1060. sup = frameOpen.substring(2 + chi.length(), frameOpen.length());
  1061. // sprintf(sup, "%s", frameOpen+2+strlen(chi));
  1062. if (sup.charAt(1) != '#')
  1063. {
  1064. tipoFrame = ERROR_FRAME;
  1065. }
  1066. return;
  1067. }
  1068. /**
  1069. * Assegna livello, interfaccia per le frame estese
  1070. *
  1071. */
  1072. private void assegnaLivelloInterfaccia()
  1073. {
  1074. // System.out.println("assegno livello interfaccia");
  1075. String sup = null;
  1076. String orig = null;
  1077. int i = 0;
  1078. // DOVE
  1079. if (!dove.equals(""))
  1080. {
  1081. if (dove.charAt(0) == '#')
  1082. {
  1083. sup = dove.substring(1, dove.length());
  1084. // sprintf(sup, "%s", dove+1);
  1085. }
  1086. else
  1087. {
  1088. sup = dove;
  1089. // sprintf(sup, "%s", dove);
  1090. }
  1091. orig = null;
  1092. orig = dove;
  1093. // sprintf(orig, "%s", dove);
  1094. if (contains(sup, '#') != false)
  1095. {
  1096. estesa = true;
  1097. dove = null;
  1098. if (orig.charAt(0) == '#')
  1099. {
  1100. i = 0;
  1101. while (sup.charAt(i) != '#')
  1102. {
  1103. i++;
  1104. }
  1105. // mao da vedere se è giusta____cos'è "#%s" ?
  1106. dove = sup.substring(0, i);
  1107. // System.out.println("Dove$$$$$$$:"+dove);
  1108. // sprintf(dove, "#%s", strtok(sup, "#"));
  1109. }
  1110. else
  1111. {
  1112. i = 0;
  1113. while (sup.charAt(i) != '#')
  1114. {
  1115. i++;
  1116. }
  1117. dove = sup.substring(0, i);
  1118. // sprintf(dove, "%s", strtok(sup, "#"));
  1119. }
  1120. // LIVELLO + INTERFACCIA
  1121. sup = null;
  1122. sup = orig.substring(dove.length() + 1, orig.length());
  1123. // sprintf(sup, "%s", orig+strlen(dove)+1);
  1124. if (contains(sup, '#') != false)
  1125. {
  1126. i = 0;
  1127. while (sup.charAt(i) != '#')
  1128. {
  1129. i++;
  1130. }
  1131. livello = sup.substring(0, i);
  1132. // sprintf(livello, "%s", strtok(sup, "#"));
  1133. interfaccia = orig.substring(dove.length() + 1 + livello.length() + 1);
  1134. // sprintf(interfaccia, "%s",
  1135. // orig+strlen(dove)+1+strlen(livello)+1);
  1136. if (interfaccia.length() == 0)
  1137. tipoFrame = ERROR_FRAME;
  1138. }
  1139. else
  1140. tipoFrame = ERROR_FRAME;
  1141. }
  1142. }
  1143. else
  1144. { // il campo dove è vuoto
  1145. }
  1146. return;
  1147. }
  1148. /**
  1149. * Assegna indirizzo
  1150. *
  1151. */
  1152. private void assegnaIndirizzo()
  1153. {
  1154. // System.out.println("assegno indirizzo");
  1155. int i = 0;
  1156. String sup = null;
  1157. String orig = null;
  1158. // CHI
  1159. sup = chi;
  1160. orig = chi;
  1161. if (contains(sup, '#') != false)
  1162. {
  1163. chi = null;
  1164. i = 0;
  1165. while (sup.charAt(i) != '#')
  1166. {
  1167. i++;
  1168. }
  1169. chi = sup.substring(0, i);
  1170. // sprintf(chi, "%s", strtok(sup, "#"));
  1171. // INDIRIZZO
  1172. numIndirizzo++;
  1173. sup = null;
  1174. sup = orig.substring(chi.length() + 1, orig.length());
  1175. // sprintf(sup, "%s", orig+strlen(chi)+1);
  1176. if (contains(sup, '#') == false)
  1177. {
  1178. // solo indirizzo seriale
  1179. if (sup.length() != 0)
  1180. {
  1181. indirizzo[0] = sup;
  1182. // sprintf(indirizzo[0], "%s", sup);
  1183. }
  1184. else
  1185. {
  1186. tipoFrame = ERROR_FRAME;
  1187. }
  1188. }
  1189. else
  1190. {
  1191. // indirizzo IP
  1192. i = 0;
  1193. while (sup.charAt(i) != '#')
  1194. {
  1195. i++;
  1196. }
  1197. indirizzo[0] = sup.substring(0, i);
  1198. // sprintf(indirizzo[0], "%s", strtok(sup, "#"));
  1199. sup = null;
  1200. sup = orig.substring(chi.length() + 1 + indirizzo[0].length() + 1, orig.length());
  1201. // sprintf(sup, "%s",
  1202. // orig+strlen(chi)+1+strlen(indirizzo[0])+1);
  1203. if (contains(sup, '#') != false)
  1204. {
  1205. // indirizzo IP
  1206. i = 0;
  1207. while (sup.charAt(i) != '#')
  1208. {
  1209. i++;
  1210. }
  1211. indirizzo[1] = sup.substring(0, i);
  1212. // sprintf(indirizzo[1], "%s", strtok(sup, "#"));
  1213. sup = null;
  1214. sup = orig.substring(chi.length() + 1 + indirizzo[0].length() + 1 + indirizzo[1].length() + 1,
  1215. orig.length());
  1216. // sprintf(sup, "%s",
  1217. // orig+strlen(chi)+1+strlen(indirizzo[0])+1+strlen(indirizzo[1])+1);
  1218. if (contains(sup, '#') != false)
  1219. {
  1220. // indirizzo IP
  1221. i = 0;
  1222. while (sup.charAt(i) != '#')
  1223. {
  1224. i++;
  1225. }
  1226. indirizzo[2] = sup.substring(0, i);
  1227. // sprintf(indirizzo[2], "%s", strtok(sup, "#"));
  1228. sup = null;
  1229. sup = orig.substring(chi.length() + 1 + indirizzo[0].length() + 1 + indirizzo[1].length() + 1
  1230. + indirizzo[2].length() + 1, orig.length());
  1231. // sprintf(sup, "%s",
  1232. // orig+strlen(chi)+1+strlen(indirizzo[0])+1+strlen(indirizzo[1])+1+strlen(indirizzo[2])+1);
  1233. if (contains(sup, '#') == false)
  1234. {
  1235. // indirizzo IP
  1236. if (sup.length() != 0)
  1237. {
  1238. indirizzo[3] = sup;
  1239. // sprintf(indirizzo[3], "%s", sup);
  1240. }
  1241. else
  1242. {
  1243. tipoFrame = ERROR_FRAME;
  1244. }
  1245. }
  1246. else
  1247. tipoFrame = ERROR_FRAME;
  1248. }
  1249. else
  1250. tipoFrame = ERROR_FRAME;
  1251. }
  1252. else
  1253. tipoFrame = ERROR_FRAME;
  1254. }
  1255. }
  1256. return;
  1257. }
  1258. /**
  1259. * Verifica se in una stringa c'è un determinato carattere
  1260. *
  1261. * @param testo
  1262. * Stringa da controllare
  1263. * @param c
  1264. * Carattere da cercare in testo
  1265. * @return True se testo contiene c; False altrimenti
  1266. */
  1267. private boolean contains(String testo, char c)
  1268. {
  1269. int i = 0;
  1270. while (i != testo.length())
  1271. {
  1272. if (testo.charAt(i) == c)
  1273. return true;
  1274. i++;
  1275. }
  1276. return false;
  1277. }
  1278. /**
  1279. * @return Returns the chi.
  1280. */
  1281. public String getChi()
  1282. {
  1283. return chi;
  1284. }
  1285. /**
  1286. * @return Returns the cosa.
  1287. */
  1288. public String getCosa()
  1289. {
  1290. return cosa;
  1291. }
  1292. /**
  1293. * @return Returns the dove.
  1294. */
  1295. public String getDove()
  1296. {
  1297. return dove;
  1298. }
  1299. /**
  1300. * @return Returns the estesa.
  1301. */
  1302. public boolean isEstesa()
  1303. {
  1304. return estesa;
  1305. }
  1306. /**
  1307. * @return Returns the frameOpen.
  1308. */
  1309. public String getFrameOpen()
  1310. {
  1311. return frameOpen;
  1312. }
  1313. /**
  1314. * @return Returns the grandezza.
  1315. */
  1316. public String getGrandezza()
  1317. {
  1318. return grandezza;
  1319. }
  1320. /**
  1321. * @return Returns the interfaccia.
  1322. */
  1323. public String getInterfaccia()
  1324. {
  1325. return interfaccia;
  1326. }
  1327. /**
  1328. * @return Returns the lengthFrameOpen.
  1329. */
  1330. public int getLengthFrameOpen()
  1331. {
  1332. return lengthFrameOpen;
  1333. }
  1334. /**
  1335. * @return Returns the tipoFrame.
  1336. */
  1337. public int getTipoFrame()
  1338. {
  1339. return tipoFrame;
  1340. }
  1341. /**
  1342. * @return Returns the quando.
  1343. */
  1344. public String getQuando()
  1345. {
  1346. return quando;
  1347. }
  1348. /**
  1349. * @return Returns the indirizzo.
  1350. */
  1351. public String getIndirizzo(int i)
  1352. {
  1353. return indirizzo[i];
  1354. }
  1355. /**
  1356. * @return Returns the valori.
  1357. */
  1358. public String getValori(int i)
  1359. {
  1360. return valori[i];
  1361. }
  1362. /**
  1363. * @return Returns the livello.
  1364. */
  1365. public String getLivello()
  1366. {
  1367. return livello;
  1368. }
  1369. /**
  1370. * @param dove
  1371. * The dove to set.
  1372. */
  1373. public void setDove(String dove)
  1374. {
  1375. this.dove = dove;
  1376. }
  1377. // tipo di frame ?
  1378. /**
  1379. *
  1380. * @return True se la frame è di tipo ERROR_FRAME; False altrimenti
  1381. */
  1382. public boolean isErrorFrame()
  1383. {
  1384. return (tipoFrame == ERROR_FRAME);
  1385. }
  1386. /**
  1387. *
  1388. * @return True se la frame è di tipo NULL_FRAME; False altrimenti
  1389. */
  1390. public boolean isNullFrame()
  1391. {
  1392. return (tipoFrame == NULL_FRAME);
  1393. }
  1394. /**
  1395. *
  1396. * @return True se la frame è di tipo NORMAL_FRAME; False altrimenti
  1397. */
  1398. public boolean isNormalFrame()
  1399. {
  1400. return (tipoFrame == NORMAL_FRAME);
  1401. }
  1402. /**
  1403. *
  1404. * @return True se la frame è di tipo MEASURE_FRAME; False altrimenti
  1405. */
  1406. public boolean isMeasureFrame()
  1407. {
  1408. return (tipoFrame == MEASURE_FRAME);
  1409. }
  1410. /**
  1411. *
  1412. * @return True se la frame è di tipo STATE_FRAME; False altrimenti
  1413. */
  1414. public boolean isStateFrame()
  1415. {
  1416. return (tipoFrame == STATE_FRAME);
  1417. }
  1418. /**
  1419. *
  1420. * @return True se la frame è di tipo WRITE_FRAME; False altrimenti
  1421. */
  1422. public boolean isWriteFrame()
  1423. {
  1424. return (tipoFrame == WRITE_FRAME);
  1425. }
  1426. /**
  1427. *
  1428. * @return True se la frame è di tipo PWD_FRAME; False altrimenti
  1429. */
  1430. public boolean isPwdFrame()
  1431. {
  1432. return (tipoFrame == PWD_FRAME);
  1433. }
  1434. /**
  1435. *
  1436. * @return True se la frame è di tipo OK_FRAME; False altrimenti
  1437. */
  1438. public boolean isOKFrame()
  1439. {
  1440. return (tipoFrame == OK_FRAME);
  1441. }
  1442. /**
  1443. *
  1444. * @return True se la frame è di tipo KO_FRAME; False altrimenti
  1445. */
  1446. public boolean isKOFrame()
  1447. {
  1448. return (tipoFrame == KO_FRAME);
  1449. }
  1450. }