From: Daniel Kirschten Date: Mon, 20 May 2019 17:28:26 +0000 (+0200) Subject: Merged logic into master X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=e7180dd9040734555e6a07f2561fb688118b7002;hp=70afb26181aba8de30ea6f796ea5c2a573d9ecab;p=Mograsim.git Merged logic into master --- diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..a128354d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,8 @@ +[submodule "logicui"] + path = logicui + url =
+ branch = logicui +[submodule "SampleERCP"] + path = SampleERCP + url =
+ branch = SampleERCP diff --git a/README.md b/README.md new file mode 100644 index 00000000..e69de29b diff --git a/REQUIREMENTS.MD b/REQUIREMENTS.MD new file mode 100644 index 00000000..3a7a8d77 --- /dev/null +++ b/REQUIREMENTS.MD @@ -0,0 +1,165 @@ +# Rechnerarchitektur GP 2019 +#### Modularer Grafischer Schaltkreis Simulator (für die MI-Maschine) + +*Ihr könnt hier gerne nach belieben Dinge ändern, haltet euch nicht zurück^^* + +## Anforderungen + +### Pflichtfeatures +1. Emulation der MI-Maschine (siehe Am2900ME) +2. Visualisierung der MI-Maschine sehr ähnlich dem Bild der VL +3. sehr gute Website, Dokumentation, Hilfe aus dem Kontextmenü heraus +4. Hilfreiche Fehlermeldungen, Warnungen bei gefährlichen Operationen + für uns/Entwickler: gutes Loggen, Absturzberichte +5. Immer hilfreiche Tooltips zu fast allem. + + +### Sollte möglich sein +1. Export der Ansicht +2. Sicht des Assemblerprogrammierers, spezifizieren einer ISA und Nutzung +3. Farben, Schriftgröße & Co. einstellbar (für Präsentation, Hell/Dunkel, Farbenblind/…) +4. Entwurf eines Schaltkreises mit einem Editor +5. Sprache ändern (für nicht Muttersprachler, internat. Potenzial, Erweiterungsmögl.) +6. Sehr einfache Installation (Eclipse Marketplace) +7. Editor sollte tooltip Einstellung erlauben +8. Rückgängig + + +### Wunschfeatures +1. Debuggen im Sinne von Breakpoints & Co. +2. interaktives Tutorial in der GUI +3. Zurückspulen der Simulation / Zeitleiste +4. Wiederherstellungspunkt (Status) + +### Weiterführende Ideen +1. x86 Modell +2. ARM Modell +3. Signalgraphen + +### Use Cases +
Alle Use Cases anzeigen

+ +#### 01. Installation +Das Programm lässt sich entweder über den Eclipse Marketplace einfach installieren (oder als Eclipse Projekt) oder als eigenes Eclipse RPC Projekt direkt herunterladen (ggf. entpacken) und starten.[A] Das Programm / Plugin lässt sich auf Windows (7+), MacOS und Linux ausführen; alle verbreitete Hardware nach 2010 mit 64 Bit OS sollte funktionieren.[B] Es muss auf den Rechnern in den TUM Rechnerhallen funktionieren.[C] + +#### 02. Deinstallation +Das Programm muss sich ohne nennenswerten Aufwand oder Kentnisse vom Benutzer rückstandslos entfernen lassen.[A] + +#### 03. Programmstart +Das Programm bzw. Plugin startet schnell (unter 10 sec.; besser unter 5 sec).[A] Bei dem ersten Programmstart ist ein Willkommensfenster zu sehen, das auf erklärende Resourcen verweist, den Nutzer grüßt und ggf. auf die (Sprach-)Einstellungen hinweist.[B] Es wird bestenfalls auf ein Beispielprojekt verwiesen (kann erstellt werden?) um dem Nutzer zu ermöglichen, sich damit vertraut zu machen.[C] Ein schnell Link zum Erstellen eines neuen Projekts/Simulation/... wird angezeigt.[D] + +#### 04. Programmende +Sollten bei Beenden des Programms oder Programmabsturz nicht persistierte Daten vorliegen, muss dafür gesorgt werden, dass diese nicht verloren gehen.[A] Enweder durch einen Dialog[B], oder durch erzeugte Recovery-Dateien[C]. Bei Absturz des Programms wird eine passende und aufschlussreiche Fehlermeldung angezeigt, bestenfalls mit Link zu einer Report-Möglichkeit.[D] + +#### 05. Einstellungen +Die Hauptextfarbe und Schriftgröße muss einstellbar sein[A], besser noch Hintergrund- und Markierungsfarben und Schriftstil.[B] Die Einstellung der Sprache muss möglich sein.[C] + +#### 06. Einstieg +Das Einstiegsprojekt zeigt zu Beginn die passende Ansicht an, die Mikroprogrammierung ist wie bei dem Am2900ME ungehindert möglich.[A] Bestenfalls ist dieses beim (erstmaligen) Start direkt geöffnet.[B] Wichtige Fenster (v.a. die grafische Darstellung) sind direkt sichtbar, oder zumindest in einem Tab geöffnet (müssen nicht gesucht werden).[C] + +#### 07. Nutzung der Visualisierung +Die Visualisierung soll möglichst der Vorlesung entsprechen.[A] Sie lässt sich transformieren (z.B. Zoom mit dem Mausrad, Verschieben mit Mausklick oder Mausklick und Alt) und wieder zurücksetzen.[B] + +#### 08. Hilfestellung +Mit dem Produkt wird eine offline-Dokumentation mitgeliefert. (bestenfalls DE und EN)[A] Mit Rechtsklick lässt sich über ein Kontextmenü der Teil der Dokumentation öffnen, der das angeklickte und seine Funktion beschreibt (Vorbild Cinema4D). Dies sollte mit fast allem möglich sein.[B] Bleibt man mit der Maus länger über einem GUI-Bestandteil, wird eine kurze Beschreibung/Hilfe dazu angezeigt (Tooltip).[C] + +#### 09. Dateihandhabung +Die Dateien sollten möglichst menschenlesbar sein, z.B. in CSV-Format, um Kommunikation mit anderer Software und Änderungen durch den Nutzer zu ermöglichen.[A] Die Dateien enthalten eine Versionsnummer, um Abwärtskompatibilität und hilfreiche Fehlermeldungen zu ermöglichen.[B] + +#### 10. Entwicklerunterstützung +Das Projekt soll sich einfach bauen/kompilieren/exportieren lassen, es muss beschrieben werden wie das möglich ist.[A] Die Verbreitung zur Anwendung soll ebenfalls unproblematisch sein.[B] + +#### Fügt hier eure eigenen dazu, fortlaufend nummeriert und ggf. mit [A,B,C,..] genauer spezifiziert. + +

+ +### UML und Ähnliches +#### Grobe Struktur +![image](https://user-images.githubusercontent.com/11130248/57186855-aae24600-6ee6-11e9-88b4-371622d43adc.png) + +## Technologie-Stack +* Git (anscheinend über Gitlab) +* Eclipse RCP + - (noch zu testen) +* Java + - Version 8? + - Version 10? + - Version 12? +* Bibliotheken + - JUnit 5.4.x ? AssertJ? [http://joel-costigliola.github.io/assertj/index.html](http://joel-costigliola.github.io/assertj/index.html) + - (Apache Commons?) + Sehr weit verbreitete und gut designte & getestete Lib; + aber zusätzliche Dep. + - Sonstiges? Logging? Log4j +- Automatischer Build mit Maven? Wohl eher nicht, wegen ERPC Build + +## Meilensteine + +## Außenwirkung +### Name, Abkürzung +### Signet, Logo +### Beschreibung + +## Sonstiges +### Nützliche Links +- [https://wiki.eclipse.org/Rich_Client_Platform](https://wiki.eclipse.org/Rich_Client_Platform) -Links +- [https://wiki.eclipse.org/User_Interface_Guidelines](https://wiki.eclipse.org/User_Interface_Guidelines) - etwas alt, aber nützlich +- [https://download.eclipse.org/eclipse/downloads/](https://download.eclipse.org/eclipse/downloads/) - Eclipse Project +- [https://www.vogella.com/tutorials/EclipseRCP/article.html](https://www.vogella.com/tutorials/EclipseRCP/article.html) - **Eclipse RPC Tutorial** +- [https://github.com/eclipse/gef/wiki](https://github.com/eclipse/gef/wiki) - **Wiki für das Grafikframework** +- [https://github.com/eclipse/MaisiKoleni/Am2900ME](https://github.com/eclipse/MaisiKoleni/Am2900ME) - der geistige Vorgänger +- [https://github.com/Haspamelodica/Am2900ME_swt](https://github.com/Haspamelodica/Am2900ME_swt) - ... auch mit SWT + +### Rechtliches +
+MIT Lizenz? - https://choosealicense.com/licenses/mit/ + +

+ +>MIT License +> +>Copyright (c) 2019 Christian Femers, Daniel Kirschten and Fabian Stemmler +> +> +> +>Permission is hereby granted, free of charge, to any person obtaining a copy +>of this software and associated documentation files (the "Software"), to deal +>in the Software without restriction, including without limitation the rights +>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +>copies of the Software, and to permit persons to whom the Software is +>furnished to do so, subject to the following conditions: +> +>The above copyright notice and this permission notice shall be included in all +>copies or substantial portions of the Software. +> +>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +>SOFTWARE. + +

+ +Muss ggf. Eclipse Public License verwendet werden wegen Copyleft? +
+Eclipse Public License 2.0? - https://www.eclipse.org/legal/epl-2.0/ + +

+ +>Copyright (c) 2019 Christian Femers, Daniel Kirschten and Fabian Stemmler +> +>This program and the accompanying materials are made +>available under the terms of the Eclipse Public License 2.0 +>which is available at https://www.eclipse.org/legal/epl-2.0/ +> +>This Source Code may also be made available under the following Secondary +>Licenses when the conditions for such availability set forth in the Eclipse +>Public License, v. 2.0 are satisfied: GNU General Public License, version 2 +>with the GNU Classpath Exception which is +>available at https://www.gnu.org/software/classpath/license.html. +> +>SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +

diff --git a/SampleERCP b/SampleERCP new file mode 160000 index 00000000..10e87495 --- /dev/null +++ b/SampleERCP @@ -0,0 +1 @@ +Subproject commit 10e87495184e49c5cab906921f0afaf2473d9aed diff --git a/era.mi/.classpath b/era.mi/.classpath index d286d860..be855233 100644 --- a/era.mi/.classpath +++ b/era.mi/.classpath @@ -1,13 +1,13 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/era.mi/.project b/era.mi/.project deleted file mode 100644 index 9a89f37b..00000000 --- a/era.mi/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - era.mi - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/era.mi/.settings/org.eclipse.jdt.core.prefs b/era.mi/.settings/org.eclipse.jdt.core.prefs index 0fc9edde..82c6671b 100644 --- a/era.mi/.settings/org.eclipse.jdt.core.prefs +++ b/era.mi/.settings/org.eclipse.jdt.core.prefs @@ -1,367 +1,367 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=10 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=10 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=10 -org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false -org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false -org.eclipse.jdt.core.formatter.align_with_spaces=false -org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 -org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 -org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 -org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=next_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line -org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true -org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false -org.eclipse.jdt.core.formatter.comment.indent_root_tags=false -org.eclipse.jdt.core.formatter.comment.indent_tag_description=false -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=140 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false -org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.lineSplit=140 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_on_off_tags=true -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true -org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true -org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true -org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true -org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true -org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true -org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=10 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=10 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=10 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=140 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.lineSplit=140 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/era.mi/src/era/mi/logic/Simulation.java b/era.mi/src/era/mi/logic/Simulation.java index ca2c9e92..0468ec1e 100644 --- a/era.mi/src/era/mi/logic/Simulation.java +++ b/era.mi/src/era/mi/logic/Simulation.java @@ -1,9 +1,9 @@ -package era.mi.logic; - -import era.mi.logic.timeline.Timeline; - -public class Simulation -{ - public final static Timeline TIMELINE = new Timeline(11); - +package era.mi.logic; + +import era.mi.logic.timeline.Timeline; + +public class Simulation +{ + public final static Timeline TIMELINE = new Timeline(11); + } \ No newline at end of file diff --git a/era.mi/src/era/mi/logic/Util.java b/era.mi/src/era/mi/logic/Util.java index 05671387..d621a44c 100644 --- a/era.mi/src/era/mi/logic/Util.java +++ b/era.mi/src/era/mi/logic/Util.java @@ -1,110 +1,110 @@ -package era.mi.logic; - -import java.util.Arrays; - -import era.mi.logic.types.Bit; - -public final class Util -{ - - @SuppressWarnings("unchecked") - public static T[] concat(T[]... arrays) - { - if (arrays.length == 0) - throw new IllegalArgumentException("Cannot concatenate 0 arrays."); - - int length = 0; - for (T[] array : arrays) - length += array.length; - - T[] newArray = Arrays.copyOf(arrays[0], length); - int appendIndex = arrays[0].length; - for (int i = 1; i < arrays.length; i++) - { - System.arraycopy(arrays[i], 0, newArray, appendIndex, arrays[i].length); - appendIndex += arrays[i].length; - } - - return newArray; - } - -// @SuppressWarnings("unchecked") -// public static T[][] split(T[] array, int... lengths) -// { -// //TODO: implement array split again; This version contains an illegal cast -// int totalLength = 0; -// for(int length : lengths) -// totalLength += length; -// -// if(totalLength != array.length) -// throw new IllegalArgumentException(); //TODO: add proper error message -// -// Object[][] newArray = new Object[lengths.length][]; -// int splitIndex = 0; -// for(int i = 0; i < lengths.length; i++) -// { -// System.arraycopy(array, splitIndex, newArray, 0, lengths[i]); -// splitIndex += lengths[i]; -// } -// -// return (T[][]) newArray; -// } - - public static Bit[] and(Bit[] a, Bit[] b) - { - return binBitOp(a, b, Bit::and); - } - - public static Bit[] or(Bit[] a, Bit[] b) - { - return binBitOp(a, b, Bit::or); - } - - public static Bit[] xor(Bit[] a, Bit[] b) - { - return binBitOp(a, b, Bit::xor); - } - - private static Bit[] binBitOp(Bit[] a, Bit[] b, BitOp op) - { - if (a.length != b.length) - throw new IllegalArgumentException("Bit Arrays were not of equal length."); - Bit[] out = new Bit[a.length]; - for (int i = 0; i < a.length; i++) - { - out[i] = op.execute(a[i], b[i]); - } - return out; - } - - public static Bit[] not(Bit[] a) - { - Bit[] out = new Bit[a.length]; - for (int i = 0; i < a.length; i++) - { - out[i] = a[i].not(); - } - return out; - } - - /** - * uses the {@link Bit#combineWith(Bit)} method, does not create a new array, the result is stored in the first array. - * - * @author Christian Femers - */ - public static Bit[] combineInto(Bit[] dest, Bit[] addition) - { - if (dest.length != addition.length) - throw new IllegalArgumentException("Bit Arrays were not of equal length."); - for (int i = 0; i < addition.length; i++) - { - dest[i] = dest[i].join(addition[i]); - } - return dest; - } - - interface BitOp - { - Bit execute(Bit a, Bit b); - } -} +package era.mi.logic; + +import java.util.Arrays; + +import era.mi.logic.types.Bit; + +public final class Util +{ + + @SuppressWarnings("unchecked") + public static T[] concat(T[]... arrays) + { + if (arrays.length == 0) + throw new IllegalArgumentException("Cannot concatenate 0 arrays."); + + int length = 0; + for (T[] array : arrays) + length += array.length; + + T[] newArray = Arrays.copyOf(arrays[0], length); + int appendIndex = arrays[0].length; + for (int i = 1; i < arrays.length; i++) + { + System.arraycopy(arrays[i], 0, newArray, appendIndex, arrays[i].length); + appendIndex += arrays[i].length; + } + + return newArray; + } + +// @SuppressWarnings("unchecked") +// public static T[][] split(T[] array, int... lengths) +// { +// //TODO: implement array split again; This version contains an illegal cast +// int totalLength = 0; +// for(int length : lengths) +// totalLength += length; +// +// if(totalLength != array.length) +// throw new IllegalArgumentException(); //TODO: add proper error message +// +// Object[][] newArray = new Object[lengths.length][]; +// int splitIndex = 0; +// for(int i = 0; i < lengths.length; i++) +// { +// System.arraycopy(array, splitIndex, newArray, 0, lengths[i]); +// splitIndex += lengths[i]; +// } +// +// return (T[][]) newArray; +// } + + public static Bit[] and(Bit[] a, Bit[] b) + { + return binBitOp(a, b, Bit::and); + } + + public static Bit[] or(Bit[] a, Bit[] b) + { + return binBitOp(a, b, Bit::or); + } + + public static Bit[] xor(Bit[] a, Bit[] b) + { + return binBitOp(a, b, Bit::xor); + } + + private static Bit[] binBitOp(Bit[] a, Bit[] b, BitOp op) + { + if (a.length != b.length) + throw new IllegalArgumentException("Bit Arrays were not of equal length."); + Bit[] out = new Bit[a.length]; + for (int i = 0; i < a.length; i++) + { + out[i] = op.execute(a[i], b[i]); + } + return out; + } + + public static Bit[] not(Bit[] a) + { + Bit[] out = new Bit[a.length]; + for (int i = 0; i < a.length; i++) + { + out[i] = a[i].not(); + } + return out; + } + + /** + * uses the {@link Bit#combineWith(Bit)} method, does not create a new array, the result is stored in the first array. + * + * @author Christian Femers + */ + public static Bit[] combineInto(Bit[] dest, Bit[] addition) + { + if (dest.length != addition.length) + throw new IllegalArgumentException("Bit Arrays were not of equal length."); + for (int i = 0; i < addition.length; i++) + { + dest[i] = dest[i].join(addition[i]); + } + return dest; + } + + interface BitOp + { + Bit execute(Bit a, Bit b); + } +} diff --git a/era.mi/src/era/mi/logic/components/BasicComponent.java b/era.mi/src/era/mi/logic/components/BasicComponent.java index 61935d15..e6952838 100644 --- a/era.mi/src/era/mi/logic/components/BasicComponent.java +++ b/era.mi/src/era/mi/logic/components/BasicComponent.java @@ -1,35 +1,35 @@ -package era.mi.logic.components; - -import era.mi.logic.Simulation; -import era.mi.logic.types.BitVector; -import era.mi.logic.wires.Wire; -import era.mi.logic.wires.WireObserver; - -/** - * A basic component that recomputes all outputs (with a delay), when it is updated. - * - * @author Fabian Stemmler - */ -public abstract class BasicComponent implements WireObserver, Component -{ - private int processTime; - - /** - * - * @param processTime Amount of time this component takes to update its outputs. Must be more than 0, otherwise 1 is assumed. - * - * @author Fabian Stemmler - */ - public BasicComponent(int processTime) - { - this.processTime = processTime > 0 ? processTime : 1; - } - - @Override - public void update(Wire initiator, BitVector oldValues) - { - Simulation.TIMELINE.addEvent(e -> compute(), processTime); - } - - protected abstract void compute(); -} +package era.mi.logic.components; + +import era.mi.logic.Simulation; +import era.mi.logic.types.BitVector; +import era.mi.logic.wires.Wire; +import era.mi.logic.wires.WireObserver; + +/** + * A basic component that recomputes all outputs (with a delay), when it is updated. + * + * @author Fabian Stemmler + */ +public abstract class BasicComponent implements WireObserver, Component +{ + private int processTime; + + /** + * + * @param processTime Amount of time this component takes to update its outputs. Must be more than 0, otherwise 1 is assumed. + * + * @author Fabian Stemmler + */ + public BasicComponent(int processTime) + { + this.processTime = processTime > 0 ? processTime : 1; + } + + @Override + public void update(Wire initiator, BitVector oldValues) + { + Simulation.TIMELINE.addEvent(e -> compute(), processTime); + } + + protected abstract void compute(); +} diff --git a/era.mi/src/era/mi/logic/components/BitDisplay.java b/era.mi/src/era/mi/logic/components/BitDisplay.java index f11fdf86..971eb7a7 100644 --- a/era.mi/src/era/mi/logic/components/BitDisplay.java +++ b/era.mi/src/era/mi/logic/components/BitDisplay.java @@ -1,49 +1,49 @@ -package era.mi.logic.components; - -import java.util.List; - -import era.mi.logic.types.Bit; -import era.mi.logic.types.BitVector; -import era.mi.logic.wires.Wire.WireEnd; - -public class BitDisplay extends BasicComponent -{ - private final WireEnd in; - private BitVector displayedValue; - - public BitDisplay(WireEnd in) - { - super(1); - this.in = in; - in.addObserver(this); - compute(); - } - - @Override - protected void compute() - { - displayedValue = in.getValues(); - } - - public BitVector getDisplayedValue() - { - return displayedValue; - } - - public boolean isDisplaying(Bit... values) - { - return displayedValue.equals(BitVector.of(values)); - } - - @Override - public List getAllInputs() - { - return List.of(in); - } - - @Override - public List getAllOutputs() - { - return List.of(); - } -} +package era.mi.logic.components; + +import java.util.List; + +import era.mi.logic.types.Bit; +import era.mi.logic.types.BitVector; +import era.mi.logic.wires.Wire.WireEnd; + +public class BitDisplay extends BasicComponent +{ + private final WireEnd in; + private BitVector displayedValue; + + public BitDisplay(WireEnd in) + { + super(1); + this.in = in; + in.addObserver(this); + compute(); + } + + @Override + protected void compute() + { + displayedValue = in.getValues(); + } + + public BitVector getDisplayedValue() + { + return displayedValue; + } + + public boolean isDisplaying(Bit... values) + { + return displayedValue.equals(BitVector.of(values)); + } + + @Override + public List getAllInputs() + { + return List.of(in); + } + + @Override + public List getAllOutputs() + { + return List.of(); + } +} diff --git a/era.mi/src/era/mi/logic/components/Clock.java b/era.mi/src/era/mi/logic/components/Clock.java index a31f20c8..07419b46 100644 --- a/era.mi/src/era/mi/logic/components/Clock.java +++ b/era.mi/src/era/mi/logic/components/Clock.java @@ -1,59 +1,59 @@ -package era.mi.logic.components; - -import java.util.List; - -import era.mi.logic.Simulation; -import era.mi.logic.timeline.TimelineEvent; -import era.mi.logic.timeline.TimelineEventHandler; -import era.mi.logic.types.Bit; -import era.mi.logic.wires.Wire; -import era.mi.logic.wires.Wire.WireEnd; - -public class Clock implements TimelineEventHandler, Component -{ - private boolean toggle = false; - private WireEnd out; - private int delta; - - /** - * - * @param out {@link Wire} the clock's impulses are fed into - * @param delta ticks between rising and falling edge - */ - public Clock(WireEnd out, int delta) - { - this.delta = delta; - this.out = out; - addToTimeline(); - } - - @Override - public void handle(TimelineEvent e) - { - addToTimeline(); - out.feedSignals(toggle ? Bit.ONE : Bit.ZERO); - toggle = !toggle; - } - - public WireEnd getOut() - { - return out; - } - - private void addToTimeline() - { - Simulation.TIMELINE.addEvent(this, delta); - } - - @Override - public List getAllInputs() - { - return List.of(); - } - - @Override - public List getAllOutputs() - { - return List.of(out); - } -} +package era.mi.logic.components; + +import java.util.List; + +import era.mi.logic.Simulation; +import era.mi.logic.timeline.TimelineEvent; +import era.mi.logic.timeline.TimelineEventHandler; +import era.mi.logic.types.Bit; +import era.mi.logic.wires.Wire; +import era.mi.logic.wires.Wire.WireEnd; + +public class Clock implements TimelineEventHandler, Component +{ + private boolean toggle = false; + private WireEnd out; + private int delta; + + /** + * + * @param out {@link Wire} the clock's impulses are fed into + * @param delta ticks between rising and falling edge + */ + public Clock(WireEnd out, int delta) + { + this.delta = delta; + this.out = out; + addToTimeline(); + } + + @Override + public void handle(TimelineEvent e) + { + addToTimeline(); + out.feedSignals(toggle ? Bit.ONE : Bit.ZERO); + toggle = !toggle; + } + + public WireEnd getOut() + { + return out; + } + + private void addToTimeline() + { + Simulation.TIMELINE.addEvent(this, delta); + } + + @Override + public List getAllInputs() + { + return List.of(); + } + + @Override + public List getAllOutputs() + { + return List.of(out); + } +} diff --git a/era.mi/src/era/mi/logic/components/Merger.java b/era.mi/src/era/mi/logic/components/Merger.java index 32321597..34ba217c 100644 --- a/era.mi/src/era/mi/logic/components/Merger.java +++ b/era.mi/src/era/mi/logic/components/Merger.java @@ -1,82 +1,82 @@ -package era.mi.logic.components; - -import java.util.List; - -import era.mi.logic.types.BitVector; -import era.mi.logic.wires.Wire; -import era.mi.logic.wires.Wire.WireEnd; -import era.mi.logic.wires.WireObserver; - -public class Merger implements WireObserver, Component -{ - private WireEnd out; - private WireEnd[] inputs; - private int[] beginningIndex; - - /** - * - * @param union The output of merging n {@link Wire}s into one. Must have length = a1.length() + a2.length() + ... + an.length(). - * @param inputs The inputs to be merged into the union - */ - public Merger(WireEnd union, WireEnd... inputs) - { - this.inputs = inputs; - this.out = union; - this.beginningIndex = new int[inputs.length]; - - int length = 0; - for (int i = 0; i < inputs.length; i++) - { - beginningIndex[i] = length; - length += inputs[i].length(); - inputs[i].addObserver(this); - } - - if (length != union.length()) - throw new IllegalArgumentException( - "The output of merging n WireArrays into one must have length = a1.length() + a2.length() + ... + an.length()."); - } - - public WireEnd getInput(int index) - { - return inputs[index]; - } - - public WireEnd getUnion() - { - return out; - } - - @Override - public void update(Wire initiator, BitVector oldValues) - { - int index = find(initiator); - int beginning = beginningIndex[index]; - out.feedSignals(beginning, inputs[index].getValues()); - } - - private int find(Wire w) - { - for (int i = 0; i < inputs.length; i++) - if (inputs[i].getWire() == w) - return i; - return -1; - } - - public WireEnd[] getInputs() - { - return inputs.clone(); - } - - @Override - public List getAllInputs() - { - return List.of(inputs); - } - - @Override - public List getAllOutputs() - { - return List.of(out); - } -} +package era.mi.logic.components; + +import java.util.List; + +import era.mi.logic.types.BitVector; +import era.mi.logic.wires.Wire; +import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.WireObserver; + +public class Merger implements WireObserver, Component +{ + private WireEnd out; + private WireEnd[] inputs; + private int[] beginningIndex; + + /** + * + * @param union The output of merging n {@link Wire}s into one. Must have length = a1.length() + a2.length() + ... + an.length(). + * @param inputs The inputs to be merged into the union + */ + public Merger(WireEnd union, WireEnd... inputs) + { + this.inputs = inputs; + this.out = union; + this.beginningIndex = new int[inputs.length]; + + int length = 0; + for (int i = 0; i < inputs.length; i++) + { + beginningIndex[i] = length; + length += inputs[i].length(); + inputs[i].addObserver(this); + } + + if (length != union.length()) + throw new IllegalArgumentException( + "The output of merging n WireArrays into one must have length = a1.length() + a2.length() + ... + an.length()."); + } + + public WireEnd getInput(int index) + { + return inputs[index]; + } + + public WireEnd getUnion() + { + return out; + } + + @Override + public void update(Wire initiator, BitVector oldValues) + { + int index = find(initiator); + int beginning = beginningIndex[index]; + out.feedSignals(beginning, inputs[index].getValues()); + } + + private int find(Wire w) + { + for (int i = 0; i < inputs.length; i++) + if (inputs[i].getWire() == w) + return i; + return -1; + } + + public WireEnd[] getInputs() + { + return inputs.clone(); + } + + @Override + public List getAllInputs() + { + return List.of(inputs); + } + + @Override + public List getAllOutputs() + { + return List.of(out); + } +} diff --git a/era.mi/src/era/mi/logic/components/Mux.java b/era.mi/src/era/mi/logic/components/Mux.java index 675c070a..aea71166 100644 --- a/era.mi/src/era/mi/logic/components/Mux.java +++ b/era.mi/src/era/mi/logic/components/Mux.java @@ -1,93 +1,93 @@ -package era.mi.logic.components; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import era.mi.logic.wires.Wire; -import era.mi.logic.wires.Wire.WireEnd; - -/** - * Models a multiplexer. Takes an arbitrary amount of input {@link Wire}s, one of which, as determined by select, is put through to the - * output. - * - * @author Fabian Stemmler - * - */ -public class Mux extends BasicComponent -{ - private WireEnd select; - private WireEnd out; - private WireEnd[] inputs; - private final int outputSize; - - /** - * Input {@link Wire}s and out must be of uniform length - * - * @param out Must be of uniform length with all inputs. - * @param select Indexes the input array which is to be mapped to the output. Must have enough bits to index all inputs. - * @param inputs One of these inputs is mapped to the output, depending on the select bits - */ - public Mux(int processTime, WireEnd out, WireEnd select, WireEnd... inputs) - { - super(processTime); - outputSize = out.length(); - - this.inputs = inputs.clone(); - for (int i = 0; i < this.inputs.length; i++) - { - if (inputs[i].length() != outputSize) - throw new IllegalArgumentException("All MUX wire arrays must be of uniform length!"); - inputs[i].addObserver(this); - } - - this.select = select; - select.addObserver(this); - - int maxInputs = 1 << select.length(); - if (this.inputs.length > maxInputs) - throw new IllegalArgumentException("There are more inputs (" + this.inputs.length + ") to the MUX than supported by " - + select.length() + " select bits (" + maxInputs + ")."); - - this.out = out; - } - - public WireEnd getOut() - { - return out; - } - - public WireEnd getSelect() - { - return select; - } - - @Override - public void compute() - { - int selectValue; - if (!select.hasNumericValue() || (selectValue = (int) select.getUnsignedValue()) >= inputs.length) - { - out.clearSignals(); - return; - } - - WireEnd active = inputs[selectValue]; - out.feedSignals(active.getValues()); - } - - @Override - public List getAllInputs() - { - ArrayList wires = new ArrayList(Arrays.asList(inputs)); - wires.add(select); - return Collections.unmodifiableList(wires); - } - - @Override - public List getAllOutputs() - { - return List.of(out); - } -} +package era.mi.logic.components; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import era.mi.logic.wires.Wire; +import era.mi.logic.wires.Wire.WireEnd; + +/** + * Models a multiplexer. Takes an arbitrary amount of input {@link Wire}s, one of which, as determined by select, is put through to the + * output. + * + * @author Fabian Stemmler + * + */ +public class Mux extends BasicComponent +{ + private WireEnd select; + private WireEnd out; + private WireEnd[] inputs; + private final int outputSize; + + /** + * Input {@link Wire}s and out must be of uniform length + * + * @param out Must be of uniform length with all inputs. + * @param select Indexes the input array which is to be mapped to the output. Must have enough bits to index all inputs. + * @param inputs One of these inputs is mapped to the output, depending on the select bits + */ + public Mux(int processTime, WireEnd out, WireEnd select, WireEnd... inputs) + { + super(processTime); + outputSize = out.length(); + + this.inputs = inputs.clone(); + for (int i = 0; i < this.inputs.length; i++) + { + if (inputs[i].length() != outputSize) + throw new IllegalArgumentException("All MUX wire arrays must be of uniform length!"); + inputs[i].addObserver(this); + } + + this.select = select; + select.addObserver(this); + + int maxInputs = 1 << select.length(); + if (this.inputs.length > maxInputs) + throw new IllegalArgumentException("There are more inputs (" + this.inputs.length + ") to the MUX than supported by " + + select.length() + " select bits (" + maxInputs + ")."); + + this.out = out; + } + + public WireEnd getOut() + { + return out; + } + + public WireEnd getSelect() + { + return select; + } + + @Override + public void compute() + { + int selectValue; + if (!select.hasNumericValue() || (selectValue = (int) select.getUnsignedValue()) >= inputs.length) + { + out.clearSignals(); + return; + } + + WireEnd active = inputs[selectValue]; + out.feedSignals(active.getValues()); + } + + @Override + public List getAllInputs() + { + ArrayList wires = new ArrayList(Arrays.asList(inputs)); + wires.add(select); + return Collections.unmodifiableList(wires); + } + + @Override + public List getAllOutputs() + { + return List.of(out); + } +} diff --git a/era.mi/src/era/mi/logic/components/Splitter.java b/era.mi/src/era/mi/logic/components/Splitter.java index e936c82e..4764c27a 100644 --- a/era.mi/src/era/mi/logic/components/Splitter.java +++ b/era.mi/src/era/mi/logic/components/Splitter.java @@ -1,43 +1,43 @@ -package era.mi.logic.components; - -import era.mi.logic.types.BitVector; -import era.mi.logic.wires.Wire; -import era.mi.logic.wires.Wire.WireEnd; -import era.mi.logic.wires.WireObserver; - -public class Splitter implements WireObserver -{ - private WireEnd input; - private WireEnd[] outputs; - - public Splitter(WireEnd input, WireEnd... outputs) - { - this.input = input; - this.outputs = outputs; - input.addObserver(this); - int length = 0; - for (WireEnd out : outputs) - length += out.length(); - - if (input.length() != length) - throw new IllegalArgumentException( - "The input of splitting one into n WireArrays must have length = a1.length() + a2.length() + ... + an.length()."); - } - - protected void compute() - { - BitVector inputBits = input.getValues(); - int startIndex = 0; - for (int i = 0; i < outputs.length; i++) - { - outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].length())); - startIndex += outputs[i].length(); - } - } - - @Override - public void update(Wire initiator, BitVector oldValues) - { - compute(); - } -} +package era.mi.logic.components; + +import era.mi.logic.types.BitVector; +import era.mi.logic.wires.Wire; +import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.WireObserver; + +public class Splitter implements WireObserver +{ + private WireEnd input; + private WireEnd[] outputs; + + public Splitter(WireEnd input, WireEnd... outputs) + { + this.input = input; + this.outputs = outputs; + input.addObserver(this); + int length = 0; + for (WireEnd out : outputs) + length += out.length(); + + if (input.length() != length) + throw new IllegalArgumentException( + "The input of splitting one into n WireArrays must have length = a1.length() + a2.length() + ... + an.length()."); + } + + protected void compute() + { + BitVector inputBits = input.getValues(); + int startIndex = 0; + for (int i = 0; i < outputs.length; i++) + { + outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].length())); + startIndex += outputs[i].length(); + } + } + + @Override + public void update(Wire initiator, BitVector oldValues) + { + compute(); + } +} diff --git a/era.mi/src/era/mi/logic/components/gates/AndGate.java b/era.mi/src/era/mi/logic/components/gates/AndGate.java index a24acc72..5da680e4 100644 --- a/era.mi/src/era/mi/logic/components/gates/AndGate.java +++ b/era.mi/src/era/mi/logic/components/gates/AndGate.java @@ -1,12 +1,12 @@ -package era.mi.logic.components.gates; - -import era.mi.logic.types.BitVector.BitVectorMutator; -import era.mi.logic.wires.Wire.WireEnd; - -public class AndGate extends MultiInputGate -{ - public AndGate(int processTime, WireEnd out, WireEnd... in) - { - super(processTime, BitVectorMutator::and, out, in); - } -} +package era.mi.logic.components.gates; + +import era.mi.logic.types.BitVector.BitVectorMutator; +import era.mi.logic.wires.Wire.WireEnd; + +public class AndGate extends MultiInputGate +{ + public AndGate(int processTime, WireEnd out, WireEnd... in) + { + super(processTime, BitVectorMutator::and, out, in); + } +} diff --git a/era.mi/src/era/mi/logic/components/gates/NotGate.java b/era.mi/src/era/mi/logic/components/gates/NotGate.java index 7baf6066..1c0d8330 100644 --- a/era.mi/src/era/mi/logic/components/gates/NotGate.java +++ b/era.mi/src/era/mi/logic/components/gates/NotGate.java @@ -1,48 +1,48 @@ -package era.mi.logic.components.gates; - -import java.util.List; - -import era.mi.logic.components.BasicComponent; -import era.mi.logic.wires.Wire.WireEnd; - -public class NotGate extends BasicComponent -{ - private WireEnd in; - private WireEnd out; - - public NotGate(int processTime, WireEnd in, WireEnd out) - { - super(processTime); - this.in = in; - in.addObserver(this); - this.out = out; - } - - @Override - protected void compute() - { - out.feedSignals(in.getValues().not()); - } - - public WireEnd getIn() - { - return in; - } - - public WireEnd getOut() - { - return out; - } - - @Override - public List getAllInputs() - { - return List.of(in); - } - - @Override - public List getAllOutputs() - { - return List.of(out); - } -} +package era.mi.logic.components.gates; + +import java.util.List; + +import era.mi.logic.components.BasicComponent; +import era.mi.logic.wires.Wire.WireEnd; + +public class NotGate extends BasicComponent +{ + private WireEnd in; + private WireEnd out; + + public NotGate(int processTime, WireEnd in, WireEnd out) + { + super(processTime); + this.in = in; + in.addObserver(this); + this.out = out; + } + + @Override + protected void compute() + { + out.feedSignals(in.getValues().not()); + } + + public WireEnd getIn() + { + return in; + } + + public WireEnd getOut() + { + return out; + } + + @Override + public List getAllInputs() + { + return List.of(in); + } + + @Override + public List getAllOutputs() + { + return List.of(out); + } +} diff --git a/era.mi/src/era/mi/logic/components/gates/OrGate.java b/era.mi/src/era/mi/logic/components/gates/OrGate.java index 0a8047cb..8c1775fd 100644 --- a/era.mi/src/era/mi/logic/components/gates/OrGate.java +++ b/era.mi/src/era/mi/logic/components/gates/OrGate.java @@ -1,12 +1,12 @@ -package era.mi.logic.components.gates; - -import era.mi.logic.types.BitVector.BitVectorMutator; -import era.mi.logic.wires.Wire.WireEnd; - -public class OrGate extends MultiInputGate -{ - public OrGate(int processTime, WireEnd out, WireEnd... in) - { - super(processTime, BitVectorMutator::or, out, in); - } -} +package era.mi.logic.components.gates; + +import era.mi.logic.types.BitVector.BitVectorMutator; +import era.mi.logic.wires.Wire.WireEnd; + +public class OrGate extends MultiInputGate +{ + public OrGate(int processTime, WireEnd out, WireEnd... in) + { + super(processTime, BitVectorMutator::or, out, in); + } +} diff --git a/era.mi/src/era/mi/logic/components/gates/XorGate.java b/era.mi/src/era/mi/logic/components/gates/XorGate.java index 9311a1db..73a25568 100644 --- a/era.mi/src/era/mi/logic/components/gates/XorGate.java +++ b/era.mi/src/era/mi/logic/components/gates/XorGate.java @@ -1,18 +1,18 @@ -package era.mi.logic.components.gates; - -import era.mi.logic.types.BitVector.BitVectorMutator; -import era.mi.logic.wires.Wire.WireEnd; - -/** - * Outputs 1 when the number of 1 inputs is odd. - * - * @author Fabian Stemmler - */ -public class XorGate extends MultiInputGate -{ - public XorGate(int processTime, WireEnd out, WireEnd... in) - { - super(processTime, BitVectorMutator::xor, out, in); - } - -} +package era.mi.logic.components.gates; + +import era.mi.logic.types.BitVector.BitVectorMutator; +import era.mi.logic.wires.Wire.WireEnd; + +/** + * Outputs 1 when the number of 1 inputs is odd. + * + * @author Fabian Stemmler + */ +public class XorGate extends MultiInputGate +{ + public XorGate(int processTime, WireEnd out, WireEnd... in) + { + super(processTime, BitVectorMutator::xor, out, in); + } + +} diff --git a/era.mi/src/era/mi/logic/tests/ComponentTest.java b/era.mi/src/era/mi/logic/tests/ComponentTest.java index d25de9e5..8a9bc5a4 100644 --- a/era.mi/src/era/mi/logic/tests/ComponentTest.java +++ b/era.mi/src/era/mi/logic/tests/ComponentTest.java @@ -1,384 +1,384 @@ -package era.mi.logic.tests; - -import static org.junit.jupiter.api.Assertions.*; - -import java.util.function.LongConsumer; - -import org.junit.jupiter.api.Test; - -import era.mi.logic.Simulation; -import era.mi.logic.components.Connector; -import era.mi.logic.components.Demux; -import era.mi.logic.components.Merger; -import era.mi.logic.components.Mux; -import era.mi.logic.components.Splitter; -import era.mi.logic.components.TriStateBuffer; -import era.mi.logic.components.gates.AndGate; -import era.mi.logic.components.gates.NotGate; -import era.mi.logic.components.gates.OrGate; -import era.mi.logic.components.gates.XorGate; -import era.mi.logic.types.Bit; -import era.mi.logic.types.BitVector; -import era.mi.logic.wires.Wire; -import era.mi.logic.wires.Wire.WireEnd; - -@SuppressWarnings("unused") -class ComponentTest -{ - - @Test - void circuitExampleTest() - { - Simulation.TIMELINE.reset(); - Wire a = new Wire(1, 1), b = new Wire(1, 1), c = new Wire(1, 10), d = new Wire(2, 1), e = new Wire(1, 1), f = new Wire(1, 1), - g = new Wire(1, 1), h = new Wire(2, 1), i = new Wire(2, 1), j = new Wire(1, 1), k = new Wire(1, 1); - new AndGate(1, f.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd()); - new NotGate(1, f.createReadOnlyEnd(), g.createEnd()); - new Merger(h.createEnd(), c.createReadOnlyEnd(), g.createReadOnlyEnd()); - new Mux(1, i.createEnd(), e.createReadOnlyEnd(), h.createReadOnlyEnd(), d.createReadOnlyEnd()); - new Splitter(i.createReadOnlyEnd(), k.createEnd(), j.createEnd()); - - a.createEnd().feedSignals(Bit.ZERO); - b.createEnd().feedSignals(Bit.ONE); - c.createEnd().feedSignals(Bit.ZERO); - d.createEnd().feedSignals(Bit.ONE, Bit.ONE); - e.createEnd().feedSignals(Bit.ZERO); - - Simulation.TIMELINE.executeAll(); - - assertEquals(Bit.ONE, j.getValue()); - assertEquals(Bit.ZERO, k.getValue()); - } - - @Test - void splitterTest() - { - Simulation.TIMELINE.reset(); - Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), in = new Wire(8, 1); - in.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); - new Splitter(in.createReadOnlyEnd(), a.createEnd(), b.createEnd(), c.createEnd()); - - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(a.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO); - assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO); - assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE); - } - - @Test - void mergerTest() - { - Simulation.TIMELINE.reset(); - Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), out = new Wire(8, 1); - a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO); - b.createEnd().feedSignals(Bit.ONE, Bit.ZERO); - c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE); - - new Merger(out.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd()); - - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); - } - - @Test - void triStateBufferTest() - { - Wire a = new Wire(1, 1), b = new Wire(1, 1), en = new Wire(1, 1), notEn = new Wire(1, 1); - new NotGate(1, en.createReadOnlyEnd(), notEn.createEnd()); - new TriStateBuffer(1, a.createReadOnlyEnd(), b.createEnd(), en.createReadOnlyEnd()); - new TriStateBuffer(1, b.createReadOnlyEnd(), a.createEnd(), notEn.createReadOnlyEnd()); - - WireEnd enI = en.createEnd(), aI = a.createEnd(), bI = b.createEnd(); - enI.feedSignals(Bit.ONE); - aI.feedSignals(Bit.ONE); - bI.feedSignals(Bit.Z); - - Simulation.TIMELINE.executeAll(); - - assertEquals(Bit.ONE, b.getValue()); - - bI.feedSignals(Bit.ZERO); - - Simulation.TIMELINE.executeAll(); - - assertEquals(Bit.X, b.getValue()); - assertEquals(Bit.ONE, a.getValue()); - - aI.clearSignals(); - enI.feedSignals(Bit.ZERO); - - Simulation.TIMELINE.executeAll(); - - assertEquals(Bit.ZERO, a.getValue()); - - } - - @Test - void muxTest() - { - Simulation.TIMELINE.reset(); - Wire a = new Wire(4, 3), b = new Wire(4, 6), c = new Wire(4, 4), select = new Wire(2, 5), out = new Wire(4, 1); - WireEnd selectIn = select.createEnd(); - - selectIn.feedSignals(Bit.ZERO, Bit.ZERO); - a.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); - c.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); - - new Mux(1, out.createEnd(), select.createReadOnlyEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd()); - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(out.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); - selectIn.feedSignals(Bit.ZERO, Bit.ONE); - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); - - selectIn.feedSignals(Bit.ONE, Bit.ONE); - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(out.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z); - - } - - @Test - void demuxTest() - { - Simulation.TIMELINE.reset(); - Wire a = new Wire(4, 3), b = new Wire(4, 6), c = new Wire(4, 4), select = new Wire(2, 5), in = new Wire(4, 1); - WireEnd selectIn = select.createEnd(); - - selectIn.feedSignals(Bit.ZERO, Bit.ZERO); - in.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); - - new Demux(1, in.createReadOnlyEnd(), select.createReadOnlyEnd(), a.createEnd(), b.createEnd(), c.createEnd()); - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(a.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); - assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U); - assertBitArrayEquals(c.getValues(), Bit.U, Bit.U, Bit.U, Bit.U); - selectIn.feedSignals(Bit.ZERO, Bit.ONE); - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z); - assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U); - assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); - - selectIn.feedSignals(Bit.ONE, Bit.ONE); - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z); - assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U); - assertBitArrayEquals(c.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z); - - } - - @Test - void andTest() - { - Simulation.TIMELINE.reset(); - Wire a = new Wire(4, 1), b = new Wire(4, 3), c = new Wire(4, 1); - new AndGate(1, c.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd()); - a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ZERO); - b.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); - - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(c.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ZERO); - } - - @Test - void orTest() - { - Simulation.TIMELINE.reset(); - Wire a = new Wire(4, 1), b = new Wire(4, 3), c = new Wire(4, 1); - new OrGate(1, c.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd()); - a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ZERO); - b.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); - - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ONE); - } - - @Test - void xorTest() - { - Simulation.TIMELINE.reset(); - Wire a = new Wire(3, 1), b = new Wire(3, 2), c = new Wire(3, 1), d = new Wire(3, 1); - new XorGate(1, d.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd()); - a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE); - b.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE); - c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE); - - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(d.getValues(), Bit.ZERO, Bit.ONE, Bit.ONE); - } - - @Test - void notTest() - { - Simulation.TIMELINE.reset(); - Wire a = new Wire(3, 1), b = new Wire(3, 2); - new NotGate(1, a.createReadOnlyEnd(), b.createEnd()); - a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE); - - Simulation.TIMELINE.executeAll(); - - assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO, Bit.ZERO); - } - - @Test - void rsLatchCircuitTest() - { - Simulation.TIMELINE.reset(); - Wire r = new Wire(1, 1), s = new Wire(1, 1), t1 = new Wire(1, 15), t2 = new Wire(1, 1), q = new Wire(1, 1), nq = new Wire(1, 1); - - new OrGate(1, t2.createEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd()); - new OrGate(1, t1.createEnd(), s.createReadOnlyEnd(), q.createReadOnlyEnd()); - new NotGate(1, t2.createReadOnlyEnd(), q.createEnd()); - new NotGate(1, t1.createReadOnlyEnd(), nq.createEnd()); - - WireEnd sIn = s.createEnd(), rIn = r.createEnd(); - - sIn.feedSignals(Bit.ONE); - rIn.feedSignals(Bit.ZERO); - - Simulation.TIMELINE.executeAll(); - - assertEquals(Bit.ONE, q.getValue()); - assertEquals(Bit.ZERO, nq.getValue()); - - sIn.feedSignals(Bit.ZERO); - - Simulation.TIMELINE.executeAll(); - assertEquals(Bit.ONE, q.getValue()); - assertEquals(Bit.ZERO, nq.getValue()); - - rIn.feedSignals(Bit.ONE); - - Simulation.TIMELINE.executeAll(); - - assertEquals(Bit.ZERO, q.getValue()); - assertEquals(Bit.ONE, nq.getValue()); - } - - @Test - void numericValueTest() - { - Simulation.TIMELINE.reset(); - - Wire a = new Wire(4, 1); - a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ONE, Bit.ONE); - - Simulation.TIMELINE.executeAll(); - - assertEquals(15, a.getUnsignedValue()); - assertEquals(-1, a.getSignedValue()); - } - - @Test - void multipleInputs() - { - Simulation.TIMELINE.reset(); - Wire w = new Wire(2, 1); - WireEnd wI1 = w.createEnd(), wI2 = w.createEnd(); - wI1.feedSignals(Bit.ONE, Bit.Z); - wI2.feedSignals(Bit.Z, Bit.X); - Simulation.TIMELINE.executeAll(); - assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.X); - - wI2.feedSignals(Bit.ZERO, Bit.Z); - Simulation.TIMELINE.executeAll(); - assertBitArrayEquals(w.getValues(), Bit.X, Bit.Z); - - wI2.feedSignals(Bit.Z, Bit.Z); - Simulation.TIMELINE.executeAll(); - assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.Z); - - wI2.feedSignals(Bit.ONE, Bit.Z); - w.addObserver((i, oldValues) -> fail("WireArray notified observer, although value did not change.")); - Simulation.TIMELINE.executeAll(); - assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.Z); - } - - @Test - void wireConnections() - { - // Nur ein Experiment, was über mehrere 'passive' Bausteine hinweg passieren würde - - Simulation.TIMELINE.reset(); - - Wire a = new Wire(1, 2); - Wire b = new Wire(1, 2); - Wire c = new Wire(1, 2); - WireEnd aI = a.createEnd(); - WireEnd bI = b.createEnd(); - WireEnd cI = c.createEnd(); - - TestBitDisplay test = new TestBitDisplay(c.createReadOnlyEnd()); - TestBitDisplay test2 = new TestBitDisplay(a.createReadOnlyEnd()); - LongConsumer print = time -> System.out.format("Time %2d\n a: %s\n b: %s\n c: %s\n", time, a, b, c); - - cI.feedSignals(Bit.ONE); - test.assertAfterSimulationIs(print, Bit.ONE); - - cI.feedSignals(Bit.X); - test.assertAfterSimulationIs(print, Bit.X); - - cI.feedSignals(Bit.X); - cI.feedSignals(Bit.Z); - test.assertAfterSimulationIs(print, Bit.Z); - - new Connector(b.createEnd(), c.createEnd()).connect(); - test.assertAfterSimulationIs(print, Bit.Z); - System.err.println("ONE"); - bI.feedSignals(Bit.ONE); - test.assertAfterSimulationIs(print, Bit.ONE); - System.err.println("ZERO"); - bI.feedSignals(Bit.ZERO); - test.assertAfterSimulationIs(print, Bit.ZERO); - System.err.println("Z"); - bI.feedSignals(Bit.Z); - test.assertAfterSimulationIs(print, Bit.Z); - - new Connector(a.createEnd(), b.createEnd()).connect(); - System.err.println("Z 2"); - aI.feedSignals(Bit.Z); - test.assertAfterSimulationIs(print, Bit.Z); - test2.assertAfterSimulationIs(Bit.Z); - System.err.println("ONE 2"); - aI.feedSignals(Bit.ONE); - test.assertAfterSimulationIs(print, Bit.ONE); - test2.assertAfterSimulationIs(Bit.ONE); - System.err.println("ZERO 2"); - aI.feedSignals(Bit.ZERO); - test.assertAfterSimulationIs(print, Bit.ZERO); - test2.assertAfterSimulationIs(Bit.ZERO); - System.err.println("Z 2 II"); - aI.feedSignals(Bit.Z); - test.assertAfterSimulationIs(print, Bit.Z); - test2.assertAfterSimulationIs(Bit.Z); - - System.err.println("No Conflict yet"); - bI.feedSignals(Bit.ONE); - test.assertAfterSimulationIs(print, Bit.ONE); - test2.assertAfterSimulationIs(Bit.ONE); - aI.feedSignals(Bit.ONE); - test.assertAfterSimulationIs(print, Bit.ONE); - test2.assertAfterSimulationIs(Bit.ONE); - System.err.println("Conflict"); - aI.feedSignals(Bit.ZERO); - test.assertAfterSimulationIs(print, Bit.X); - test2.assertAfterSimulationIs(Bit.X); - aI.feedSignals(Bit.ONE); - test.assertAfterSimulationIs(print, Bit.ONE); - test2.assertAfterSimulationIs(Bit.ONE); - } - - private static void assertBitArrayEquals(BitVector actual, Bit... expected) - { - assertArrayEquals(expected, actual.getBits()); - } -} +package era.mi.logic.tests; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.function.LongConsumer; + +import org.junit.jupiter.api.Test; + +import era.mi.logic.Simulation; +import era.mi.logic.components.Connector; +import era.mi.logic.components.Demux; +import era.mi.logic.components.Merger; +import era.mi.logic.components.Mux; +import era.mi.logic.components.Splitter; +import era.mi.logic.components.TriStateBuffer; +import era.mi.logic.components.gates.AndGate; +import era.mi.logic.components.gates.NotGate; +import era.mi.logic.components.gates.OrGate; +import era.mi.logic.components.gates.XorGate; +import era.mi.logic.types.Bit; +import era.mi.logic.types.BitVector; +import era.mi.logic.wires.Wire; +import era.mi.logic.wires.Wire.WireEnd; + +@SuppressWarnings("unused") +class ComponentTest +{ + + @Test + void circuitExampleTest() + { + Simulation.TIMELINE.reset(); + Wire a = new Wire(1, 1), b = new Wire(1, 1), c = new Wire(1, 10), d = new Wire(2, 1), e = new Wire(1, 1), f = new Wire(1, 1), + g = new Wire(1, 1), h = new Wire(2, 1), i = new Wire(2, 1), j = new Wire(1, 1), k = new Wire(1, 1); + new AndGate(1, f.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd()); + new NotGate(1, f.createReadOnlyEnd(), g.createEnd()); + new Merger(h.createEnd(), c.createReadOnlyEnd(), g.createReadOnlyEnd()); + new Mux(1, i.createEnd(), e.createReadOnlyEnd(), h.createReadOnlyEnd(), d.createReadOnlyEnd()); + new Splitter(i.createReadOnlyEnd(), k.createEnd(), j.createEnd()); + + a.createEnd().feedSignals(Bit.ZERO); + b.createEnd().feedSignals(Bit.ONE); + c.createEnd().feedSignals(Bit.ZERO); + d.createEnd().feedSignals(Bit.ONE, Bit.ONE); + e.createEnd().feedSignals(Bit.ZERO); + + Simulation.TIMELINE.executeAll(); + + assertEquals(Bit.ONE, j.getValue()); + assertEquals(Bit.ZERO, k.getValue()); + } + + @Test + void splitterTest() + { + Simulation.TIMELINE.reset(); + Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), in = new Wire(8, 1); + in.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); + new Splitter(in.createReadOnlyEnd(), a.createEnd(), b.createEnd(), c.createEnd()); + + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(a.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO); + assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO); + assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE); + } + + @Test + void mergerTest() + { + Simulation.TIMELINE.reset(); + Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), out = new Wire(8, 1); + a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO); + b.createEnd().feedSignals(Bit.ONE, Bit.ZERO); + c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE); + + new Merger(out.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd()); + + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); + } + + @Test + void triStateBufferTest() + { + Wire a = new Wire(1, 1), b = new Wire(1, 1), en = new Wire(1, 1), notEn = new Wire(1, 1); + new NotGate(1, en.createReadOnlyEnd(), notEn.createEnd()); + new TriStateBuffer(1, a.createReadOnlyEnd(), b.createEnd(), en.createReadOnlyEnd()); + new TriStateBuffer(1, b.createReadOnlyEnd(), a.createEnd(), notEn.createReadOnlyEnd()); + + WireEnd enI = en.createEnd(), aI = a.createEnd(), bI = b.createEnd(); + enI.feedSignals(Bit.ONE); + aI.feedSignals(Bit.ONE); + bI.feedSignals(Bit.Z); + + Simulation.TIMELINE.executeAll(); + + assertEquals(Bit.ONE, b.getValue()); + + bI.feedSignals(Bit.ZERO); + + Simulation.TIMELINE.executeAll(); + + assertEquals(Bit.X, b.getValue()); + assertEquals(Bit.ONE, a.getValue()); + + aI.clearSignals(); + enI.feedSignals(Bit.ZERO); + + Simulation.TIMELINE.executeAll(); + + assertEquals(Bit.ZERO, a.getValue()); + + } + + @Test + void muxTest() + { + Simulation.TIMELINE.reset(); + Wire a = new Wire(4, 3), b = new Wire(4, 6), c = new Wire(4, 4), select = new Wire(2, 5), out = new Wire(4, 1); + WireEnd selectIn = select.createEnd(); + + selectIn.feedSignals(Bit.ZERO, Bit.ZERO); + a.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); + c.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); + + new Mux(1, out.createEnd(), select.createReadOnlyEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd()); + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(out.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); + selectIn.feedSignals(Bit.ZERO, Bit.ONE); + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); + + selectIn.feedSignals(Bit.ONE, Bit.ONE); + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(out.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z); + + } + + @Test + void demuxTest() + { + Simulation.TIMELINE.reset(); + Wire a = new Wire(4, 3), b = new Wire(4, 6), c = new Wire(4, 4), select = new Wire(2, 5), in = new Wire(4, 1); + WireEnd selectIn = select.createEnd(); + + selectIn.feedSignals(Bit.ZERO, Bit.ZERO); + in.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); + + new Demux(1, in.createReadOnlyEnd(), select.createReadOnlyEnd(), a.createEnd(), b.createEnd(), c.createEnd()); + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(a.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); + assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U); + assertBitArrayEquals(c.getValues(), Bit.U, Bit.U, Bit.U, Bit.U); + selectIn.feedSignals(Bit.ZERO, Bit.ONE); + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z); + assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U); + assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO); + + selectIn.feedSignals(Bit.ONE, Bit.ONE); + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z); + assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U); + assertBitArrayEquals(c.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z); + + } + + @Test + void andTest() + { + Simulation.TIMELINE.reset(); + Wire a = new Wire(4, 1), b = new Wire(4, 3), c = new Wire(4, 1); + new AndGate(1, c.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd()); + a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ZERO); + b.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); + + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(c.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ZERO); + } + + @Test + void orTest() + { + Simulation.TIMELINE.reset(); + Wire a = new Wire(4, 1), b = new Wire(4, 3), c = new Wire(4, 1); + new OrGate(1, c.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd()); + a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ZERO); + b.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE); + + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ONE, Bit.ZERO, Bit.ONE); + } + + @Test + void xorTest() + { + Simulation.TIMELINE.reset(); + Wire a = new Wire(3, 1), b = new Wire(3, 2), c = new Wire(3, 1), d = new Wire(3, 1); + new XorGate(1, d.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd()); + a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE); + b.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE); + c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE); + + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(d.getValues(), Bit.ZERO, Bit.ONE, Bit.ONE); + } + + @Test + void notTest() + { + Simulation.TIMELINE.reset(); + Wire a = new Wire(3, 1), b = new Wire(3, 2); + new NotGate(1, a.createReadOnlyEnd(), b.createEnd()); + a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE); + + Simulation.TIMELINE.executeAll(); + + assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO, Bit.ZERO); + } + + @Test + void rsLatchCircuitTest() + { + Simulation.TIMELINE.reset(); + Wire r = new Wire(1, 1), s = new Wire(1, 1), t1 = new Wire(1, 15), t2 = new Wire(1, 1), q = new Wire(1, 1), nq = new Wire(1, 1); + + new OrGate(1, t2.createEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd()); + new OrGate(1, t1.createEnd(), s.createReadOnlyEnd(), q.createReadOnlyEnd()); + new NotGate(1, t2.createReadOnlyEnd(), q.createEnd()); + new NotGate(1, t1.createReadOnlyEnd(), nq.createEnd()); + + WireEnd sIn = s.createEnd(), rIn = r.createEnd(); + + sIn.feedSignals(Bit.ONE); + rIn.feedSignals(Bit.ZERO); + + Simulation.TIMELINE.executeAll(); + + assertEquals(Bit.ONE, q.getValue()); + assertEquals(Bit.ZERO, nq.getValue()); + + sIn.feedSignals(Bit.ZERO); + + Simulation.TIMELINE.executeAll(); + assertEquals(Bit.ONE, q.getValue()); + assertEquals(Bit.ZERO, nq.getValue()); + + rIn.feedSignals(Bit.ONE); + + Simulation.TIMELINE.executeAll(); + + assertEquals(Bit.ZERO, q.getValue()); + assertEquals(Bit.ONE, nq.getValue()); + } + + @Test + void numericValueTest() + { + Simulation.TIMELINE.reset(); + + Wire a = new Wire(4, 1); + a.createEnd().feedSignals(Bit.ONE, Bit.ONE, Bit.ONE, Bit.ONE); + + Simulation.TIMELINE.executeAll(); + + assertEquals(15, a.getUnsignedValue()); + assertEquals(-1, a.getSignedValue()); + } + + @Test + void multipleInputs() + { + Simulation.TIMELINE.reset(); + Wire w = new Wire(2, 1); + WireEnd wI1 = w.createEnd(), wI2 = w.createEnd(); + wI1.feedSignals(Bit.ONE, Bit.Z); + wI2.feedSignals(Bit.Z, Bit.X); + Simulation.TIMELINE.executeAll(); + assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.X); + + wI2.feedSignals(Bit.ZERO, Bit.Z); + Simulation.TIMELINE.executeAll(); + assertBitArrayEquals(w.getValues(), Bit.X, Bit.Z); + + wI2.feedSignals(Bit.Z, Bit.Z); + Simulation.TIMELINE.executeAll(); + assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.Z); + + wI2.feedSignals(Bit.ONE, Bit.Z); + w.addObserver((i, oldValues) -> fail("WireArray notified observer, although value did not change.")); + Simulation.TIMELINE.executeAll(); + assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.Z); + } + + @Test + void wireConnections() + { + // Nur ein Experiment, was über mehrere 'passive' Bausteine hinweg passieren würde + + Simulation.TIMELINE.reset(); + + Wire a = new Wire(1, 2); + Wire b = new Wire(1, 2); + Wire c = new Wire(1, 2); + WireEnd aI = a.createEnd(); + WireEnd bI = b.createEnd(); + WireEnd cI = c.createEnd(); + + TestBitDisplay test = new TestBitDisplay(c.createReadOnlyEnd()); + TestBitDisplay test2 = new TestBitDisplay(a.createReadOnlyEnd()); + LongConsumer print = time -> System.out.format("Time %2d\n a: %s\n b: %s\n c: %s\n", time, a, b, c); + + cI.feedSignals(Bit.ONE); + test.assertAfterSimulationIs(print, Bit.ONE); + + cI.feedSignals(Bit.X); + test.assertAfterSimulationIs(print, Bit.X); + + cI.feedSignals(Bit.X); + cI.feedSignals(Bit.Z); + test.assertAfterSimulationIs(print, Bit.Z); + + new Connector(b.createEnd(), c.createEnd()).connect(); + test.assertAfterSimulationIs(print, Bit.Z); + System.err.println("ONE"); + bI.feedSignals(Bit.ONE); + test.assertAfterSimulationIs(print, Bit.ONE); + System.err.println("ZERO"); + bI.feedSignals(Bit.ZERO); + test.assertAfterSimulationIs(print, Bit.ZERO); + System.err.println("Z"); + bI.feedSignals(Bit.Z); + test.assertAfterSimulationIs(print, Bit.Z); + + new Connector(a.createEnd(), b.createEnd()).connect(); + System.err.println("Z 2"); + aI.feedSignals(Bit.Z); + test.assertAfterSimulationIs(print, Bit.Z); + test2.assertAfterSimulationIs(Bit.Z); + System.err.println("ONE 2"); + aI.feedSignals(Bit.ONE); + test.assertAfterSimulationIs(print, Bit.ONE); + test2.assertAfterSimulationIs(Bit.ONE); + System.err.println("ZERO 2"); + aI.feedSignals(Bit.ZERO); + test.assertAfterSimulationIs(print, Bit.ZERO); + test2.assertAfterSimulationIs(Bit.ZERO); + System.err.println("Z 2 II"); + aI.feedSignals(Bit.Z); + test.assertAfterSimulationIs(print, Bit.Z); + test2.assertAfterSimulationIs(Bit.Z); + + System.err.println("No Conflict yet"); + bI.feedSignals(Bit.ONE); + test.assertAfterSimulationIs(print, Bit.ONE); + test2.assertAfterSimulationIs(Bit.ONE); + aI.feedSignals(Bit.ONE); + test.assertAfterSimulationIs(print, Bit.ONE); + test2.assertAfterSimulationIs(Bit.ONE); + System.err.println("Conflict"); + aI.feedSignals(Bit.ZERO); + test.assertAfterSimulationIs(print, Bit.X); + test2.assertAfterSimulationIs(Bit.X); + aI.feedSignals(Bit.ONE); + test.assertAfterSimulationIs(print, Bit.ONE); + test2.assertAfterSimulationIs(Bit.ONE); + } + + private static void assertBitArrayEquals(BitVector actual, Bit... expected) + { + assertArrayEquals(expected, actual.getBits()); + } +} diff --git a/era.mi/src/era/mi/logic/tests/TestBitDisplay.java b/era.mi/src/era/mi/logic/tests/TestBitDisplay.java index d821752b..cb0494e1 100644 --- a/era.mi/src/era/mi/logic/tests/TestBitDisplay.java +++ b/era.mi/src/era/mi/logic/tests/TestBitDisplay.java @@ -1,47 +1,47 @@ -package era.mi.logic.tests; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; - -import java.util.function.LongConsumer; - -import era.mi.logic.Simulation; -import era.mi.logic.components.BitDisplay; -import era.mi.logic.types.Bit; -import era.mi.logic.wires.Wire.WireEnd; - -public final class TestBitDisplay extends BitDisplay -{ - - public TestBitDisplay(WireEnd in) - { - super(in); - } - - public void assertDisplays(Bit... expected) - { - assertArrayEquals(expected, getDisplayedValue().getBits()); - } - - public void assertAfterSimulationIs(Bit... expected) - { - Simulation.TIMELINE.executeAll(); - assertDisplays(expected); - } - - public void assertAfterSimulationIs(LongConsumer r, Bit... expected) - { - while (Simulation.TIMELINE.hasNext()) - { - Simulation.TIMELINE.executeNext(); - r.accept(Simulation.TIMELINE.getSimulationTime()); - } - assertDisplays(expected); - } - - @Override - protected void compute() - { - super.compute(); - System.out.println("update: value is " + getDisplayedValue()); - } -} +package era.mi.logic.tests; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + +import java.util.function.LongConsumer; + +import era.mi.logic.Simulation; +import era.mi.logic.components.BitDisplay; +import era.mi.logic.types.Bit; +import era.mi.logic.wires.Wire.WireEnd; + +public final class TestBitDisplay extends BitDisplay +{ + + public TestBitDisplay(WireEnd in) + { + super(in); + } + + public void assertDisplays(Bit... expected) + { + assertArrayEquals(expected, getDisplayedValue().getBits()); + } + + public void assertAfterSimulationIs(Bit... expected) + { + Simulation.TIMELINE.executeAll(); + assertDisplays(expected); + } + + public void assertAfterSimulationIs(LongConsumer r, Bit... expected) + { + while (Simulation.TIMELINE.hasNext()) + { + Simulation.TIMELINE.executeNext(); + r.accept(Simulation.TIMELINE.getSimulationTime()); + } + assertDisplays(expected); + } + + @Override + protected void compute() + { + super.compute(); + System.out.println("update: value is " + getDisplayedValue()); + } +} diff --git a/era.mi/src/era/mi/logic/timeline/Timeline.java b/era.mi/src/era/mi/logic/timeline/Timeline.java index 9e649388..8107db96 100644 --- a/era.mi/src/era/mi/logic/timeline/Timeline.java +++ b/era.mi/src/era/mi/logic/timeline/Timeline.java @@ -1,178 +1,178 @@ -package era.mi.logic.timeline; - -import java.util.ArrayList; -import java.util.List; -import java.util.PriorityQueue; -import java.util.function.Consumer; - -/** - * Orders Events by the time they are due to be executed. Can execute Events individually. - * - * @author Fabian Stemmler - * - */ -public class Timeline -{ - private PriorityQueue events; - private long currentTime = 0; - - private final List> eventAddedListener; - - public Timeline(int initCapacity) - { - events = new PriorityQueue(initCapacity, (a, b) -> - { - long difference = a.getTiming() - b.getTiming(); - if (difference == 0) - return 0; - return difference < 0 ? -1 : 1; - }); - - eventAddedListener = new ArrayList<>(); - } - - public boolean hasNext() - { - return !events.isEmpty(); - } - - public void executeNext() - { - InnerEvent first = events.poll(); - currentTime = first.getTiming(); - first.run(); - } - - public void executeAll() - { - while (hasNext()) - executeNext(); - } - - /** - * Executes all events up to a given simulation timestamp. The simulation process can be constrained by a real world timestamp. - * - * @param timestamp the simulation timestamp up to which the events will be processed - * @param stopMillis the System.currentTimeMillis() when simulation definitely needs to stop. - * @return if it was possible to fulfil the goal in the given real world time. - * @author Christian Femers - */ - public ExecutionResult executeUpTo(long timestamp, long stopMillis) - { - if (events.isEmpty()) - { - currentTime = timestamp; - return ExecutionResult.NOTHING_DONE; - } - int checkStop = 0; - InnerEvent first = events.peek(); - while (first != null && first.getTiming() <= timestamp) - { - events.remove(); - currentTime = first.getTiming(); - first.run(); - // Don't check after every run - checkStop = (checkStop + 1) % 10; - if (checkStop == 0 && System.currentTimeMillis() >= stopMillis) - return ExecutionResult.RAN_OUT_OF_TIME; - first = events.peek(); - } - currentTime = timestamp; - return ExecutionResult.DONE_IN_TIME; - } - - public long getSimulationTime() - { - return currentTime; - } - - public long nextEventTime() - { - if (!hasNext()) - return -1; - return events.peek().timing; - } - - public void reset() - { - events.clear(); - currentTime = 0; - } - - public void addEventAddedListener(Consumer listener) - { - eventAddedListener.add(listener); - } - - public void removeEventAddedListener(Consumer listener) - { - eventAddedListener.remove(listener); - } - - /** - * Adds an Event to the {@link Timeline} - * - * @param function The {@link TimelineEventHandler} that will be executed, when the {@link InnerEvent} occurs on the timeline. - * @param relativeTiming The amount of MI ticks in which the {@link InnerEvent} is called, starting from the current time. - */ - public void addEvent(TimelineEventHandler function, int relativeTiming) - { - long timing = currentTime + relativeTiming; - TimelineEvent event = new TimelineEvent(timing); - events.add(new InnerEvent(function, event, timing)); - eventAddedListener.forEach(l -> l.accept(event)); - } - - private class InnerEvent - { - - final long timing; - private final TimelineEventHandler function; - private final TimelineEvent event; - - /** - * Creates an {@link InnerEvent} - * - * @param function {@link TimelineEventHandler} to be executed when the {@link InnerEvent} occurs - * @param timing Point in the MI simulation {@link Timeline}, at which the {@link InnerEvent} is executed; - */ - InnerEvent(TimelineEventHandler function, TimelineEvent event, long timing) - { - this.function = function; - this.event = event; - this.timing = timing; - } - - public long getTiming() - { - return timing; - } - - public void run() - { - function.handle(event); - } - - @Override - public String toString() - { - return event.toString(); - } - } - - @Override - public String toString() - { - return "simulation time: " + currentTime + ", " + events.toString(); - } - - public static long toNanoseconds(long ticks) - { - return ticks; // TODO: Alter this when it has been determined how ticks should relate to real time. - } - - public enum ExecutionResult - { - NOTHING_DONE, DONE_IN_TIME, RAN_OUT_OF_TIME - } +package era.mi.logic.timeline; + +import java.util.ArrayList; +import java.util.List; +import java.util.PriorityQueue; +import java.util.function.Consumer; + +/** + * Orders Events by the time they are due to be executed. Can execute Events individually. + * + * @author Fabian Stemmler + * + */ +public class Timeline +{ + private PriorityQueue events; + private long currentTime = 0; + + private final List> eventAddedListener; + + public Timeline(int initCapacity) + { + events = new PriorityQueue(initCapacity, (a, b) -> + { + long difference = a.getTiming() - b.getTiming(); + if (difference == 0) + return 0; + return difference < 0 ? -1 : 1; + }); + + eventAddedListener = new ArrayList<>(); + } + + public boolean hasNext() + { + return !events.isEmpty(); + } + + public void executeNext() + { + InnerEvent first = events.poll(); + currentTime = first.getTiming(); + first.run(); + } + + public void executeAll() + { + while (hasNext()) + executeNext(); + } + + /** + * Executes all events up to a given simulation timestamp. The simulation process can be constrained by a real world timestamp. + * + * @param timestamp the simulation timestamp up to which the events will be processed + * @param stopMillis the System.currentTimeMillis() when simulation definitely needs to stop. + * @return if it was possible to fulfil the goal in the given real world time. + * @author Christian Femers + */ + public ExecutionResult executeUpTo(long timestamp, long stopMillis) + { + if (events.isEmpty()) + { + currentTime = timestamp; + return ExecutionResult.NOTHING_DONE; + } + int checkStop = 0; + InnerEvent first = events.peek(); + while (first != null && first.getTiming() <= timestamp) + { + events.remove(); + currentTime = first.getTiming(); + first.run(); + // Don't check after every run + checkStop = (checkStop + 1) % 10; + if (checkStop == 0 && System.currentTimeMillis() >= stopMillis) + return ExecutionResult.RAN_OUT_OF_TIME; + first = events.peek(); + } + currentTime = timestamp; + return ExecutionResult.DONE_IN_TIME; + } + + public long getSimulationTime() + { + return currentTime; + } + + public long nextEventTime() + { + if (!hasNext()) + return -1; + return events.peek().timing; + } + + public void reset() + { + events.clear(); + currentTime = 0; + } + + public void addEventAddedListener(Consumer listener) + { + eventAddedListener.add(listener); + } + + public void removeEventAddedListener(Consumer listener) + { + eventAddedListener.remove(listener); + } + + /** + * Adds an Event to the {@link Timeline} + * + * @param function The {@link TimelineEventHandler} that will be executed, when the {@link InnerEvent} occurs on the timeline. + * @param relativeTiming The amount of MI ticks in which the {@link InnerEvent} is called, starting from the current time. + */ + public void addEvent(TimelineEventHandler function, int relativeTiming) + { + long timing = currentTime + relativeTiming; + TimelineEvent event = new TimelineEvent(timing); + events.add(new InnerEvent(function, event, timing)); + eventAddedListener.forEach(l -> l.accept(event)); + } + + private class InnerEvent + { + + final long timing; + private final TimelineEventHandler function; + private final TimelineEvent event; + + /** + * Creates an {@link InnerEvent} + * + * @param function {@link TimelineEventHandler} to be executed when the {@link InnerEvent} occurs + * @param timing Point in the MI simulation {@link Timeline}, at which the {@link InnerEvent} is executed; + */ + InnerEvent(TimelineEventHandler function, TimelineEvent event, long timing) + { + this.function = function; + this.event = event; + this.timing = timing; + } + + public long getTiming() + { + return timing; + } + + public void run() + { + function.handle(event); + } + + @Override + public String toString() + { + return event.toString(); + } + } + + @Override + public String toString() + { + return "simulation time: " + currentTime + ", " + events.toString(); + } + + public static long toNanoseconds(long ticks) + { + return ticks; // TODO: Alter this when it has been determined how ticks should relate to real time. + } + + public enum ExecutionResult + { + NOTHING_DONE, DONE_IN_TIME, RAN_OUT_OF_TIME + } } \ No newline at end of file diff --git a/era.mi/src/era/mi/logic/timeline/TimelineEvent.java b/era.mi/src/era/mi/logic/timeline/TimelineEvent.java index cc37c992..46decf5f 100644 --- a/era.mi/src/era/mi/logic/timeline/TimelineEvent.java +++ b/era.mi/src/era/mi/logic/timeline/TimelineEvent.java @@ -1,30 +1,30 @@ -package era.mi.logic.timeline; - -/** - * A class that stores all relevant information about an event in the {@link Timeline}. Currently, there is not much relevant information to - * store. - * - * @author Fabian Stemmler - * - */ -public class TimelineEvent -{ - private final long timing; - - TimelineEvent(long timing) - { - super(); - this.timing = timing; - } - - public long getTiming() - { - return timing; - } - - @Override - public String toString() - { - return "timestamp: " + timing; - } +package era.mi.logic.timeline; + +/** + * A class that stores all relevant information about an event in the {@link Timeline}. Currently, there is not much relevant information to + * store. + * + * @author Fabian Stemmler + * + */ +public class TimelineEvent +{ + private final long timing; + + TimelineEvent(long timing) + { + super(); + this.timing = timing; + } + + public long getTiming() + { + return timing; + } + + @Override + public String toString() + { + return "timestamp: " + timing; + } } \ No newline at end of file diff --git a/era.mi/src/era/mi/logic/timeline/TimelineEventHandler.java b/era.mi/src/era/mi/logic/timeline/TimelineEventHandler.java index c2dcb986..59a91c95 100644 --- a/era.mi/src/era/mi/logic/timeline/TimelineEventHandler.java +++ b/era.mi/src/era/mi/logic/timeline/TimelineEventHandler.java @@ -1,6 +1,6 @@ -package era.mi.logic.timeline; - -public interface TimelineEventHandler -{ - public void handle(TimelineEvent e); +package era.mi.logic.timeline; + +public interface TimelineEventHandler +{ + public void handle(TimelineEvent e); } \ No newline at end of file diff --git a/logicui b/logicui new file mode 160000 index 00000000..32a3d41c --- /dev/null +++ b/logicui @@ -0,0 +1 @@ +Subproject commit 32a3d41c11b96c2530c25b6059b4341a8b34a2e2