branch feature/7459 updated (aae9b0f -> 593e87e)
This is an automated email from the git hooks/post-receive script. New change to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git omits aae9b0f modif de l'icone du pied à coulisse (fixes #7459) omits ed81d11 affichage du port série écouté dans la barre de statut (refs #7459) omits 4670088 modif de la conif de port série : nombre au lieu de faire une liste des ports dispo (refs #7459) omits 0241863 lecture des données reçues sur le pied à coulisse (refs #7459) omits a13af77 ajout de la connexion au pied à coulisse depuis l'appli (refs #7459) omits 1a3421d ajout de la conf du port série du pied a coulisse (refs #7459) omits f70c0d6 implem de la réception des données du pied a coulisse (refs #7459) omits 0388a1f creation du module pour le pied à coulisse (caliper) (refs #7459) omits 43c87bf renommage des classes de l'ichtyometre en vue de l'ajout de module du pied à coulisse, pour eviter les confusions (refs #7459) adds d0bfe06 Déplacement du cache de haut niveau dans un paquetage plus adapté + amélioration code dans le cache (côté ui) adds 2dad5f3 Revue de comment interroger le cache adds 2488271 Utilisation d'un nouvel handler pour gérer la zone de notification adds 9025fe4 Ajout d'états sur le cache d'ui adds e7dec7b Revue de la zone de notification adds 2ce988a Suppression des listeners sur le cache + revue du code du cache adds 41059a9 Suppression du statut de la ligne d'une observation (cela pose des problème sur la sélection dans par exemple l'éditeur des code de prélèvement qui se déclanche avant que la ligne soit sélectionnée) adds 48d0e06 Revue du modèle de la zone de notification et de son handler adds e899b8a traduction perdue adds af55cbb Renommage méthode + suppression méthode non utilisée adds 7de63b3 Normalement on a le bon flow pour la rafraichissement de la zone de notification des prélèvements + nettoyage de code adds d8e5c5f Retour sur develop, car déjà trop de modifications... mais non fini Merge branch 'feature/revue_algorithme' into develop adds b65b154 si on modifie la catégorie vrac/hors vrac, on met à jour le compte de lots vrac/hors vrac (fixes #8255) adds eba83d2 Merge branch 'feature/8255' into 'develop' adds 3de3001 Fix npe... Refs #8263 adds 3886a2d Livrable #8263 Merge branch 'feature/8263' into develop adds efe729c Ne pas tenter de supprimer des lots déjà supprimés (See #8261) adds 4807b51 Livrable #8261 Merge branch 'feature/8261' into develop adds f6c2f9d Correction lors de l'import des mensurations en multi-poste (See #8249) adds 7ed9bfc Livrable #8249 Merge branch 'feature/8249' into develop adds 3191b67 Changement du message lors de l'erreur d'un import (See #8247) adds 524e139 Livrable #8247 Merge branch 'feature/8247' into develop adds 41feecb Ne plus cacher le status dans la zone de notification adds 72ca87d Ne plus conserver les états dans le modèle de zone de notification + renommage propriété adds c74e5c1 Si un des max est atteint on ne propose plus de prélever adds 8cd62f9 Amélioration des logs sur le cache adds 5f9e52e Introduction d'une requète sur le cache d'échantillons + amélioration du cache adds c316995 Utilisation de la requete sur le cache d'échantillon + continue à simplifier et assainir le code adds bac64af Fin du ménage même s'il reste encore des choses à revoir... adds 50f07c7 Retour sur develop pour intégrer les autres tickets avant release Merge branch 'feature/8242' into develop adds e2b2a0e Clean code adds 29ac08e Compacter la table des observations individuelles à l'ouverture de l'écran (See #8202) adds 03a5c31 Livrable #8202 Merge branch 'feature/8202' into develop adds c47e59e Revue du changement de mode de recopie new 2b893cc renommage des classes de l'ichtyometre en vue de l'ajout de module du pied à coulisse, pour eviter les confusions (refs #7459) new 70c6707 creation du module pour le pied à coulisse (caliper) (refs #7459) new 5c79f17 implem de la réception des données du pied a coulisse (refs #7459) new fa669e5 ajout de la conf du port série du pied a coulisse (refs #7459) new 0ad86dc ajout de la connexion au pied à coulisse depuis l'appli (refs #7459) new 1961579 lecture des données reçues sur le pied à coulisse (refs #7459) new 6607ccd modif de la conif de port série : nombre au lieu de faire une liste des ports dispo (refs #7459) new 6500c3c affichage du port série écouté dans la barre de statut (refs #7459) new b8e1fa0 modif de l'icone du pied à coulisse (fixes #7459) new 151e005 Fix import from merge new 593e87e Meilleur gestion des dépendences This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (aae9b0f) \ N -- N -- N refs/heads/feature/7459 (593e87e) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omits" are not gone; other references still refer to them. Any revisions marked "discards" are gone forever. The 11 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 593e87e06c560e2a7b3ee47ac9d44716e65aaca5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Apr 22 13:35:31 2016 +0200 Meilleur gestion des dépendences commit 151e00570056132eb6eff7cc0f6a047a47031fa6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Apr 22 13:35:18 2016 +0200 Fix import from merge commit b8e1fa0dac2f5269b71a39c181ca9a64dd05556c Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 21 11:49:44 2016 +0200 modif de l'icone du pied à coulisse (fixes #7459) commit 6500c3c4165e40ecc0efd10149dad6943392ce7f Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 21 10:30:12 2016 +0200 affichage du port série écouté dans la barre de statut (refs #7459) commit 6607ccdc4b4b3495418136a7e828759244301b3a Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 21 10:28:40 2016 +0200 modif de la conif de port série : nombre au lieu de faire une liste des ports dispo (refs #7459) commit 19615796d8980283f913f3bc8a6aa5569937da9e Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 21 10:27:04 2016 +0200 lecture des données reçues sur le pied à coulisse (refs #7459) commit 0ad86dc1263c7303e33d2f5c90bbb226effef4f3 Author: Kevin Morin <morin@codelutin.com> Date: Wed Apr 20 16:16:55 2016 +0200 ajout de la connexion au pied à coulisse depuis l'appli (refs #7459) commit fa669e59b30830fcb51a434ed5e941c34ef2e2a3 Author: Kevin Morin <morin@codelutin.com> Date: Wed Apr 20 15:34:01 2016 +0200 ajout de la conf du port série du pied a coulisse (refs #7459) commit 5c79f17385017c8b0614fdd48ef3059d7f6ff4da Author: Kevin Morin <morin@codelutin.com> Date: Wed Apr 20 15:21:16 2016 +0200 implem de la réception des données du pied a coulisse (refs #7459) commit 70c6707dc809d7c4f48143504403bd509d5fcdf9 Author: Kevin Morin <morin@codelutin.com> Date: Tue Apr 19 17:54:34 2016 +0200 creation du module pour le pied à coulisse (caliper) (refs #7459) commit 2b893ccf555cbd52cbe08b42db6fc933ad83c787 Author: Kevin Morin <morin@codelutin.com> Date: Tue Apr 19 17:37:33 2016 +0200 renommage des classes de l'ichtyometre en vue de l'ajout de module du pied à coulisse, pour eviter les confusions (refs #7459) Summary of changes: pom.xml | 7 + tutti-caliper/pom.xml | 14 +- .../ifremer/tutti/service/PersistenceService.java | 4 +- .../fr/ifremer/tutti/service/TuttiDataContext.java | 4 +- .../catches/multipost/MultiPostImportService.java | 20 +- .../service/{sampling => cruise}/CruiseCache.java | 4 +- .../{sampling => cruise}/CruiseCacheAble.java | 2 +- .../{sampling => cruise}/CruiseCacheLoader.java | 4 +- .../cps/CalcifiedPiecesSamplingExportService.java | 2 +- ...cesSamplingAlgorithmEntryNotFoundException.java | 15 + .../service/sampling/CruiseSamplingCache.java | 726 +++++++++------------ .../sampling/CruiseSamplingInternalCache.java | 147 ++--- .../IndividualObservationSamplingCacheRequest.java | 80 +++ .../IndividualObservationSamplingContext.java | 148 +++++ .../IndividualObservationSamplingStatus.java | 141 ++++ ...lObservationSamplingStatusExceptionSupport.java | 28 + .../tutti/service/sampling/SamplingCodeCache.java | 1 + .../tutti/service/sampling/SamplingEvent.java | 105 --- .../tutti/service/sampling/SamplingListener.java | 39 -- ...NotDefinedOnIndividualObservationException.java | 15 + .../ZoneNotDefinedOnFishingOperationException.java | 15 + .../resources/i18n/tutti-service_fr_FR.properties | 2 +- .../fr/ifremer/tutti/ui/swing/TuttiUIContext.java | 2 +- .../content/actions/EditCatchesSupportAction.java | 2 +- .../CalcifiedPiecesSamplingReportAction.java | 2 +- .../SamplingCodeCellEditor.java | 2 +- .../ChangeSpeciesBatchSampleCategoryAction.java | 22 +- .../edit/actions/RemoveSpeciesBatchAction.java | 8 +- .../IndividualObservationBatchRowModel.java | 21 +- .../IndividualObservationBatchRowState.java | 38 +- .../IndividualObservationBatchTableHandler.java | 535 +++++++-------- .../IndividualObservationBatchTableModel.java | 14 +- .../IndividualObservationBatchUIModel.java | 15 + ...dividualObservationToSamplingCacheResolver.java | 147 +++++ .../frequency/IndividualObservationUICache.java | 529 ++++----------- .../frequency/SamplingNotificationZoneHandler.java | 331 ++++++++++ .../frequency/SamplingNotificationZoneModel.java | 35 + .../frequency/SamplingNotificationZoneStatus.java | 15 + .../frequency/SpeciesFrequencyRowModel.java | 4 + .../frequency/SpeciesFrequencyTableModel.java | 4 +- .../species/frequency/SpeciesFrequencyUI.jaxx | 6 +- .../species/frequency/SpeciesFrequencyUI.jcss | 4 - .../frequency/SpeciesFrequencyUIHandler.java | 309 +++++---- .../species/frequency/SpeciesFrequencyUIModel.java | 164 ++--- .../actions/ApplySpeciesFrequencyRafaleAction.java | 51 +- .../actions/CancelEditSpeciesFrequencyAction.java | 15 +- .../frequency/actions/EditSampleCodeAction.java | 52 +- .../frequency/actions/RemoveObservationAction.java | 8 +- .../actions/ResetSpeciesFrequencyAction.java | 13 +- .../content/protocol/EditProtocolUIModel.java | 4 +- .../resources/i18n/tutti-ui-swing_en_GB.properties | 1 + .../resources/i18n/tutti-ui-swing_fr_FR.properties | 2 +- 52 files changed, 2117 insertions(+), 1761 deletions(-) rename tutti-service/src/main/java/fr/ifremer/tutti/service/{sampling => cruise}/CruiseCache.java (96%) rename tutti-service/src/main/java/fr/ifremer/tutti/service/{sampling => cruise}/CruiseCacheAble.java (97%) rename tutti-service/src/main/java/fr/ifremer/tutti/service/{sampling => cruise}/CruiseCacheLoader.java (97%) create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CalcifiedPiecesSamplingAlgorithmEntryNotFoundException.java create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/IndividualObservationSamplingCacheRequest.java create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/IndividualObservationSamplingContext.java create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/IndividualObservationSamplingStatus.java create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/IndividualObservationSamplingStatusExceptionSupport.java delete mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/SamplingEvent.java delete mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/SamplingListener.java create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/SizeNotDefinedOnIndividualObservationException.java create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/ZoneNotDefinedOnFishingOperationException.java create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationToSamplingCacheResolver.java create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SamplingNotificationZoneHandler.java create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SamplingNotificationZoneModel.java create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SamplingNotificationZoneStatus.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 70c6707dc809d7c4f48143504403bd509d5fcdf9 Author: Kevin Morin <morin@codelutin.com> Date: Tue Apr 19 17:54:34 2016 +0200 creation du module pour le pied à coulisse (caliper) (refs #7459) --- pom.xml | 1 + tutti-caliper/LICENSE.txt | 674 +++++++++++++++++++++ tutti-caliper/README.md | 0 tutti-caliper/pom.xml | 148 +++++ .../tutti/caliper/feed/CaliperFeedReader.java | 232 +++++++ .../caliper/feed/event/CaliperFeedReaderEvent.java | 53 ++ .../feed/event/CaliperFeedReaderListener.java | 42 ++ .../record/CaliperFeedReaderMeasureRecord.java | 79 +++ .../record/CaliperFeedReaderRecordFactory.java | 94 +++ .../record/CaliperFeedReaderRecordSupport.java | 62 ++ .../CaliperFeedReaderStylusMotionRecord.java | 79 +++ 11 files changed, 1464 insertions(+) diff --git a/pom.xml b/pom.xml index 1f59bad..4e738ac 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,7 @@ <modules> <module>tutti-persistence</module> <module>tutti-ichtyometer</module> + <module>tutti-caliper</module> <module>tutti-report-generator</module> <module>tutti-service</module> <module>tutti-ui-swing-updater</module> diff --git a/tutti-caliper/LICENSE.txt b/tutti-caliper/LICENSE.txt new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/tutti-caliper/LICENSE.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/tutti-caliper/README.md b/tutti-caliper/README.md new file mode 100644 index 0000000..e69de29 diff --git a/tutti-caliper/pom.xml b/tutti-caliper/pom.xml new file mode 100644 index 0000000..23755dd --- /dev/null +++ b/tutti-caliper/pom.xml @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Tutti :: Ichtyometer API + %% + Copyright (C) 2014 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>fr.ifremer</groupId> + <artifactId>tutti</artifactId> + <version>4.5-SNAPSHOT</version> + </parent> + + <groupId>fr.ifremer.tutti</groupId> + <artifactId>tutti-caliper</artifactId> + + <name>Tutti :: Caliper API</name> + + <properties> + + </properties> + + <dependencies> + + <!-- Commons --> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + + <!-- Guava --> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + + <!-- Logging --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jcl</artifactId> + <scope>provided</scope> + </dependency> + + <!-- Tests --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + + <profiles> + <profile> + <id>tools</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + <properties> + <redmine.releaseFiles> + target/${project.build.finalName}-tools.zip + </redmine.releaseFiles> + </properties> + + <build> + <defaultGoal>package</defaultGoal> + + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>jar</id> + <goals> + <goal>assembly</goal> + </goals> + <phase>package</phase> + <configuration> + <descriptorRefs> + <descriptorRef>jar-with-dependencies</descriptorRef> + </descriptorRefs> + + </configuration> + </execution> + <execution> + <id>zip</id> + <goals> + <goal>assembly</goal> + </goals> + <phase>package</phase> + <configuration> + <descriptor>src/main/assembly/tools.xml</descriptor> + </configuration> + </execution> + </executions> + <configuration> + <finalName>${project.build.finalName}-tools</finalName> + <appendAssemblyId>false</appendAssemblyId> + </configuration> + </plugin> + </plugins> + </build> + + + <dependencies> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>runtime</scope> + </dependency> + + </dependencies> + </profile> + </profiles> + +</project> diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java new file mode 100644 index 0000000..e50d9c7 --- /dev/null +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java @@ -0,0 +1,232 @@ +package fr.ifremer.tutti.caliper.feed; + +/* + * #%L + * Tutti :: Ichtyometer API + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderEvent; +import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderListener; +import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderMeasureRecord; +import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderRecordFactory; +import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderRecordSupport; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.event.EventListenerList; +import java.io.Closeable; +import java.io.DataInputStream; +import java.io.IOException; + +/** + * To read some records from a caliper in feed mode. + * + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class CaliperFeedReader implements Closeable { + + /** Logger. */ + private static final Log log = LogFactory.getLog(CaliperFeedReader.class); + + /** + * Ichtyometer client given in the {@code start} method. + */ +// protected CaliperClient client; + + /** + * Reader runnable code (to be used in a thread). + */ + protected ReadingRunnable readingRunnable; + + /** + * To keep list of {@link CaliperFeedReaderListener} listeners. + */ + protected final EventListenerList listenerList; + + /** + * To generate some feed record from the rax record send by the board. + * + * @since 3.10 + */ + protected final CaliperFeedReaderRecordFactory recordFactory; + + public CaliperFeedReader() { + listenerList = new EventListenerList(); + recordFactory = new CaliperFeedReaderRecordFactory(); + } + +// public void start(CaliperClient client) throws IOException { +// +// Preconditions.checkNotNull(client, "client can not be null"); +// Preconditions.checkState(client.isOpen(), "client must be opened"); +// this.client = client; +// +// // get connection +// StreamConnection connection = client.openConnection(); +// +// // get input stream +// DataInputStream dataInputStream = connection.openDataInputStream(); +// +// // create the reader runnable +// readingRunnable = new ReadingRunnable(dataInputStream); +// +// // start the reader thread +// new Thread(readingRunnable).start(); +// +// if (log.isDebugEnabled()) { +// log.debug("Ready to read remote device..."); +// } +// } + + @Override + public void close() throws IOException { + +// Preconditions.checkNotNull(client, "client can not be null"); +// Preconditions.checkState(client.isOpen(), "client must be opened"); + + try { + readingRunnable.stop(); + + } finally { + +// Closeables.close(client, true); + } + } + +// public String getClientName() { +// return client.getName(); +// } + + public void addFeedModeReaderListener(CaliperFeedReaderListener listener) { + listenerList.add(CaliperFeedReaderListener.class, listener); + } + + public void removeFeedModeReaderListener(CaliperFeedReaderListener listener) { + listenerList.remove(CaliperFeedReaderListener.class, listener); + } + + public void removeAllFeedModeReaderListeners() { + for (CaliperFeedReaderListener listener : listenerList.getListeners(CaliperFeedReaderListener.class)) { + listenerList.remove(CaliperFeedReaderListener.class, listener); + } + } + + protected class ReadingRunnable implements Runnable { + + /** + * Input stream to read new record. + */ + protected final DataInputStream dataInputStream; + + /** + * Flag to stop the runnable. + */ + protected boolean stop; + + protected ReadingRunnable(DataInputStream dataInputStream) { + this.dataInputStream = dataInputStream; + } + + protected void stop() { + this.stop = true; + } + + @Override + public void run() { + + if (log.isInfoEnabled()) { + log.info("Reader thread start... " + this); + } + + while (!stop) { + + try { + // get a new record + CaliperFeedReaderRecordSupport readerRecord = readRecord(dataInputStream); + + if (!stop && readerRecord != null && readerRecord instanceof CaliperFeedReaderMeasureRecord) { + + // send new record to listeners + CaliperFeedReaderEvent e = new CaliperFeedReaderEvent(CaliperFeedReader.this, (CaliperFeedReaderMeasureRecord) readerRecord); + for (CaliperFeedReaderListener listener : listenerList.getListeners(CaliperFeedReaderListener.class)) { + listener.recordRead(e); + } + + } + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Could not read record", e); + } + } + } + + if (log.isInfoEnabled()) { + log.info("Reader thread stop..." + this); + } + } + + protected CaliperFeedReaderRecordSupport readRecord(DataInputStream dataInputStream) throws IOException { + + String result = ""; + + // wait until got a # + + boolean complete = false; + + while (!complete) { + + if (stop) { + break; + } + while (dataInputStream.available() > 0) { + if (complete || stop) { + break; + } + int c = dataInputStream.read(); + + result += (char) c; + + if ('#' == (char) c) { + + complete = true; + } + } + } + + CaliperFeedReaderRecordSupport readerRecord = null; + + if (!stop) { + + if (log.isInfoEnabled()) { + log.info("New raw record: " + result); + } + readerRecord = recordFactory.newRecord(result); + + if (log.isDebugEnabled()) { + log.debug("New feed record: " + readerRecord); + } + + } + + return readerRecord; + } + } +} diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/event/CaliperFeedReaderEvent.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/event/CaliperFeedReaderEvent.java new file mode 100644 index 0000000..5cd44b3 --- /dev/null +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/event/CaliperFeedReaderEvent.java @@ -0,0 +1,53 @@ +package fr.ifremer.tutti.caliper.feed.event; + +/* + * #%L + * Tutti :: Ichtyometer API + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.caliper.feed.CaliperFeedReader; +import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderMeasureRecord; + +import java.util.EventObject; + +/** + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class CaliperFeedReaderEvent extends EventObject { + + private static final long serialVersionUID = 1L; + + protected final CaliperFeedReaderMeasureRecord record; + + public CaliperFeedReaderEvent(CaliperFeedReader source, CaliperFeedReaderMeasureRecord record) { + super(source); + this.record = record; + } + + @Override + public CaliperFeedReader getSource() { + return (CaliperFeedReader) super.getSource(); + } + + public CaliperFeedReaderMeasureRecord getRecord() { + return record; + } +} diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/event/CaliperFeedReaderListener.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/event/CaliperFeedReaderListener.java new file mode 100644 index 0000000..3f5fffd --- /dev/null +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/event/CaliperFeedReaderListener.java @@ -0,0 +1,42 @@ +package fr.ifremer.tutti.caliper.feed.event; + +/* + * #%L + * Tutti :: Ichtyometer API + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import java.util.EventListener; + +/** + * To listen new read records from the caliper. + * + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public interface CaliperFeedReaderListener extends EventListener { + + /** + * When a new record was read. + * + * @param event event containing the new read record + */ + void recordRead(CaliperFeedReaderEvent event); + +} diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java new file mode 100644 index 0000000..fc0ed28 --- /dev/null +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java @@ -0,0 +1,79 @@ +package fr.ifremer.tutti.caliper.feed.record; + +/* + * #%L + * Tutti :: Ichtyometer API + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import org.apache.commons.lang3.builder.ToStringBuilder; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * A measure record. + * + * Format is <pre>%l,v#</pre>. + * + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class CaliperFeedReaderMeasureRecord extends CaliperFeedReaderRecordSupport { + + private static final long serialVersionUID = 1L; + + protected static final Pattern RECORD_PATTERN = Pattern.compile("%l\\,(\\w+)?#"); + + public static boolean acceptRecord(String record) { + + Matcher matcher = RECORD_PATTERN.matcher(record); + return matcher.matches(); + + } + + protected final int measure; + + CaliperFeedReaderMeasureRecord(String record) { + super(record); + Matcher matcher = RECORD_PATTERN.matcher(record); + matcher.find(); + String measureStr = matcher.group(1); + measure = Integer.valueOf(measureStr); + } + + public int getMeasure() { + return measure; + } + + @Override + public boolean isValid() { + return acceptRecord(record); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("record", measure) + .append("measure", measure) + .toString(); + } +} diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java new file mode 100644 index 0000000..14d361f --- /dev/null +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java @@ -0,0 +1,94 @@ +package fr.ifremer.tutti.caliper.feed.record; + +/* + * #%L + * Tutti :: Ichtyometer API + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import java.util.LinkedHashSet; +import java.util.Set; + +/** + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class CaliperFeedReaderRecordFactory { + + protected final Set<FeedReaderRecordAceptor> acceptors; + + public CaliperFeedReaderRecordFactory() { + acceptors = new LinkedHashSet<>(); + acceptors.add(new FeedReaderRecordAceptor<CaliperFeedReaderStylusMotionRecord>() { + @Override + public boolean accept(String record) { + return CaliperFeedReaderStylusMotionRecord.acceptRecord(record); + } + + @Override + public CaliperFeedReaderStylusMotionRecord newRecord(String record) { + return new CaliperFeedReaderStylusMotionRecord(record); + } + }); + acceptors.add(new FeedReaderRecordAceptor<CaliperFeedReaderMeasureRecord>() { + @Override + public boolean accept(String record) { + return CaliperFeedReaderMeasureRecord.acceptRecord(record); + } + + @Override + public CaliperFeedReaderMeasureRecord newRecord(String record) { + return new CaliperFeedReaderMeasureRecord(record); + } + }); + + } + + public CaliperFeedReaderRecordSupport newRecord(String record) { + + CaliperFeedReaderRecordSupport feedRecord = null; + + for (FeedReaderRecordAceptor acceptor : acceptors) { + + boolean accept = acceptor.accept(record); + if (accept) { + + feedRecord = acceptor.newRecord(record); + break; + + } + + } + + return feedRecord; + + } + + protected static interface FeedReaderRecordAceptor<F extends CaliperFeedReaderRecordSupport> { + + boolean accept(String record); + + + F newRecord(String record); + + } + +} diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordSupport.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordSupport.java new file mode 100644 index 0000000..da21f1e --- /dev/null +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordSupport.java @@ -0,0 +1,62 @@ +package fr.ifremer.tutti.caliper.feed.record; + +/* + * #%L + * Tutti :: Ichtyometer API + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import java.io.Serializable; + +/** + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public abstract class CaliperFeedReaderRecordSupport implements Serializable{ + + private static final long serialVersionUID = 1L; + + /** + * Incoming raw record. + */ + protected final String record; + + protected CaliperFeedReaderRecordSupport(String record) { + this.record = record; + Preconditions.checkState(isValid()); + } + + public abstract boolean isValid(); + + public String getRecord() { + return record; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("record", record) + .toString(); + } +} diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderStylusMotionRecord.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderStylusMotionRecord.java new file mode 100644 index 0000000..5beef21 --- /dev/null +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderStylusMotionRecord.java @@ -0,0 +1,79 @@ +package fr.ifremer.tutti.caliper.feed.record; + +/* + * #%L + * Tutti :: Ichtyometer API + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import org.apache.commons.lang3.builder.ToStringBuilder; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * A measure record. + * + * Format is <pre>%l,v#</pre>. + * + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class CaliperFeedReaderStylusMotionRecord extends CaliperFeedReaderRecordSupport { + + private static final long serialVersionUID = 1L; + + protected static final Pattern RECORD_PATTERN = Pattern.compile("%t:(\\w)?#"); + + public static boolean acceptRecord(String record) { + + Matcher matcher = RECORD_PATTERN.matcher(record); + return matcher.matches(); + + } + + protected final int motion; + + CaliperFeedReaderStylusMotionRecord(String record) { + super(record); + Matcher matcher = RECORD_PATTERN.matcher(record); + matcher.find(); + String measureStr = matcher.group(1); + motion = Integer.valueOf(measureStr); + } + + public int getMotion() { + return motion; + } + + @Override + public boolean isValid() { + return acceptRecord(record); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("record", record) + .append("motion", motion) + .toString(); + } +} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 5c79f17385017c8b0614fdd48ef3059d7f6ff4da Author: Kevin Morin <morin@codelutin.com> Date: Wed Apr 20 15:21:16 2016 +0200 implem de la réception des données du pied a coulisse (refs #7459) --- tutti-caliper/pom.xml | 7 + .../fr/ifremer/tutti/caliper/feed/Caliper.java | 135 +++++++++++++++ .../caliper/feed/CaliperConnectionException.java | 12 ++ .../tutti/caliper/feed/CaliperFeedReader.java | 192 +++++++++------------ .../record/CaliperFeedReaderMeasureRecord.java | 14 +- .../record/CaliperFeedReaderRecordFactory.java | 20 +-- .../record/CaliperFeedReaderRecordSupport.java | 1 + .../CaliperFeedReaderStylusMotionRecord.java | 79 --------- 8 files changed, 241 insertions(+), 219 deletions(-) diff --git a/tutti-caliper/pom.xml b/tutti-caliper/pom.xml index 23755dd..8c4fced 100644 --- a/tutti-caliper/pom.xml +++ b/tutti-caliper/pom.xml @@ -75,6 +75,13 @@ <scope>test</scope> </dependency> + <dependency> + <groupId>com.neuronrobotics</groupId> + <artifactId>nrjavaserial</artifactId> + <version>3.7.5.1</version> + </dependency> + + </dependencies> <profiles> diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/Caliper.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/Caliper.java new file mode 100644 index 0000000..b63acb5 --- /dev/null +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/Caliper.java @@ -0,0 +1,135 @@ +package fr.ifremer.tutti.caliper.feed; + +import gnu.io.CommPort; +import gnu.io.CommPortIdentifier; +import gnu.io.SerialPort; +import gnu.io.SerialPortEvent; +import gnu.io.SerialPortEventListener; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * @author Kevin Morin (Code Lutin) + * @since x.x + */ +public class Caliper { + public Caliper() + { + super(); + } + + void connect ( String portName ) throws Exception + { + CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); + if ( portIdentifier.isCurrentlyOwned() ) + { + System.out.println("Error: Port is currently in use"); + } + else + { + CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000); + + if ( commPort instanceof SerialPort ) + { + SerialPort serialPort = (SerialPort) commPort; + serialPort.setSerialPortParams(4800,SerialPort.DATABITS_7,SerialPort.STOPBITS_1,SerialPort.PARITY_EVEN); + + InputStream in = serialPort.getInputStream(); + OutputStream out = serialPort.getOutputStream(); + + (new Thread(new SerialWriter(out))).start(); + + serialPort.addEventListener(new SerialReader(in)); + serialPort.notifyOnDataAvailable(true); + + } + else + { + System.out.println("Error: Only serial ports are handled by this example."); + } + } + } + + /** + * Handles the input coming from the serial port. A new line character + * is treated as the end of a block in this example. + */ + public static class SerialReader implements SerialPortEventListener + { + private InputStream in; + private byte[] buffer = new byte[1024]; + + public SerialReader ( InputStream in ) + { + this.in = in; + } + + public void serialEvent(SerialPortEvent arg0) { + int data; + + try + { + int len = 0; + while ( ( data = in.read()) > -1 ) + { + if ( data == '\n' ) { + break; + } + buffer[len++] = (byte) data; + } + System.out.print(new String(buffer,0,len)); + } + catch ( IOException e ) + { + e.printStackTrace(); + System.exit(-1); + } + } + + } + + /** */ + public static class SerialWriter implements Runnable + { + OutputStream out; + + public SerialWriter ( OutputStream out ) + { + this.out = out; + } + + public void run () + { + try + { + int c = 0; + while ( ( c = System.in.read()) > -1 ) + { + this.out.write(c); + } + } + catch ( IOException e ) + { + e.printStackTrace(); + System.exit(-1); + } + } + } + + + + public static void main ( String[] args ) + { + try + { + (new Caliper()).connect("COM1"); + } + catch ( Exception e ) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperConnectionException.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperConnectionException.java new file mode 100644 index 0000000..fb9a0f6 --- /dev/null +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperConnectionException.java @@ -0,0 +1,12 @@ +package fr.ifremer.tutti.caliper.feed; + +/** + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class CaliperConnectionException extends Exception { + + public CaliperConnectionException(Throwable cause) { + super(cause); + } +} diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java index e50d9c7..f2febd9 100644 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java @@ -22,18 +22,28 @@ package fr.ifremer.tutti.caliper.feed; * #L% */ +import com.google.common.base.Preconditions; import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderEvent; import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderListener; import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderMeasureRecord; import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderRecordFactory; import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderRecordSupport; +import gnu.io.CommPortIdentifier; +import gnu.io.NoSuchPortException; +import gnu.io.PortInUseException; +import gnu.io.SerialPort; +import gnu.io.SerialPortEvent; +import gnu.io.SerialPortEventListener; +import gnu.io.UnsupportedCommOperationException; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.swing.event.EventListenerList; import java.io.Closeable; -import java.io.DataInputStream; import java.io.IOException; +import java.io.InputStream; +import java.util.TooManyListenersException; /** * To read some records from a caliper in feed mode. @@ -47,14 +57,9 @@ public class CaliperFeedReader implements Closeable { private static final Log log = LogFactory.getLog(CaliperFeedReader.class); /** - * Ichtyometer client given in the {@code start} method. + * Serial port open in the {@code start} method. */ -// protected CaliperClient client; - - /** - * Reader runnable code (to be used in a thread). - */ - protected ReadingRunnable readingRunnable; + protected SerialPort serialPort; /** * To keep list of {@link CaliperFeedReaderListener} listeners. @@ -73,48 +78,44 @@ public class CaliperFeedReader implements Closeable { recordFactory = new CaliperFeedReaderRecordFactory(); } -// public void start(CaliperClient client) throws IOException { -// -// Preconditions.checkNotNull(client, "client can not be null"); -// Preconditions.checkState(client.isOpen(), "client must be opened"); -// this.client = client; -// -// // get connection -// StreamConnection connection = client.openConnection(); -// -// // get input stream -// DataInputStream dataInputStream = connection.openDataInputStream(); -// -// // create the reader runnable -// readingRunnable = new ReadingRunnable(dataInputStream); -// -// // start the reader thread -// new Thread(readingRunnable).start(); -// -// if (log.isDebugEnabled()) { -// log.debug("Ready to read remote device..."); -// } -// } + public void start(String portName) throws CaliperConnectionException { + + Preconditions.checkArgument(StringUtils.isNotEmpty(portName), "serial port can not be null or empty"); + + try { + CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); + + serialPort = portIdentifier.open(this.getClass().getName(), 2000); + serialPort.setSerialPortParams(4800, SerialPort.DATABITS_7, SerialPort.STOPBITS_1, SerialPort.PARITY_EVEN); + + InputStream inputStream = serialPort.getInputStream(); + + serialPort.addEventListener(new SerialReader(inputStream)); + serialPort.notifyOnDataAvailable(true); + + if (log.isDebugEnabled()) { + log.debug("Ready to read remote device..."); + } + + } catch (IOException | TooManyListenersException | PortInUseException | NoSuchPortException | UnsupportedCommOperationException e) { + if (log.isErrorEnabled()) { + log.error("Error while connecting to the serial port " + portName, e); + } + throw new CaliperConnectionException(e); + } + } @Override public void close() throws IOException { -// Preconditions.checkNotNull(client, "client can not be null"); -// Preconditions.checkState(client.isOpen(), "client must be opened"); - try { - readingRunnable.stop(); + serialPort.close(); } finally { - -// Closeables.close(client, true); + // do nothing if the close fails } } -// public String getClientName() { -// return client.getName(); -// } - public void addFeedModeReaderListener(CaliperFeedReaderListener listener) { listenerList.add(CaliperFeedReaderListener.class, listener); } @@ -129,104 +130,69 @@ public class CaliperFeedReader implements Closeable { } } - protected class ReadingRunnable implements Runnable { - /** - * Input stream to read new record. - */ - protected final DataInputStream dataInputStream; - - /** - * Flag to stop the runnable. - */ - protected boolean stop; + /** + * Handles the input coming from the serial port. A new line character + * is treated as the end of a block in this example. + */ + public class SerialReader implements SerialPortEventListener { - protected ReadingRunnable(DataInputStream dataInputStream) { - this.dataInputStream = dataInputStream; - } + private InputStream in; + private byte[] buffer = new byte[1024]; - protected void stop() { - this.stop = true; + public SerialReader(InputStream in) + { + this.in = in; } - @Override - public void run() { - - if (log.isInfoEnabled()) { - log.info("Reader thread start... " + this); - } - - while (!stop) { + public void serialEvent(SerialPortEvent arg0) { - try { - // get a new record - CaliperFeedReaderRecordSupport readerRecord = readRecord(dataInputStream); + try { + CaliperFeedReaderRecordSupport readerRecord = readRecord(); - if (!stop && readerRecord != null && readerRecord instanceof CaliperFeedReaderMeasureRecord) { + if (readerRecord != null && readerRecord instanceof CaliperFeedReaderMeasureRecord) { - // send new record to listeners - CaliperFeedReaderEvent e = new CaliperFeedReaderEvent(CaliperFeedReader.this, (CaliperFeedReaderMeasureRecord) readerRecord); - for (CaliperFeedReaderListener listener : listenerList.getListeners(CaliperFeedReaderListener.class)) { - listener.recordRead(e); - } - - } - } catch (IOException e) { - if (log.isErrorEnabled()) { - log.error("Could not read record", e); + // send new record to listeners + CaliperFeedReaderEvent e = new CaliperFeedReaderEvent(CaliperFeedReader.this, (CaliperFeedReaderMeasureRecord) readerRecord); + for (CaliperFeedReaderListener listener : listenerList.getListeners(CaliperFeedReaderListener.class)) { + listener.recordRead(e); } + } - } - if (log.isInfoEnabled()) { - log.info("Reader thread stop..." + this); + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Could not read record", e); + } } } - protected CaliperFeedReaderRecordSupport readRecord(DataInputStream dataInputStream) throws IOException { - - String result = ""; - - // wait until got a # + private CaliperFeedReaderRecordSupport readRecord() throws IOException { - boolean complete = false; + int len = 0; + int data; - while (!complete) { - - if (stop) { + while (( data = in.read()) > -1) { + if (data == '\n') { break; } - while (dataInputStream.available() > 0) { - if (complete || stop) { - break; - } - int c = dataInputStream.read(); - - result += (char) c; - - if ('#' == (char) c) { - - complete = true; - } - } + buffer[len++] = (byte) data; } - CaliperFeedReaderRecordSupport readerRecord = null; - - if (!stop) { - - if (log.isInfoEnabled()) { - log.info("New raw record: " + result); - } - readerRecord = recordFactory.newRecord(result); + String result = new String(buffer,0,len); - if (log.isDebugEnabled()) { - log.debug("New feed record: " + readerRecord); - } + if (log.isInfoEnabled()) { + log.info("New raw record: " + result); + } + CaliperFeedReaderRecordSupport readerRecord = recordFactory.newRecord(result); + if (log.isDebugEnabled()) { + log.debug("New feed record: " + readerRecord); } return readerRecord; } + } + } diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java index fc0ed28..5fbb8dd 100644 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java @@ -25,9 +25,7 @@ package fr.ifremer.tutti.caliper.feed.record; */ import org.apache.commons.lang3.builder.ToStringBuilder; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import org.apache.commons.lang3.math.NumberUtils; /** * A measure record. @@ -41,12 +39,9 @@ public class CaliperFeedReaderMeasureRecord extends CaliperFeedReaderRecordSuppo private static final long serialVersionUID = 1L; - protected static final Pattern RECORD_PATTERN = Pattern.compile("%l\\,(\\w+)?#"); - public static boolean acceptRecord(String record) { - Matcher matcher = RECORD_PATTERN.matcher(record); - return matcher.matches(); + return NumberUtils.isNumber(record); } @@ -54,10 +49,7 @@ public class CaliperFeedReaderMeasureRecord extends CaliperFeedReaderRecordSuppo CaliperFeedReaderMeasureRecord(String record) { super(record); - Matcher matcher = RECORD_PATTERN.matcher(record); - matcher.find(); - String measureStr = matcher.group(1); - measure = Integer.valueOf(measureStr); + measure = Integer.valueOf(record); } public int getMeasure() { diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java index 14d361f..a6fea28 100644 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java @@ -33,22 +33,11 @@ import java.util.Set; */ public class CaliperFeedReaderRecordFactory { - protected final Set<FeedReaderRecordAceptor> acceptors; + protected final Set<CaliperFeedReaderRecordAceptor> acceptors; public CaliperFeedReaderRecordFactory() { acceptors = new LinkedHashSet<>(); - acceptors.add(new FeedReaderRecordAceptor<CaliperFeedReaderStylusMotionRecord>() { - @Override - public boolean accept(String record) { - return CaliperFeedReaderStylusMotionRecord.acceptRecord(record); - } - - @Override - public CaliperFeedReaderStylusMotionRecord newRecord(String record) { - return new CaliperFeedReaderStylusMotionRecord(record); - } - }); - acceptors.add(new FeedReaderRecordAceptor<CaliperFeedReaderMeasureRecord>() { + acceptors.add(new CaliperFeedReaderRecordAceptor<CaliperFeedReaderMeasureRecord>() { @Override public boolean accept(String record) { return CaliperFeedReaderMeasureRecord.acceptRecord(record); @@ -66,7 +55,7 @@ public class CaliperFeedReaderRecordFactory { CaliperFeedReaderRecordSupport feedRecord = null; - for (FeedReaderRecordAceptor acceptor : acceptors) { + for (CaliperFeedReaderRecordAceptor acceptor : acceptors) { boolean accept = acceptor.accept(record); if (accept) { @@ -82,11 +71,10 @@ public class CaliperFeedReaderRecordFactory { } - protected static interface FeedReaderRecordAceptor<F extends CaliperFeedReaderRecordSupport> { + protected static interface CaliperFeedReaderRecordAceptor<F extends CaliperFeedReaderRecordSupport> { boolean accept(String record); - F newRecord(String record); } diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordSupport.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordSupport.java index da21f1e..01ffbd9 100644 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordSupport.java +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordSupport.java @@ -30,6 +30,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import java.io.Serializable; /** + * TODO à mettre en commun entre l'ichtyo et le pied à coulisse ? * @author Kevin Morin (Code Lutin) * @since 4.5 */ diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderStylusMotionRecord.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderStylusMotionRecord.java deleted file mode 100644 index 5beef21..0000000 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderStylusMotionRecord.java +++ /dev/null @@ -1,79 +0,0 @@ -package fr.ifremer.tutti.caliper.feed.record; - -/* - * #%L - * Tutti :: Ichtyometer API - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.apache.commons.lang3.builder.ToStringBuilder; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * A measure record. - * - * Format is <pre>%l,v#</pre>. - * - * @author Kevin Morin (Code Lutin) - * @since 4.5 - */ -public class CaliperFeedReaderStylusMotionRecord extends CaliperFeedReaderRecordSupport { - - private static final long serialVersionUID = 1L; - - protected static final Pattern RECORD_PATTERN = Pattern.compile("%t:(\\w)?#"); - - public static boolean acceptRecord(String record) { - - Matcher matcher = RECORD_PATTERN.matcher(record); - return matcher.matches(); - - } - - protected final int motion; - - CaliperFeedReaderStylusMotionRecord(String record) { - super(record); - Matcher matcher = RECORD_PATTERN.matcher(record); - matcher.find(); - String measureStr = matcher.group(1); - motion = Integer.valueOf(measureStr); - } - - public int getMotion() { - return motion; - } - - @Override - public boolean isValid() { - return acceptRecord(record); - } - - @Override - public String toString() { - return new ToStringBuilder(this) - .append("record", record) - .append("motion", motion) - .toString(); - } -} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit fa669e59b30830fcb51a434ed5e941c34ef2e2a3 Author: Kevin Morin <morin@codelutin.com> Date: Wed Apr 20 15:34:01 2016 +0200 ajout de la conf du port série du pied a coulisse (refs #7459) --- .../java/fr/ifremer/tutti/TuttiConfiguration.java | 29 +++++++++-------- .../fr/ifremer/tutti/TuttiConfigurationOption.java | 32 +++++++++++-------- .../java/fr/ifremer/tutti/util/SerialPort.java | 12 ++++++++ .../i18n/tutti-persistence_en_GB.properties | 7 +++++ .../i18n/tutti-persistence_fr_FR.properties | 7 +++++ .../swing/content/config/TuttiConfigUIHandler.java | 36 +++++++++++++--------- .../ifremer/tutti/ui/swing/util/SoundEngine.java | 14 ++++----- .../resources/i18n/tutti-ui-swing_en_GB.properties | 9 ++++++ .../resources/i18n/tutti-ui-swing_fr_FR.properties | 9 ++++++ 9 files changed, 110 insertions(+), 45 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java index 45bea6e..613b18c 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java @@ -29,6 +29,7 @@ import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.type.CoordinateEditorType; import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.util.BeepFrequency; +import fr.ifremer.tutti.util.SerialPort; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.logging.Log; @@ -732,28 +733,32 @@ public class TuttiConfiguration extends ApplicationConfiguration { return applicationConfig.getOptionAsInt(TuttiConfigurationOption.ICHTYOMETER_MAXIMUM_NUMBER_OF_ATTEMPT_TO_CONNECT.getKey()); } - public Boolean isIchtyometerVoiceEnabled() { - return applicationConfig.getOptionAsBoolean(TuttiConfigurationOption.ICHTYOMETER_VOICE_ENABLED.getKey()); + public SerialPort getCaliperSerialPort() { + return SerialPort.valueOf(applicationConfig.getOption(TuttiConfigurationOption.CALIPER_SERIAL_PORT.getKey())); } - public Boolean isIchtyometerReadsUnit() { - return applicationConfig.getOptionAsBoolean(TuttiConfigurationOption.ICHTYOMETER_READS_UNIT.getKey()); + public Boolean isExternalDevicesVoiceEnabled() { + return applicationConfig.getOptionAsBoolean(TuttiConfigurationOption.EXTERNAL_DEVICES_VOICE_ENABLED.getKey()); } - public Boolean isIchtyometerDataReceptionBeepEnabled() { - return applicationConfig.getOptionAsBoolean(TuttiConfigurationOption.ICHTYOMETER_DATA_RECEPTION_BEEP_ENABLED.getKey()); + public Boolean isExternalDevicesReadsUnit() { + return applicationConfig.getOptionAsBoolean(TuttiConfigurationOption.EXTERNAL_DEVICES_READS_UNIT.getKey()); } - public BeepFrequency getIchtyometerDataReceptionBeepFrequency() { - return BeepFrequency.valueOf(applicationConfig.getOption(TuttiConfigurationOption.ICHTYOMETER_DATA_RECEPTION_BEEP_FREQUENCY.getKey())); + public Boolean isExternalDevicesDataReceptionBeepEnabled() { + return applicationConfig.getOptionAsBoolean(TuttiConfigurationOption.EXTERNAL_DEVICES_DATA_RECEPTION_BEEP_ENABLED.getKey()); } - public Boolean isIchtyometerErrorReceptionBeepEnabled() { - return applicationConfig.getOptionAsBoolean(TuttiConfigurationOption.ICHTYOMETER_ERROR_RECEPTION_BEEP_ENABLED.getKey()); + public BeepFrequency getExternalDevicesDataReceptionBeepFrequency() { + return BeepFrequency.valueOf(applicationConfig.getOption(TuttiConfigurationOption.EXTERNAL_DEVICES_DATA_RECEPTION_BEEP_FREQUENCY.getKey())); } - public BeepFrequency getIchtyometerErrorReceptionBeepFrequency() { - return BeepFrequency.valueOf(applicationConfig.getOption(TuttiConfigurationOption.ICHTYOMETER_ERROR_RECEPTION_BEEP_FREQUENCY.getKey())); + public Boolean isExternalDevicesErrorReceptionBeepEnabled() { + return applicationConfig.getOptionAsBoolean(TuttiConfigurationOption.EXTERNAL_DEVICES_ERROR_RECEPTION_BEEP_ENABLED.getKey()); + } + + public BeepFrequency getExternalDevicesErrorReceptionBeepFrequency() { + return BeepFrequency.valueOf(applicationConfig.getOption(TuttiConfigurationOption.EXTERNAL_DEVICES_ERROR_RECEPTION_BEEP_FREQUENCY.getKey())); } public String getJavaCommandPath() { diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java index e989798..a758b60 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java @@ -26,6 +26,7 @@ import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.type.CoordinateEditorType; import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.util.BeepFrequency; +import fr.ifremer.tutti.util.SerialPort; import org.hibernate.dialect.HSQLDialect; import org.hsqldb.jdbcDriver; import org.nuiton.config.ConfigOptionDef; @@ -646,44 +647,51 @@ public enum TuttiConfigurationOption implements ConfigOptionDef { int.class, false ), - ICHTYOMETER_VOICE_ENABLED( + CALIPER_SERIAL_PORT( + "tutti.ichtyometer.caliperSerialPort", + n("tutti.config.option.externalDevices.maximumNumberOfAttemptToConnect.description"), + "COM1", + SerialPort.class, + false + ), + EXTERNAL_DEVICES_VOICE_ENABLED( "tutti.ichtyometer.voice.enabled", - n("tutti.config.option.ichtyometer.voice.enabled.description"), + n("tutti.config.option.externalDevices.voice.enabled.description"), "true", Boolean.class, false ), - ICHTYOMETER_READS_UNIT( + EXTERNAL_DEVICES_READS_UNIT( "tutti.ichtyometer.reads.unit", - n("tutti.config.option.ichtyometer.reads.unit.description"), + n("tutti.config.option.externalDevices.reads.unit.description"), "true", Boolean.class, false ), - ICHTYOMETER_DATA_RECEPTION_BEEP_ENABLED( + EXTERNAL_DEVICES_DATA_RECEPTION_BEEP_ENABLED( "tutti.ichtyometer.beep.data.enabled", - n("tutti.config.option.ichtyometer.beep.data.enabled.description"), + n("tutti.config.option.externalDevices.beep.data.enabled.description"), "true", Boolean.class, false ), - ICHTYOMETER_DATA_RECEPTION_BEEP_FREQUENCY( + EXTERNAL_DEVICES_DATA_RECEPTION_BEEP_FREQUENCY( "tutti.ichtyometer.beep.data.frequency", - n("tutti.config.option.ichtyometer.beep.data.frequency.description"), + n("tutti.config.option.externalDevices.beep.data.frequency.description"), "A2", BeepFrequency.class, false ), - ICHTYOMETER_ERROR_RECEPTION_BEEP_ENABLED( + EXTERNAL_DEVICES_ERROR_RECEPTION_BEEP_ENABLED( "tutti.ichtyometer.beep.error.enabled", - n("tutti.config.option.ichtyometer.beep.error.enabled.description"), + n("tutti.config.option.externalDevices.beep.error.enabled.description"), "true", Boolean.class, false ), - ICHTYOMETER_ERROR_RECEPTION_BEEP_FREQUENCY( + EXTERNAL_DEVICES_ERROR_RECEPTION_BEEP_FREQUENCY( "tutti.ichtyometer.beep.error.frequency", - n("tutti.config.option.ichtyometer.beep.error.frequency.description"), + n("tutti.config.option.externalDevices.beep.error.frequency.description"), "A1", BeepFrequency.class, false diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/util/SerialPort.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/util/SerialPort.java new file mode 100644 index 0000000..6cd4ba7 --- /dev/null +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/util/SerialPort.java @@ -0,0 +1,12 @@ +package fr.ifremer.tutti.util; + +/** + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public enum SerialPort { + + COM1, + COM2, + COM3 +} diff --git a/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties b/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties index 4878154..e9fd0bc 100644 --- a/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties +++ b/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties @@ -18,6 +18,13 @@ tutti.config.option.db.import.skipBackup.description= tutti.config.option.errorBeepFrequency.description= tutti.config.option.export.backup.directory.description= tutti.config.option.export.countryId.description= +tutti.config.option.externalDevices.beep.data.enabled.description= +tutti.config.option.externalDevices.beep.data.frequency.description= +tutti.config.option.externalDevices.beep.error.enabled.description= +tutti.config.option.externalDevices.beep.error.frequency.description= +tutti.config.option.externalDevices.maximumNumberOfAttemptToConnect.description= +tutti.config.option.externalDevices.reads.unit.description= +tutti.config.option.externalDevices.voice.enabled.description= tutti.config.option.genericFormat.import.maximumRowsInErrorPerFile.description= tutti.config.option.genericFormat.import.skipBackup.description= tutti.config.option.genericFormat.report.backup.directory.description= diff --git a/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties b/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties index dec1cfb..b64b634 100644 --- a/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties +++ b/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties @@ -11,6 +11,13 @@ tutti.config.option.data.directory.description=Répertoire de données de l'appl tutti.config.option.db.import.skipBackup.description=Pour ne pas effectuer une sauvegarde avant un import de base tutti.config.option.export.backup.directory.description=Répertoire où sont enregistrées les exports génériques tutti.config.option.export.countryId.description=L'id du pays à utiliser pour les exports (il s'agit de la valeur LOCATION.ID). +tutti.config.option.externalDevices.beep.data.enabled.description= +tutti.config.option.externalDevices.beep.data.frequency.description= +tutti.config.option.externalDevices.beep.error.enabled.description= +tutti.config.option.externalDevices.beep.error.frequency.description= +tutti.config.option.externalDevices.maximumNumberOfAttemptToConnect.description= +tutti.config.option.externalDevices.reads.unit.description= +tutti.config.option.externalDevices.voice.enabled.description= tutti.config.option.genericFormat.import.maximumRowsInErrorPerFile.description=Nombre maximum de lignes en erreur possible par fichier lors de la validation de l'import générique tutti.config.option.genericFormat.import.skipBackup.description=Pour ne pas effectuer une sauvegarde avant chaque import générique tutti.config.option.genericFormat.report.backup.directory.description=Répertoire où sont enregistrés les rapports de l'import générique diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java index d60cb57..a43feaf 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java @@ -256,8 +256,10 @@ public class TuttiConfigUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, // ichtyometer category - helper.addCategory(n("tutti.config.category.ichtyometer"), - n("tutti.config.category.ichtyometer.description")) + helper.addCategory(n("tutti.config.category.externalDevices"), + n("tutti.config.category.externalDevices.description")) + + // ichtyometer .addOption(TuttiConfigurationOption.FULL_BLUETOOTH_SCAN) .setOptionShortLabel(t("tutti.config.option.ui.fullBluetoothScan.shortLabel")) @@ -265,24 +267,30 @@ public class TuttiConfigUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, .addOption(TuttiConfigurationOption.ICHTYOMETER_MAXIMUM_NUMBER_OF_ATTEMPT_TO_CONNECT) .setOptionShortLabel(t("tutti.config.option.ui.ichtyometerMaximumNumberOfAttemptToConnect.shortLabel")) - .addOption(TuttiConfigurationOption.ICHTYOMETER_VOICE_ENABLED) - .setOptionShortLabel(t("tutti.config.option.ui.ichtyometerVoiceEnabled.shortLabel")) + // caliper + + .addOption(TuttiConfigurationOption.CALIPER_SERIAL_PORT) + .setOptionShortLabel(t("tutti.config.option.ui.caliperSerialPort.shortLabel")) + + // all devices - .addOption(TuttiConfigurationOption.ICHTYOMETER_READS_UNIT) - .setOptionShortLabel(t("tutti.config.option.ui.ichtyometerReadsUnit.shortLabel")) + .addOption(TuttiConfigurationOption.EXTERNAL_DEVICES_VOICE_ENABLED) + .setOptionShortLabel(t("tutti.config.option.ui.externalDevicesVoiceEnabled.shortLabel")) + .addOption(TuttiConfigurationOption.EXTERNAL_DEVICES_READS_UNIT) + .setOptionShortLabel(t("tutti.config.option.ui.externalDevicesReadsUnit.shortLabel")) - .addOption(TuttiConfigurationOption.ICHTYOMETER_DATA_RECEPTION_BEEP_ENABLED) - .setOptionShortLabel(t("tutti.config.option.ui.ichtyometerDataBeepEnabled.shortLabel")) + .addOption(TuttiConfigurationOption.EXTERNAL_DEVICES_DATA_RECEPTION_BEEP_ENABLED) + .setOptionShortLabel(t("tutti.config.option.ui.externalDevicesDataBeepEnabled.shortLabel")) - .addOption(TuttiConfigurationOption.ICHTYOMETER_DATA_RECEPTION_BEEP_FREQUENCY) - .setOptionShortLabel(t("tutti.config.option.ui.ichtyometerDataBeepFrequency.shortLabel")) + .addOption(TuttiConfigurationOption.EXTERNAL_DEVICES_DATA_RECEPTION_BEEP_FREQUENCY) + .setOptionShortLabel(t("tutti.config.option.ui.externalDevicesDataBeepFrequency.shortLabel")) - .addOption(TuttiConfigurationOption.ICHTYOMETER_ERROR_RECEPTION_BEEP_ENABLED) - .setOptionShortLabel(t("tutti.config.option.ui.ichtyometerErrorBeepEnabled.shortLabel")) + .addOption(TuttiConfigurationOption.EXTERNAL_DEVICES_ERROR_RECEPTION_BEEP_ENABLED) + .setOptionShortLabel(t("tutti.config.option.ui.externalDevicesErrorBeepEnabled.shortLabel")) - .addOption(TuttiConfigurationOption.ICHTYOMETER_ERROR_RECEPTION_BEEP_FREQUENCY) - .setOptionShortLabel(t("tutti.config.option.ui.ichtyometerErrorBeepFrequency.shortLabel")); + .addOption(TuttiConfigurationOption.EXTERNAL_DEVICES_ERROR_RECEPTION_BEEP_FREQUENCY) + .setOptionShortLabel(t("tutti.config.option.ui.externalDevicesErrorBeepFrequency.shortLabel")); // Technical category diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/SoundEngine.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/SoundEngine.java index a3f150a..2edf69d 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/SoundEngine.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/SoundEngine.java @@ -67,11 +67,11 @@ public class SoundEngine implements Closeable { public synchronized void beepOnIchtyometerDataReception(String unit, float aroundLengthStep) { - if (configuration.isIchtyometerDataReceptionBeepEnabled()) { - soundsToPlay.add(configuration.getIchtyometerDataReceptionBeepFrequency()); + if (configuration.isExternalDevicesDataReceptionBeepEnabled()) { + soundsToPlay.add(configuration.getExternalDevicesDataReceptionBeepFrequency()); } - if (configuration.isIchtyometerVoiceEnabled()) { + if (configuration.isExternalDevicesVoiceEnabled()) { soundsToPlay.add(new Measure(unit, aroundLengthStep)); } @@ -79,9 +79,9 @@ public class SoundEngine implements Closeable { public synchronized void beepOnIchtyometerErrorReception() { - if (configuration.isIchtyometerErrorReceptionBeepEnabled()) { + if (configuration.isExternalDevicesErrorReceptionBeepEnabled()) { for (int i = 0; i < 3; i++) { - soundsToPlay.add(configuration.getIchtyometerDataReceptionBeepFrequency()); + soundsToPlay.add(configuration.getExternalDevicesDataReceptionBeepFrequency()); } } @@ -136,7 +136,7 @@ public class SoundEngine implements Closeable { log.info("New Measure to say: " + measure); } String unit; - if (configuration.isIchtyometerReadsUnit()) { + if (configuration.isExternalDevicesReadsUnit()) { unit = measure.unit; } else { unit = null; @@ -144,7 +144,7 @@ public class SoundEngine implements Closeable { SoundUtil.readNumber(measure.aroundLengthStep, Optional.fromNullable(unit)); } else if (sound instanceof BeepFrequency) { - SoundUtil.beep(configuration.getIchtyometerErrorReceptionBeepFrequency()); + SoundUtil.beep(configuration.getExternalDevicesErrorReceptionBeepFrequency()); } } diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties index a1df422..1038958 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties @@ -153,6 +153,8 @@ tutti.config.action.reload.application= tutti.config.action.reload.ui= tutti.config.category.applications= tutti.config.category.applications.description= +tutti.config.category.externalDevices= +tutti.config.category.externalDevices.description= tutti.config.category.ichtyometer= tutti.config.category.ichtyometer.description= tutti.config.category.technical= @@ -185,6 +187,7 @@ tutti.config.option.site.url.shortLabel= tutti.config.option.tmp.directory.shortLabel= tutti.config.option.tremieCarousselVessel.shortLabel= tutti.config.option.ui.beepFrequency.shortLabel= +tutti.config.option.ui.caliperSerialPort.shortLabel= tutti.config.option.ui.color.alternateRow.shortLabel= tutti.config.option.ui.color.benthos.shortLabel= tutti.config.option.ui.color.blockingLayer.shortLabel= @@ -205,6 +208,12 @@ tutti.config.option.ui.config.file.shortLabel= tutti.config.option.ui.coordinateEditorType.shortLabel= tutti.config.option.ui.dateFormat.shortLabel= tutti.config.option.ui.db.import.skipBackup.shortLabel= +tutti.config.option.ui.externalDevicesDataBeepEnabled.shortLabel= +tutti.config.option.ui.externalDevicesDataBeepFrequency.shortLabel= +tutti.config.option.ui.externalDevicesErrorBeepEnabled.shortLabel= +tutti.config.option.ui.externalDevicesErrorBeepFrequency.shortLabel= +tutti.config.option.ui.externalDevicesReadsUnit.shortLabel= +tutti.config.option.ui.externalDevicesVoiceEnabled.shortLabel= tutti.config.option.ui.fullBluetoothScan.shortLabel= tutti.config.option.ui.genericFormat.import.maximumRowsInErrorPerFile.shortLabel= tutti.config.option.ui.genericFormat.import.skipBackup.shortLabel= diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties index 647a22e..b18f4c2 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties @@ -125,6 +125,8 @@ tutti.config.action.reload.application=Recharger l'application tutti.config.action.reload.ui=Recharger l'interface graphique tutti.config.category.applications=Application tutti.config.category.applications.description=Application +tutti.config.category.externalDevices= +tutti.config.category.externalDevices.description= tutti.config.category.ichtyometer=Ichtyomètre tutti.config.category.ichtyometer.description=Ichtyomètre tutti.config.category.technical=Technique @@ -157,6 +159,7 @@ tutti.config.option.site.url.shortLabel=URL du site technique tutti.config.option.tmp.directory.shortLabel=Répertoire temporaire tutti.config.option.tremieCarousselVessel.shortLabel=Navire ayant un carrousel et une trémie tutti.config.option.ui.beepFrequency.shortLabel=Tonalité du bip +tutti.config.option.ui.caliperSerialPort.shortLabel= tutti.config.option.ui.color.alternateRow.shortLabel=Couleur alternée tutti.config.option.ui.color.benthos.shortLabel=Couleur des libellés de benthos (Écran Capture > Résumé) tutti.config.option.ui.color.blockingLayer.shortLabel=Couleur d'attente @@ -177,6 +180,12 @@ tutti.config.option.ui.config.file.shortLabel=Chemin du fichier de confirmation tutti.config.option.ui.coordinateEditorType.shortLabel=Formateur de coordonnées tutti.config.option.ui.dateFormat.shortLabel=Format des dates tutti.config.option.ui.db.import.skipBackup.shortLabel=Ne pas faire de sauvegarde avant un import de base +tutti.config.option.ui.externalDevicesDataBeepEnabled.shortLabel= +tutti.config.option.ui.externalDevicesDataBeepFrequency.shortLabel= +tutti.config.option.ui.externalDevicesErrorBeepEnabled.shortLabel= +tutti.config.option.ui.externalDevicesErrorBeepFrequency.shortLabel= +tutti.config.option.ui.externalDevicesReadsUnit.shortLabel= +tutti.config.option.ui.externalDevicesVoiceEnabled.shortLabel= tutti.config.option.ui.fullBluetoothScan.shortLabel=Recherche complète des périphériques bluetooth tutti.config.option.ui.genericFormat.import.maximumRowsInErrorPerFile.shortLabel=Nombre maximum de lignes en erreur possible par fichier lors de la validation de l'import générique tutti.config.option.ui.genericFormat.import.skipBackup.shortLabel=Ne pas faire de sauvegarde avant un import au format générique -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 0ad86dc1263c7303e33d2f5c90bbb226effef4f3 Author: Kevin Morin <morin@codelutin.com> Date: Wed Apr 20 16:16:55 2016 +0200 ajout de la connexion au pied à coulisse depuis l'appli (refs #7459) --- .../tutti/caliper/feed/CaliperFeedReader.java | 3 + .../fr/ifremer/tutti/TuttiConfigurationOption.java | 2 +- .../i18n/tutti-persistence_fr_FR.properties | 20 ++--- tutti-ui-swing/pom.xml | 5 ++ .../filtered-resources/tutti-help-fr.properties | 28 +------ .../fr/ifremer/tutti/ui/swing/TuttiUIContext.java | 27 +++++++ .../fr/ifremer/tutti/ui/swing/content/MainUI.jaxx | 3 + .../fr/ifremer/tutti/ui/swing/content/MainUI.jcss | 29 +++++++ .../tutti/ui/swing/content/MainUIHandler.java | 21 +++++ .../content/actions/ConnectCaliperAction.java | 66 ++++++++++++++++ .../content/actions/DisconnectCaliperAction.java | 54 +++++++++++++ .../frequency/SpeciesFrequencyUIHandler.java | 92 ++++++++++++++++++++-- .../actions/ApplySpeciesFrequencyRafaleAction.java | 2 +- .../ifremer/tutti/ui/swing/util/SoundEngine.java | 4 +- .../resources/i18n/tutti-ui-swing_en_GB.properties | 13 +++ .../resources/i18n/tutti-ui-swing_fr_FR.properties | 41 +++++----- 16 files changed, 342 insertions(+), 68 deletions(-) diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java index f2febd9..6dbec27 100644 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java @@ -130,6 +130,9 @@ public class CaliperFeedReader implements Closeable { } } + public String getSerialPortName() { + return serialPort != null ? serialPort.getName() : null; + } /** * Handles the input coming from the serial port. A new line character diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java index a758b60..97c0413 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java @@ -649,7 +649,7 @@ public enum TuttiConfigurationOption implements ConfigOptionDef { ), CALIPER_SERIAL_PORT( "tutti.ichtyometer.caliperSerialPort", - n("tutti.config.option.externalDevices.maximumNumberOfAttemptToConnect.description"), + n("tutti.config.option.caliper.serialPort.description"), "COM1", SerialPort.class, false diff --git a/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties b/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties index b64b634..713c0cc 100644 --- a/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties +++ b/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties @@ -5,33 +5,27 @@ application.common.unit.short.g=g application.common.unit.short.kg=kg tutti.config=Configuration d'Allegro Campagne tutti.config.option.basedir.description=Répertoire principale +tutti.config.option.caliper.serialPort.description=Port série de connexion au pied à coulisse tutti.config.option.cruiseId.description=Identifiant de la dernière campagne utilisée tutti.config.option.csv.separator.description=Caractère séparateur pour les import / export de fichier au format csv. tutti.config.option.data.directory.description=Répertoire de données de l'application. Vous pouvez utiliser l'expression ${tutti.data.directory} pour le référence dans d'autres propriétés de configuration (ex\: ${tutti.data.directory}/tmp). tutti.config.option.db.import.skipBackup.description=Pour ne pas effectuer une sauvegarde avant un import de base tutti.config.option.export.backup.directory.description=Répertoire où sont enregistrées les exports génériques tutti.config.option.export.countryId.description=L'id du pays à utiliser pour les exports (il s'agit de la valeur LOCATION.ID). -tutti.config.option.externalDevices.beep.data.enabled.description= -tutti.config.option.externalDevices.beep.data.frequency.description= -tutti.config.option.externalDevices.beep.error.enabled.description= -tutti.config.option.externalDevices.beep.error.frequency.description= -tutti.config.option.externalDevices.maximumNumberOfAttemptToConnect.description= -tutti.config.option.externalDevices.reads.unit.description= -tutti.config.option.externalDevices.voice.enabled.description= +tutti.config.option.externalDevices.beep.data.enabled.description=Pour activer ou non le bip à la réception de mesures +tutti.config.option.externalDevices.beep.data.frequency.description=Tonalité du bip lors de la réception de données d'un appareil externe +tutti.config.option.externalDevices.beep.error.enabled.description=Pour activer ou non le bip à la réception d'erreurs +tutti.config.option.externalDevices.beep.error.frequency.description=Tonalité du bip lors de la réception d'une erreur d'un appareil externe +tutti.config.option.externalDevices.reads.unit.description=Pour lire l'unité à la réception d'une mesure +tutti.config.option.externalDevices.voice.enabled.description=Pour activer ou non la lecture vocale des mesures reçues tutti.config.option.genericFormat.import.maximumRowsInErrorPerFile.description=Nombre maximum de lignes en erreur possible par fichier lors de la validation de l'import générique tutti.config.option.genericFormat.import.skipBackup.description=Pour ne pas effectuer une sauvegarde avant chaque import générique tutti.config.option.genericFormat.report.backup.directory.description=Répertoire où sont enregistrés les rapports de l'import générique tutti.config.option.help.directory.description=Répertoire des fichiers d'aide tutti.config.option.i18n.directory.description=Répertoire des fichiers de traductions tutti.config.option.i18n.locale.description=Langue utilisée dans l'application -tutti.config.option.ichtyometer.beep.data.enabled.description=Pour activer ou non le bip à la réception de mesures -tutti.config.option.ichtyometer.beep.data.frequency.description=Tonalité du bip lors de la réception de données de l'ichtyomètre -tutti.config.option.ichtyometer.beep.error.enabled.description=Pour activer ou non le bip à la réception d'erreurs -tutti.config.option.ichtyometer.beep.error.frequency.description=Tonalité du bip lors de la réception d'une erreur de l'ichtyomètre tutti.config.option.ichtyometer.fullBluetoothScan.description=Pour toujours effectuer une recherche complète des périphériques bluetooth lors de la recherche d'un ichtyomètre tutti.config.option.ichtyometer.maximumNumberOfAttemptToConnect.description=Nombre maximum de de tentatives de connection à l'ichtyomètre -tutti.config.option.ichtyometer.reads.unit.description=Pour lire l'unité à la réception d'une mesure -tutti.config.option.ichtyometer.voice.enabled.description=Pour activer ou non la lecture vocale des mesures reçues tutti.config.option.inceptionYear.description=Année de démarrage du projet tutti.config.option.launch.mode.description=Mode de démarrage de l'application tutti.config.option.organizationName.description=Nom de l'organisation dans la licence diff --git a/tutti-ui-swing/pom.xml b/tutti-ui-swing/pom.xml index a9d5671..fa4d30c 100644 --- a/tutti-ui-swing/pom.xml +++ b/tutti-ui-swing/pom.xml @@ -117,6 +117,11 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>tutti-caliper</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>tutti-ui-swing-updater</artifactId> <version>${project.version}</version> </dependency> diff --git a/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties b/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties index b572bae..af6a40a 100644 --- a/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties +++ b/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties @@ -1,28 +1,5 @@ -### -# #%L -# Tutti :: UI -# $Id:$ -# $HeadURL:$ -# %% -# Copyright (C) 2012 - 2016 Ifremer -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### #Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo -#Fri Apr 01 23:37:59 CEST 2016 +#Wed Apr 20 15:51:16 CEST 2016 tutti.config.help=config.html tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions @@ -425,7 +402,9 @@ tutti.main.menu.action.changeLocale.help=menu.html\#menu_aide tutti.main.menu.action.changeLocaleFR.help=menu.html\#menu_aide tutti.main.menu.action.changeLocaleUK.help=menu.html\#menu_aide tutti.main.menu.action.configuration.help=menu.html\#menu_fichier_configuration +tutti.main.menu.action.connectCaliper.help= tutti.main.menu.action.connectIchtyometer.help=menu.html\#menu_fichier +tutti.main.menu.action.disconnectCaliper.help= tutti.main.menu.action.disconnectIchtyometer.help=menu.html\#menu_fichier tutti.main.menu.action.editCatches.help=menu.html\#menu_action tutti.main.menu.action.editCruise.help=menu.html\#menu_action @@ -445,6 +424,7 @@ tutti.main.menu.action.site.help=menu.html\#menu_aide tutti.main.menu.action.updateApplication.help=menu.html\#menu_fichier tutti.main.menu.action.updateReport.help=menu.html\#menu_fichier tutti.main.menu.action.validateCatches.help=menu.html\#menu_action +tutti.main.status.caliper.help= tutti.main.status.ichtyometer.help=menu.html\#status tutti.main.status.validation.help=menu.html\#status tutti.manageTemporaryReferential.action.exportExistingTemporaryGear.help=menu.html\#menu_administration_referentiel diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java index 748691b..99cf0a8 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java @@ -26,6 +26,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import fr.ifremer.tutti.TuttiConfiguration; +import fr.ifremer.tutti.caliper.feed.CaliperFeedReader; import fr.ifremer.tutti.ichtyometer.feed.IchtyometerFeedReader; import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.service.ClosedPersistenceService; @@ -142,6 +143,8 @@ public class TuttiUIContext extends AbstractBean implements Closeable, UIMessage public static final String PROPERTY_ICHTYOMETER_CONNECTED = "ichtyometerConnected"; + public static final String PROPERTY_CALIPER_CONNECTED = "caliperConnected"; + public static final String PROPERTY_BUSY = "busy"; public static final String PROPERTY_HIDE_BODY = "hideBody"; @@ -288,6 +291,13 @@ public class TuttiUIContext extends AbstractBean implements Closeable, UIMessage private IchtyometerFeedReader ichtyometerReader; /** + * Caliper Reader. + * + * @since 4.5 + */ + private CaliperFeedReader caliperFeedReader; + + /** * A file lock to prevent multiple instance. the lock is create in the {@link #init()} method and remove in the * {@link #close()} method. * @@ -1129,6 +1139,23 @@ public class TuttiUIContext extends AbstractBean implements Closeable, UIMessage } //------------------------------------------------------------------------// + //-- Caliper methods --// + //------------------------------------------------------------------------// + + public CaliperFeedReader getCaliperReader() { + return caliperFeedReader; + } + + public void setCaliperReader(CaliperFeedReader caliperFeedReader) { + this.caliperFeedReader = caliperFeedReader; + firePropertyChange(PROPERTY_CALIPER_CONNECTED, null, isCaliperConnected()); + } + + public boolean isCaliperConnected() { + return caliperFeedReader != null; + } + + //------------------------------------------------------------------------// //-- Other methods --// //------------------------------------------------------------------------// diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx index 275ecd6..f49d102 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx @@ -61,6 +61,8 @@ <JSeparator/> <JMenuItem id='menuFileConnectIchtyometer'/> <JMenuItem id='menuFileDisconnectIchtyometer'/> + <JMenuItem id='menuFileConnectCaliper'/> + <JMenuItem id='menuFileDisconnectCaliper'/> <JSeparator/> <JMenuItem id='menuFileManageDb'/> <JSeparator/> @@ -98,6 +100,7 @@ <JToolBar id='bottomBar'> <JLabel id='ichtyometerStatus'/> + <JLabel id='caliperStatus'/> <SwingValidatorMessageWidget id='validatorMessageWidget'/> </JToolBar> diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss index c57300b..ce1cee1 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss @@ -109,6 +109,27 @@ JMenu { _help: {"tutti.main.menu.action.disconnectIchtyometer.help"}; } + +#menuFileConnectCaliper { + actionIcon: bluetooth-down; + text: "tutti.main.action.connectCaliper"; + toolTipText: "tutti.main.action.connectCaliper.tip"; + i18nMnemonic: "tutti.main.action.connectCaliper.mnemonic"; + visible: {!model.isCaliperConnected()}; + _applicationAction: {fr.ifremer.tutti.ui.swing.content.actions.ConnectCaliperAction.class}; + _help: {"tutti.main.menu.action.connectCaliper.help"}; +} + +#menuFileDisconnectCaliper { + actionIcon: bluetooth-up; + text: "tutti.main.action.disconnectCaliper"; + toolTipText: "tutti.main.action.disconnectCaliper.tip"; + i18nMnemonic: "tutti.main.action.disconnectCaliper.mnemonic"; + visible: {model.isCaliperConnected()}; + _applicationAction: {fr.ifremer.tutti.ui.swing.content.actions.DisconnectCaliperAction.class}; + _help: {"tutti.main.menu.action.disconnectCaliper.help"}; +} + #menuFileManageDb { actionIcon: manage-db; text: "tutti.main.action.manageDb"; @@ -315,6 +336,14 @@ JMenu { _help: {"tutti.main.status.ichtyometer.help"}; } +#caliperStatus { + actionIcon: "bluetooth-up"; + disabledIcon: {jaxx.runtime.SwingUtil.createActionIcon("bluetooth-down")}; + enabled: {model.isCaliperConnected()}; + toolTipText: {handler.getCaliperStatusLabel(model.isCaliperConnected())}; + _help: {"tutti.main.status.caliper.help"}; +} + #showHelp { actionIcon:"show-help"; toolTipText:"tutti.main.action.showHelp.tip"; diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java index 08c7ce2..e6ce5ab 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java @@ -23,6 +23,7 @@ package fr.ifremer.tutti.ui.swing.content; */ import com.google.common.base.Preconditions; +import fr.ifremer.tutti.caliper.feed.CaliperFeedReader; import fr.ifremer.tutti.ichtyometer.feed.IchtyometerFeedReader; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.Program; @@ -103,6 +104,26 @@ public class MainUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, MainUI } return result; } + + public String getCaliperStatusLabel(boolean connected) { + String result = null; + if (connected) { + CaliperFeedReader caliperReader = getModel().getCaliperReader(); + result = caliperReader.getSerialPortName(); + } + return result; + } + + public String getCaliperStatusTip(boolean connected) { + String result; + if (connected) { + CaliperFeedReader caliperReader = getModel().getCaliperReader(); + result = t("tutti.caliper.status.connected.tip", caliperReader.getSerialPortName()); + } else { + result = t("tutti.caliper.status.not.connected.tip"); + } + return result; + } //------------------------------------------------------------------------// //-- AbstractTuttiUIHandler methods --// //------------------------------------------------------------------------// diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/ConnectCaliperAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/ConnectCaliperAction.java new file mode 100644 index 0000000..ddd0584 --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/ConnectCaliperAction.java @@ -0,0 +1,66 @@ +package fr.ifremer.tutti.ui.swing.content.actions; + +/* + * #%L + * Tutti :: UI + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.caliper.feed.CaliperFeedReader; +import fr.ifremer.tutti.ui.swing.content.MainUIHandler; + +import static org.nuiton.i18n.I18n.t; + +/** + * Establish a connection to an ichtyometer. + * + * Created on 1/29/14. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 3.1 + */ +public class ConnectCaliperAction extends AbstractMainUITuttiAction { + + public ConnectCaliperAction(MainUIHandler handler) { + super(handler, false); + } + + @Override + public void doAction() throws Exception { + + CaliperFeedReader caliperReader = new CaliperFeedReader(); + caliperReader.start(getConfig().getCaliperSerialPort().name()); + + getContext().setCaliperReader(caliperReader); + } + + @Override + public void postSuccessAction() { + super.postSuccessAction(); + + CaliperFeedReader caliperReader = getContext().getCaliperReader(); + String serialPort = caliperReader.getSerialPortName(); + sendMessage(t("tutti.caliper.connection.establish", serialPort)); + + displayInfoMessage( + t("tutti.caliper.connection.establish.title"), + t("tutti.caliper.connection.establish.message", serialPort) + ); + } +} diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/DisconnectCaliperAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/DisconnectCaliperAction.java new file mode 100644 index 0000000..487035a --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/DisconnectCaliperAction.java @@ -0,0 +1,54 @@ +package fr.ifremer.tutti.ui.swing.content.actions; + +/* + * #%L + * Tutti :: UI + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.caliper.feed.CaliperFeedReader; +import fr.ifremer.tutti.ui.swing.content.MainUIHandler; +import org.apache.commons.io.IOUtils; + +import static org.nuiton.i18n.I18n.t; + +/** + * Close the connection to caliper. + * + * @author Kevin Morin (Code Lutin) + * @since 4.6 + */ +public class DisconnectCaliperAction extends AbstractMainUITuttiAction { + + public DisconnectCaliperAction(MainUIHandler handler) { + super(handler, false); + } + + @Override + public void doAction() throws Exception { + + CaliperFeedReader caliperReader = getContext().getCaliperReader(); + + // there is a feed reader, stop it now + IOUtils.closeQuietly(caliperReader); + getContext().setCaliperReader(null); + + sendMessage(t("tutti.caliper.connection.stop", caliperReader.getSerialPortName())); + } +} diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java index f05ea82..2558ac3 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java @@ -128,7 +128,11 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci /** * To consume measures when they arrive from the ichtyometer. */ - protected final IchtyometerFeedReaderListener feedReaderListener; + protected final IchtyometerFeedReaderListener ichtyometerFeedReaderListener; + /** + * To consume measures when they arrive from the caliper. + */ + protected final CaliperFeedReaderListener caliperFeedReaderListener; protected ApplySpeciesFrequencyRafaleAction applySpeciesFrequencyRafaleAction; @@ -149,7 +153,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci SpeciesFrequencyRowModel.PROPERTY_NUMBER, SpeciesFrequencyRowModel.PROPERTY_WEIGHT); - this.feedReaderListener = new IchtyometerFeedReaderListener() { + this.ichtyometerFeedReaderListener = new IchtyometerFeedReaderListener() { @Override public void recordRead(IchtyometerFeedReaderEvent event) { @@ -160,7 +164,25 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci if (!getModel().isSimpleCountingMode()) { // can try to consume value - consumeFeedRecord(record); + consumeIchtyometerFeedRecord(record); + } + } + ); + } + }; + + this.caliperFeedReaderListener = new CaliperFeedReaderListener() { + + @Override + public void recordRead(CaliperFeedReaderEvent event) { + final CaliperFeedReaderMeasureRecord record = event.getRecord(); + + SwingUtilities.invokeLater( + () -> { + if (!getModel().isSimpleCountingMode()) { + + // can try to consume value + consumeCaliperFeedRecord(record); } } ); @@ -524,7 +546,12 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci if (context.isIchtyometerConnected()) { - context.getIchtyometerReader().removeFeedModeReaderListener(feedReaderListener); + context.getIchtyometerReader().removeFeedModeReaderListener(ichtyometerFeedReaderListener); + } + + if (context.isCaliperConnected()) { + + context.getCaliperReader().removeFeedModeReaderListener(caliperFeedReaderListener); } EditSpeciesBatchPanelUI parent = getParentContainer(EditSpeciesBatchPanelUI.class); @@ -609,6 +636,13 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } + if (getContext().isCaliperConnected()) { + + // let's listen the caliper + listenCaliper(); + + } + model.setModify(false); } @@ -914,7 +948,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci return col; } - protected void consumeFeedRecord(IchtyometerFeedReaderMeasureRecord record) { + protected void consumeIchtyometerFeedRecord(IchtyometerFeedReaderMeasureRecord record) { if (record.isValid()) { String unit = getModel().getLengthStepCaracteristicUnit(); @@ -940,12 +974,44 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } else { SoundEngine soundEngine = getContext().getSoundEngine(); - soundEngine.beepOnIchtyometerErrorReception(); + soundEngine.beepOnExternalDeviceErrorReception(); throw new ApplicationBusinessException(t("tutti.editSpeciesFrequencies.error.itchyometer.bad.record", record.getRecord())); } } + protected void consumeCaliperFeedRecord(CaliperFeedReaderMeasureRecord record) { + if (record.isValid()) { + + String unit = getModel().getLengthStepCaracteristicUnit(); + + // board measurements are in mm + + float length; + + if ("mm".equals(unit)) { + + // measurement in mm asked + length = record.getMeasure(); + + } else { + + // measurement in cm asked + length = record.getMeasure() / 10f; + + } + + applySpeciesFrequencyRafaleAction.applyRafaleStep(length, true); + + } else { + + SoundEngine soundEngine = getContext().getSoundEngine(); + soundEngine.beepOnExternalDeviceErrorReception(); + + throw new ApplicationBusinessException(t("tutti.editSpeciesFrequencies.error.caliper.bad.record", record.getRecord())); + } + } + protected void listenItchtyometer() { // always remove the listener before adding it to be sure it will not be there twice @@ -953,7 +1019,17 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci if (log.isInfoEnabled()) { log.info("Start listen ichtyometer"); } - getContext().getIchtyometerReader().addFeedModeReaderListener(feedReaderListener); + getContext().getIchtyometerReader().addFeedModeReaderListener(ichtyometerFeedReaderListener); + } + + protected void listenCaliper() { + + // always remove the listener before adding it to be sure it will not be there twice + getContext().getCaliperReader().removeAllFeedModeReaderListeners(); + if (log.isInfoEnabled()) { + log.info("Start listen caliper"); + } + getContext().getCaliperReader().addFeedModeReaderListener(caliperFeedReaderListener); } protected JComponent getComponentToFocus(FrequencyConfigurationMode mode) { @@ -992,7 +1068,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci protected void updateLogVisibility() { - boolean logVisible = getModel().isRafaleMode() || getContext().isIchtyometerConnected(); + boolean logVisible = getModel().isRafaleMode() || getContext().isIchtyometerConnected() || getContext().isCaliperConnected(); JSplitPane firstSplitPane = ui.getFirstSplitPane(); JSplitPane secondSplitPane = ui.getSecondSplitPane(); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/actions/ApplySpeciesFrequencyRafaleAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/actions/ApplySpeciesFrequencyRafaleAction.java index d10a1f5..a77cd37 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/actions/ApplySpeciesFrequencyRafaleAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/actions/ApplySpeciesFrequencyRafaleAction.java @@ -114,7 +114,7 @@ public class ApplySpeciesFrequencyRafaleAction { String unit = model.getLengthStepCaracteristicUnit(); handler.showInformationMessage(t("tutti.editSpeciesFrequencies.addMeasure", step, aroundLengthStep, unit)); - soundEngine.beepOnIchtyometerDataReception(unit, aroundLengthStep); + soundEngine.beepOnExternalDeviceDataReception(unit, aroundLengthStep); } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/SoundEngine.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/SoundEngine.java index 2edf69d..0d0326c 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/SoundEngine.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/SoundEngine.java @@ -65,7 +65,7 @@ public class SoundEngine implements Closeable { thread.start(); } - public synchronized void beepOnIchtyometerDataReception(String unit, float aroundLengthStep) { + public synchronized void beepOnExternalDeviceDataReception(String unit, float aroundLengthStep) { if (configuration.isExternalDevicesDataReceptionBeepEnabled()) { soundsToPlay.add(configuration.getExternalDevicesDataReceptionBeepFrequency()); @@ -77,7 +77,7 @@ public class SoundEngine implements Closeable { } - public synchronized void beepOnIchtyometerErrorReception() { + public synchronized void beepOnExternalDeviceErrorReception() { if (configuration.isExternalDevicesErrorReceptionBeepEnabled()) { for (int i = 0; i < 3; i++) { diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties index 1038958..9722252 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties @@ -90,6 +90,12 @@ tutti.attachmentEditor.saveAttachment.title= tutti.attachmentEditor.simpleText= tutti.attachmentEditor.text= tutti.attachmentEditor.title= +tutti.caliper.connection.establish= +tutti.caliper.connection.establish.message= +tutti.caliper.connection.establish.title= +tutti.caliper.connection.stop= +tutti.caliper.status.connected.tip= +tutti.caliper.status.not.connected.tip= tutti.caracteristicMapEditor.none.tip= tutti.caracteristicMapEditorTable.table.header.key= tutti.caracteristicMapEditorTable.table.header.value= @@ -1581,6 +1587,7 @@ tutti.editSpeciesFrequencies.changeCopyMode.confirm.title= tutti.editSpeciesFrequencies.changeCopyRtpWeights.confirm.help= tutti.editSpeciesFrequencies.changeCopyRtpWeights.confirm.message= tutti.editSpeciesFrequencies.changeCopyRtpWeights.confirm.title= +tutti.editSpeciesFrequencies.error.caliper.bad.record= tutti.editSpeciesFrequencies.error.itchyometer.bad.record= tutti.editSpeciesFrequencies.error.length.doublon= tutti.editSpeciesFrequencies.error.notAvailableSamplingCode= @@ -2053,9 +2060,15 @@ tutti.main.action.changeLocaleUK.tip= tutti.main.action.configuration= tutti.main.action.configuration.mnemonic= tutti.main.action.configuration.tip= +tutti.main.action.connectCaliper= +tutti.main.action.connectCaliper.mnemonic= +tutti.main.action.connectCaliper.tip= tutti.main.action.connectIchtyometer= tutti.main.action.connectIchtyometer.mnemonic= tutti.main.action.connectIchtyometer.tip= +tutti.main.action.disconnectCaliper= +tutti.main.action.disconnectCaliper.mnemonic= +tutti.main.action.disconnectCaliper.tip= tutti.main.action.disconnectIchtyometer= tutti.main.action.disconnectIchtyometer.mnemonic= tutti.main.action.disconnectIchtyometer.tip= diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties index b18f4c2..dcb5904 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties @@ -3,7 +3,6 @@ application.error.ui.business.warning= jaxx.application.action.create.error= jaxx.application.common.askBeforeDelete.help= swing.error.cannot.open.file=Aucun programme n'est défini pour ouvrir ce type de fichier. Enregistrez le fichier et ouvrez le en dehors de l'application -test= tutti.about.bottomText=Copyright %s - %s - version %s tutti.about.message=<h3>Allegro Campagne</h3><p><strong>Outil de saisie de données d'opérations et de captures au cours des campagnes halieutiques.</strong></p><br/><p>Ce logiciel permettra la saisie en mer des données d'opération de pêche (positions, environnement, engin, etc) et des captures associées (composition de la capture en espèces scientifiques avec poids, nombres, tailles etc) pour l'ensemble des campagnes halieutiques réalisées par l'Ifremer.</p><p>Ce projet a été initiée en [...] tutti.about.title=À propos d'Allegro Campagne @@ -73,6 +72,12 @@ tutti.attachmentEditor.saveAttachment.title=Enregistrer la pièce-jointe tutti.attachmentEditor.simpleText=Pièce(s) jointe(s) tutti.attachmentEditor.text=(%s) tutti.attachmentEditor.title=Pièces jointes +tutti.caliper.connection.establish=Connexion au pied à coulisse établie sur le port <strong>%s</strong> +tutti.caliper.connection.establish.message=<html><body>La connexion au pied à coulisse est établie sur le port <strong>%s</strong>.</body></html> +tutti.caliper.connection.establish.title=Connexion établie +tutti.caliper.connection.stop=Connexion au pied à coulisse arrêtée +tutti.caliper.status.connected.tip=<html><body>Le pied à coulisse est connecté sur le port <strong>%s</strong>.</body></html> +tutti.caliper.status.not.connected.tip=<html><body>Aucun pied à coulisse connecté.</body></html> tutti.caracteristicMapEditor.none.tip=Pas de caractéristiques tutti.caracteristicMapEditorTable.table.header.key=Caractéristique tutti.caracteristicMapEditorTable.table.header.value=Valeur @@ -125,10 +130,8 @@ tutti.config.action.reload.application=Recharger l'application tutti.config.action.reload.ui=Recharger l'interface graphique tutti.config.category.applications=Application tutti.config.category.applications.description=Application -tutti.config.category.externalDevices= -tutti.config.category.externalDevices.description= -tutti.config.category.ichtyometer=Ichtyomètre -tutti.config.category.ichtyometer.description=Ichtyomètre +tutti.config.category.externalDevices=Apprareils externes +tutti.config.category.externalDevices.description=Appareils de mesure externes (ichtyomètre, pied à coulisse) tutti.config.category.technical=Technique tutti.config.category.technical.description=Informations techniques tutti.config.category.ui=Interface utilisateur @@ -159,7 +162,7 @@ tutti.config.option.site.url.shortLabel=URL du site technique tutti.config.option.tmp.directory.shortLabel=Répertoire temporaire tutti.config.option.tremieCarousselVessel.shortLabel=Navire ayant un carrousel et une trémie tutti.config.option.ui.beepFrequency.shortLabel=Tonalité du bip -tutti.config.option.ui.caliperSerialPort.shortLabel= +tutti.config.option.ui.caliperSerialPort.shortLabel=Port série de connexion au pied à coulisse tutti.config.option.ui.color.alternateRow.shortLabel=Couleur alternée tutti.config.option.ui.color.benthos.shortLabel=Couleur des libellés de benthos (Écran Capture > Résumé) tutti.config.option.ui.color.blockingLayer.shortLabel=Couleur d'attente @@ -180,25 +183,18 @@ tutti.config.option.ui.config.file.shortLabel=Chemin du fichier de confirmation tutti.config.option.ui.coordinateEditorType.shortLabel=Formateur de coordonnées tutti.config.option.ui.dateFormat.shortLabel=Format des dates tutti.config.option.ui.db.import.skipBackup.shortLabel=Ne pas faire de sauvegarde avant un import de base -tutti.config.option.ui.externalDevicesDataBeepEnabled.shortLabel= -tutti.config.option.ui.externalDevicesDataBeepFrequency.shortLabel= -tutti.config.option.ui.externalDevicesErrorBeepEnabled.shortLabel= -tutti.config.option.ui.externalDevicesErrorBeepFrequency.shortLabel= -tutti.config.option.ui.externalDevicesReadsUnit.shortLabel= -tutti.config.option.ui.externalDevicesVoiceEnabled.shortLabel= +tutti.config.option.ui.externalDevicesDataBeepEnabled.shortLabel=Bip à la réception de mesures +tutti.config.option.ui.externalDevicesDataBeepFrequency.shortLabel=Tonalité de réception de données +tutti.config.option.ui.externalDevicesErrorBeepEnabled.shortLabel=Bip à la réception d'erreur +tutti.config.option.ui.externalDevicesErrorBeepFrequency.shortLabel=Tonalité de réception d'erreur +tutti.config.option.ui.externalDevicesReadsUnit.shortLabel=Lire l'unité à la réception d'une mesure (utilisée uniquement si la lecture vocale est active) +tutti.config.option.ui.externalDevicesVoiceEnabled.shortLabel=Lecture vocale des mesures reçues tutti.config.option.ui.fullBluetoothScan.shortLabel=Recherche complète des périphériques bluetooth tutti.config.option.ui.genericFormat.import.maximumRowsInErrorPerFile.shortLabel=Nombre maximum de lignes en erreur possible par fichier lors de la validation de l'import générique tutti.config.option.ui.genericFormat.import.skipBackup.shortLabel=Ne pas faire de sauvegarde avant un import au format générique -tutti.config.option.ui.ichtyometerDataBeepEnabled.shortLabel=Bip à la réception de mesures -tutti.config.option.ui.ichtyometerDataBeepFrequency.shortLabel=Tonalité de réception de données -tutti.config.option.ui.ichtyometerErrorBeepEnabled.shortLabel=Bip à la réception d'erreur -tutti.config.option.ui.ichtyometerErrorBeepFrequency.shortLabel=Tonalité de réception d'erreur tutti.config.option.ui.ichtyometerMaximumNumberOfAttemptToConnect.shortLabel=Nombre maximum de tentatives de connection à l'ichtyomètre -tutti.config.option.ui.ichtyometerReadsUnit.shortLabel=Lire l'unité à la réception d'une mesure (utilisée uniquement si la lecture vocale est active) -tutti.config.option.ui.ichtyometerVoiceEnabled.shortLabel=Lecture vocale des mesures reçues tutti.config.option.ui.individualObservationRowsToCreate.shortLabel=Nombre max de données individuelles tutti.config.option.ui.samplingCodePrefix.shortLabel=Préfixe du code de prélèvement -tutti.config.option.ui.samplingCodeSeparator.shortLabel=Séparator du code de prélèvement tutti.config.option.ui.showBatchLog.shortLabel=Voir la structure des lots dans les logs tutti.config.option.ui.showMemoryUsage.shortLabel=Voir l'utilisation de la mémoire tutti.config.option.update.application.url.shortLabel=URL de mise à jour des applicatifs @@ -1481,6 +1477,7 @@ tutti.editSpeciesFrequencies.changeCopyMode.confirm.title=Changement de mode de tutti.editSpeciesFrequencies.changeCopyRtpWeights.confirm.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas copier les poids calculés via les RTP</li><li><strong>OK</strong> pour copier les poids calculés via les RTP et supprimer les données saisies</li></ul> tutti.editSpeciesFrequencies.changeCopyRtpWeights.confirm.message=Vous êtes sur le point de remplacer les poids saisis par les poids calculés via les RTP.<br/>Si vous les remplacez, les données saisies seront perdues. tutti.editSpeciesFrequencies.changeCopyRtpWeights.confirm.title=Copier les poids calculés via les RTP +tutti.editSpeciesFrequencies.error.caliper.bad.record=La mesure provenant du pied à coulisse n'est pas valide (la donnée est peut-être corrompue) \:<br/><ul><li>Enregistrement \: <strong>%s</strong></li><li>CRC \: <strong>%s</strong></li><li>CRC calculé \: <strong>%s</strong></li></ul> tutti.editSpeciesFrequencies.error.itchyometer.bad.record=La mesure provenant de l'ichtyomètre n'est pas valide (la donnée est peut-être corrompue) \:<br/><ul><li>Enregistrement \: <strong>%s</strong></li><li>CRC \: <strong>%s</strong></li><li>CRC calculé \: <strong>%s</strong></li></ul> tutti.editSpeciesFrequencies.error.length.doublon=La classe de taille <strong>%s</strong> est utilisée plusieurs fois (deuxième occurrence trouvée à la ligne <strong>%s</strong>), ce qui n'est pas autorisé.<hr/>Veuillez corriger cela pour pouvoir enregistrer les mensurations. tutti.editSpeciesFrequencies.error.notAvailableSamplingCode=Le code de prélèvement <strong>%s</strong> est déjà utilisé sur cette campagne; veuillez en choisir un autre. @@ -1904,9 +1901,15 @@ tutti.main.action.changeLocaleUK.tip=Passer en anglais tutti.main.action.configuration=Configuration tutti.main.action.configuration.mnemonic=C tutti.main.action.configuration.tip=Configurer l'application +tutti.main.action.connectCaliper=Connexion Pied à coulisse +tutti.main.action.connectCaliper.mnemonic=P +tutti.main.action.connectCaliper.tip=Se connecter à un pied à coulisse sur le port série défini dans la configuration tutti.main.action.connectIchtyometer=Connexion Ichtyomètre tutti.main.action.connectIchtyometer.mnemonic=y tutti.main.action.connectIchtyometer.tip=Se connecter à un ichtyomètre +tutti.main.action.disconnectCaliper=Déconnexion Pied à coulisse +tutti.main.action.disconnectCaliper.mnemonic=P +tutti.main.action.disconnectCaliper.tip=Se déconnecter du pied à coulisse tutti.main.action.disconnectIchtyometer=Déconnexion Ichtyomètre tutti.main.action.disconnectIchtyometer.mnemonic=y tutti.main.action.disconnectIchtyometer.tip=Se déconnecter de l'ichtyomètre -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 19615796d8980283f913f3bc8a6aa5569937da9e Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 21 10:27:04 2016 +0200 lecture des données reçues sur le pied à coulisse (refs #7459) --- tutti-caliper/pom.xml | 69 +---------- .../fr/ifremer/tutti/caliper/feed/Caliper.java | 135 --------------------- .../caliper/feed/CaliperConnectionException.java | 24 ++++ .../tutti/caliper/feed/CaliperFeedReader.java | 19 +-- .../record/CaliperFeedReaderMeasureRecord.java | 15 ++- .../record/CaliperFeedReaderRecordFactory.java | 8 +- 6 files changed, 53 insertions(+), 217 deletions(-) diff --git a/tutti-caliper/pom.xml b/tutti-caliper/pom.xml index 8c4fced..36a564f 100644 --- a/tutti-caliper/pom.xml +++ b/tutti-caliper/pom.xml @@ -75,6 +75,7 @@ <scope>test</scope> </dependency> + <!-- Serial port reading --> <dependency> <groupId>com.neuronrobotics</groupId> <artifactId>nrjavaserial</artifactId> @@ -84,72 +85,4 @@ </dependencies> - <profiles> - <profile> - <id>tools</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - - <properties> - <redmine.releaseFiles> - target/${project.build.finalName}-tools.zip - </redmine.releaseFiles> - </properties> - - <build> - <defaultGoal>package</defaultGoal> - - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <executions> - <execution> - <id>jar</id> - <goals> - <goal>assembly</goal> - </goals> - <phase>package</phase> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - - </configuration> - </execution> - <execution> - <id>zip</id> - <goals> - <goal>assembly</goal> - </goals> - <phase>package</phase> - <configuration> - <descriptor>src/main/assembly/tools.xml</descriptor> - </configuration> - </execution> - </executions> - <configuration> - <finalName>${project.build.finalName}-tools</finalName> - <appendAssemblyId>false</appendAssemblyId> - </configuration> - </plugin> - </plugins> - </build> - - - <dependencies> - - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>runtime</scope> - </dependency> - - </dependencies> - </profile> - </profiles> - </project> diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/Caliper.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/Caliper.java deleted file mode 100644 index b63acb5..0000000 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/Caliper.java +++ /dev/null @@ -1,135 +0,0 @@ -package fr.ifremer.tutti.caliper.feed; - -import gnu.io.CommPort; -import gnu.io.CommPortIdentifier; -import gnu.io.SerialPort; -import gnu.io.SerialPortEvent; -import gnu.io.SerialPortEventListener; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * @author Kevin Morin (Code Lutin) - * @since x.x - */ -public class Caliper { - public Caliper() - { - super(); - } - - void connect ( String portName ) throws Exception - { - CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); - if ( portIdentifier.isCurrentlyOwned() ) - { - System.out.println("Error: Port is currently in use"); - } - else - { - CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000); - - if ( commPort instanceof SerialPort ) - { - SerialPort serialPort = (SerialPort) commPort; - serialPort.setSerialPortParams(4800,SerialPort.DATABITS_7,SerialPort.STOPBITS_1,SerialPort.PARITY_EVEN); - - InputStream in = serialPort.getInputStream(); - OutputStream out = serialPort.getOutputStream(); - - (new Thread(new SerialWriter(out))).start(); - - serialPort.addEventListener(new SerialReader(in)); - serialPort.notifyOnDataAvailable(true); - - } - else - { - System.out.println("Error: Only serial ports are handled by this example."); - } - } - } - - /** - * Handles the input coming from the serial port. A new line character - * is treated as the end of a block in this example. - */ - public static class SerialReader implements SerialPortEventListener - { - private InputStream in; - private byte[] buffer = new byte[1024]; - - public SerialReader ( InputStream in ) - { - this.in = in; - } - - public void serialEvent(SerialPortEvent arg0) { - int data; - - try - { - int len = 0; - while ( ( data = in.read()) > -1 ) - { - if ( data == '\n' ) { - break; - } - buffer[len++] = (byte) data; - } - System.out.print(new String(buffer,0,len)); - } - catch ( IOException e ) - { - e.printStackTrace(); - System.exit(-1); - } - } - - } - - /** */ - public static class SerialWriter implements Runnable - { - OutputStream out; - - public SerialWriter ( OutputStream out ) - { - this.out = out; - } - - public void run () - { - try - { - int c = 0; - while ( ( c = System.in.read()) > -1 ) - { - this.out.write(c); - } - } - catch ( IOException e ) - { - e.printStackTrace(); - System.exit(-1); - } - } - } - - - - public static void main ( String[] args ) - { - try - { - (new Caliper()).connect("COM1"); - } - catch ( Exception e ) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperConnectionException.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperConnectionException.java index fb9a0f6..c188300 100644 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperConnectionException.java +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperConnectionException.java @@ -1,5 +1,29 @@ package fr.ifremer.tutti.caliper.feed; +/* + * #%L + * Tutti :: Caliper API + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2012 - 2016 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + /** * @author Kevin Morin (Code Lutin) * @since 4.5 diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java index 6dbec27..27b837b 100644 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/CaliperFeedReader.java @@ -22,7 +22,6 @@ package fr.ifremer.tutti.caliper.feed; * #L% */ -import com.google.common.base.Preconditions; import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderEvent; import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderListener; import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderMeasureRecord; @@ -35,7 +34,6 @@ import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -56,6 +54,13 @@ public class CaliperFeedReader implements Closeable { /** Logger. */ private static final Log log = LogFactory.getLog(CaliperFeedReader.class); + private static final String SERIAL_PORT_PREFIX = "COM"; + + /** + * Name of the serial port + */ + protected String serialPortName; + /** * Serial port open in the {@code start} method. */ @@ -78,12 +83,12 @@ public class CaliperFeedReader implements Closeable { recordFactory = new CaliperFeedReaderRecordFactory(); } - public void start(String portName) throws CaliperConnectionException { + public void start(int portNumber) throws CaliperConnectionException { - Preconditions.checkArgument(StringUtils.isNotEmpty(portName), "serial port can not be null or empty"); + this.serialPortName = SERIAL_PORT_PREFIX + portNumber; try { - CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); + CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(serialPortName); serialPort = portIdentifier.open(this.getClass().getName(), 2000); serialPort.setSerialPortParams(4800, SerialPort.DATABITS_7, SerialPort.STOPBITS_1, SerialPort.PARITY_EVEN); @@ -99,7 +104,7 @@ public class CaliperFeedReader implements Closeable { } catch (IOException | TooManyListenersException | PortInUseException | NoSuchPortException | UnsupportedCommOperationException e) { if (log.isErrorEnabled()) { - log.error("Error while connecting to the serial port " + portName, e); + log.error("Error while connecting to the serial port " + serialPortName, e); } throw new CaliperConnectionException(e); } @@ -131,7 +136,7 @@ public class CaliperFeedReader implements Closeable { } public String getSerialPortName() { - return serialPort != null ? serialPort.getName() : null; + return serialPortName; } /** diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java index 5fbb8dd..49a1f6e 100644 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderMeasureRecord.java @@ -25,7 +25,9 @@ package fr.ifremer.tutti.caliper.feed.record; */ import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.math.NumberUtils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * A measure record. @@ -39,9 +41,13 @@ public class CaliperFeedReaderMeasureRecord extends CaliperFeedReaderRecordSuppo private static final long serialVersionUID = 1L; + /** Received values are like +12,345\n */ + private static final Pattern RECORD_PATTERN = Pattern.compile("\\+(\\w+),\\w+\\s*"); + public static boolean acceptRecord(String record) { - return NumberUtils.isNumber(record); + Matcher matcher = RECORD_PATTERN.matcher(record); + return matcher.matches(); } @@ -49,7 +55,10 @@ public class CaliperFeedReaderMeasureRecord extends CaliperFeedReaderRecordSuppo CaliperFeedReaderMeasureRecord(String record) { super(record); - measure = Integer.valueOf(record); + Matcher matcher = RECORD_PATTERN.matcher(record); + matcher.find(); + String intPart = matcher.group(1); + measure = Integer.valueOf(intPart); } public int getMeasure() { diff --git a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java index a6fea28..a9c4c01 100644 --- a/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java +++ b/tutti-caliper/src/main/java/fr/ifremer/tutti/caliper/feed/record/CaliperFeedReaderRecordFactory.java @@ -33,11 +33,11 @@ import java.util.Set; */ public class CaliperFeedReaderRecordFactory { - protected final Set<CaliperFeedReaderRecordAceptor> acceptors; + protected final Set<CaliperFeedReaderRecordAcceptor> acceptors; public CaliperFeedReaderRecordFactory() { acceptors = new LinkedHashSet<>(); - acceptors.add(new CaliperFeedReaderRecordAceptor<CaliperFeedReaderMeasureRecord>() { + acceptors.add(new CaliperFeedReaderRecordAcceptor<CaliperFeedReaderMeasureRecord>() { @Override public boolean accept(String record) { return CaliperFeedReaderMeasureRecord.acceptRecord(record); @@ -55,7 +55,7 @@ public class CaliperFeedReaderRecordFactory { CaliperFeedReaderRecordSupport feedRecord = null; - for (CaliperFeedReaderRecordAceptor acceptor : acceptors) { + for (CaliperFeedReaderRecordAcceptor acceptor : acceptors) { boolean accept = acceptor.accept(record); if (accept) { @@ -71,7 +71,7 @@ public class CaliperFeedReaderRecordFactory { } - protected static interface CaliperFeedReaderRecordAceptor<F extends CaliperFeedReaderRecordSupport> { + protected interface CaliperFeedReaderRecordAcceptor<F extends CaliperFeedReaderRecordSupport> { boolean accept(String record); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 6607ccdc4b4b3495418136a7e828759244301b3a Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 21 10:28:40 2016 +0200 modif de la conif de port série : nombre au lieu de faire une liste des ports dispo (refs #7459) --- .../src/main/java/fr/ifremer/tutti/TuttiConfiguration.java | 5 ++--- .../main/java/fr/ifremer/tutti/TuttiConfigurationOption.java | 5 ++--- .../src/main/java/fr/ifremer/tutti/util/SerialPort.java | 12 ------------ .../main/resources/i18n/tutti-persistence_en_GB.properties | 1 + 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java index 613b18c..ab5397e 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java @@ -29,7 +29,6 @@ import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.type.CoordinateEditorType; import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.util.BeepFrequency; -import fr.ifremer.tutti.util.SerialPort; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.logging.Log; @@ -733,8 +732,8 @@ public class TuttiConfiguration extends ApplicationConfiguration { return applicationConfig.getOptionAsInt(TuttiConfigurationOption.ICHTYOMETER_MAXIMUM_NUMBER_OF_ATTEMPT_TO_CONNECT.getKey()); } - public SerialPort getCaliperSerialPort() { - return SerialPort.valueOf(applicationConfig.getOption(TuttiConfigurationOption.CALIPER_SERIAL_PORT.getKey())); + public int getCaliperSerialPort() { + return applicationConfig.getOptionAsInt(TuttiConfigurationOption.CALIPER_SERIAL_PORT.getKey()); } public Boolean isExternalDevicesVoiceEnabled() { diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java index 97c0413..2177eb6 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java @@ -26,7 +26,6 @@ import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.type.CoordinateEditorType; import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.util.BeepFrequency; -import fr.ifremer.tutti.util.SerialPort; import org.hibernate.dialect.HSQLDialect; import org.hsqldb.jdbcDriver; import org.nuiton.config.ConfigOptionDef; @@ -650,8 +649,8 @@ public enum TuttiConfigurationOption implements ConfigOptionDef { CALIPER_SERIAL_PORT( "tutti.ichtyometer.caliperSerialPort", n("tutti.config.option.caliper.serialPort.description"), - "COM1", - SerialPort.class, + "1", + int.class, false ), EXTERNAL_DEVICES_VOICE_ENABLED( diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/util/SerialPort.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/util/SerialPort.java deleted file mode 100644 index 6cd4ba7..0000000 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/util/SerialPort.java +++ /dev/null @@ -1,12 +0,0 @@ -package fr.ifremer.tutti.util; - -/** - * @author Kevin Morin (Code Lutin) - * @since 4.5 - */ -public enum SerialPort { - - COM1, - COM2, - COM3 -} diff --git a/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties b/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties index e9fd0bc..7dd397c 100644 --- a/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties +++ b/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties @@ -10,6 +10,7 @@ tutti.caracteristicType.vesselUseFeature= tutti.config= tutti.config.option.basedir.description= tutti.config.option.beepFrequency.description= +tutti.config.option.caliper.serialPort.description= tutti.config.option.cruiseId.description= tutti.config.option.csv.separator.description= tutti.config.option.data.directory.description= -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 6500c3c4165e40ecc0efd10149dad6943392ce7f Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 21 10:30:12 2016 +0200 affichage du port série écouté dans la barre de statut (refs #7459) --- .../src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss | 3 ++- .../ifremer/tutti/ui/swing/content/actions/ConnectCaliperAction.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss index ce1cee1..0041ff7 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss @@ -340,7 +340,8 @@ JMenu { actionIcon: "bluetooth-up"; disabledIcon: {jaxx.runtime.SwingUtil.createActionIcon("bluetooth-down")}; enabled: {model.isCaliperConnected()}; - toolTipText: {handler.getCaliperStatusLabel(model.isCaliperConnected())}; + toolTipText: {handler.getCaliperStatusTip(model.isCaliperConnected())}; + text: {handler.getCaliperStatusLabel(model.isCaliperConnected())}; _help: {"tutti.main.status.caliper.help"}; } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/ConnectCaliperAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/ConnectCaliperAction.java index ddd0584..e0ea92c 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/ConnectCaliperAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/actions/ConnectCaliperAction.java @@ -45,7 +45,7 @@ public class ConnectCaliperAction extends AbstractMainUITuttiAction { public void doAction() throws Exception { CaliperFeedReader caliperReader = new CaliperFeedReader(); - caliperReader.start(getConfig().getCaliperSerialPort().name()); + caliperReader.start(getConfig().getCaliperSerialPort()); getContext().setCaliperReader(caliperReader); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit b8e1fa0dac2f5269b71a39c181ca9a64dd05556c Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 21 11:49:44 2016 +0200 modif de l'icone du pied à coulisse (fixes #7459) --- .../java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss | 8 ++++---- .../src/main/resources/icons/action-caliper-down.png | Bin 0 -> 426 bytes .../src/main/resources/icons/action-caliper-up.png | Bin 0 -> 436 bytes 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss index 0041ff7..ffad3e0 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jcss @@ -111,7 +111,7 @@ JMenu { #menuFileConnectCaliper { - actionIcon: bluetooth-down; + actionIcon: caliper-down; text: "tutti.main.action.connectCaliper"; toolTipText: "tutti.main.action.connectCaliper.tip"; i18nMnemonic: "tutti.main.action.connectCaliper.mnemonic"; @@ -121,7 +121,7 @@ JMenu { } #menuFileDisconnectCaliper { - actionIcon: bluetooth-up; + actionIcon: caliper-up; text: "tutti.main.action.disconnectCaliper"; toolTipText: "tutti.main.action.disconnectCaliper.tip"; i18nMnemonic: "tutti.main.action.disconnectCaliper.mnemonic"; @@ -337,8 +337,8 @@ JMenu { } #caliperStatus { - actionIcon: "bluetooth-up"; - disabledIcon: {jaxx.runtime.SwingUtil.createActionIcon("bluetooth-down")}; + actionIcon: "caliper-up"; + disabledIcon: {jaxx.runtime.SwingUtil.createActionIcon("caliper-down")}; enabled: {model.isCaliperConnected()}; toolTipText: {handler.getCaliperStatusTip(model.isCaliperConnected())}; text: {handler.getCaliperStatusLabel(model.isCaliperConnected())}; diff --git a/tutti-ui-swing/src/main/resources/icons/action-caliper-down.png b/tutti-ui-swing/src/main/resources/icons/action-caliper-down.png new file mode 100644 index 0000000..dad4fdf Binary files /dev/null and b/tutti-ui-swing/src/main/resources/icons/action-caliper-down.png differ diff --git a/tutti-ui-swing/src/main/resources/icons/action-caliper-up.png b/tutti-ui-swing/src/main/resources/icons/action-caliper-up.png new file mode 100644 index 0000000..2746335 Binary files /dev/null and b/tutti-ui-swing/src/main/resources/icons/action-caliper-up.png differ -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 151e00570056132eb6eff7cc0f6a047a47031fa6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Apr 22 13:35:18 2016 +0200 Fix import from merge --- .../operation/catches/species/frequency/SpeciesFrequencyUIHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java index 2558ac3..7914bae 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java @@ -22,6 +22,9 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; * #L% */ +import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderEvent; +import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderListener; +import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderMeasureRecord; import fr.ifremer.tutti.ichtyometer.feed.event.IchtyometerFeedReaderEvent; import fr.ifremer.tutti.ichtyometer.feed.event.IchtyometerFeedReaderListener; import fr.ifremer.tutti.ichtyometer.feed.record.IchtyometerFeedReaderMeasureRecord; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7459 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 593e87e06c560e2a7b3ee47ac9d44716e65aaca5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Apr 22 13:35:31 2016 +0200 Meilleur gestion des dépendences --- pom.xml | 7 +++++++ tutti-caliper/pom.xml | 14 ++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 4e738ac..b68d3ea 100644 --- a/pom.xml +++ b/pom.xml @@ -529,6 +529,13 @@ <scope>runtime</scope> </dependency> + <!-- Serial port reading --> + <dependency> + <groupId>com.neuronrobotics</groupId> + <artifactId>nrjavaserial</artifactId> + <version>3.7.5.1</version> + </dependency> + <!-- JFreeChart --> <dependency> <groupId>org.jfree</groupId> diff --git a/tutti-caliper/pom.xml b/tutti-caliper/pom.xml index 36a564f..828c127 100644 --- a/tutti-caliper/pom.xml +++ b/tutti-caliper/pom.xml @@ -57,6 +57,12 @@ <artifactId>guava</artifactId> </dependency> + <!-- Serial port reading --> + <dependency> + <groupId>com.neuronrobotics</groupId> + <artifactId>nrjavaserial</artifactId> + </dependency> + <!-- Logging --> <dependency> <groupId>org.slf4j</groupId> @@ -75,14 +81,6 @@ <scope>test</scope> </dependency> - <!-- Serial port reading --> - <dependency> - <groupId>com.neuronrobotics</groupId> - <artifactId>nrjavaserial</artifactId> - <version>3.7.5.1</version> - </dependency> - - </dependencies> </project> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm