diff --git a/MPSoC/soclib/soclib/platform/topcells/caba-vgmn-mutekh_kernel_tutorial/my_hwa0.cpp b/MPSoC/soclib/soclib/platform/topcells/caba-vgmn-mutekh_kernel_tutorial/my_hwa0.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ebe9946c620d70bf369691398f21d513dda09b96 --- /dev/null +++ b/MPSoC/soclib/soclib/platform/topcells/caba-vgmn-mutekh_kernel_tutorial/my_hwa0.cpp @@ -0,0 +1,38 @@ +#include "my_hwa0.h" + +namespace dsx { namespace caba { + + +#define tmpl(...) __VA_ARGS__ MyHWA0 + +tmpl(/**/)::~MyHWA0() +{ +} + +tmpl(/**/)::MyHWA0(sc_core::sc_module_name insname) + :dsx::caba::FifoVirtualCoprocessorWrapper(insname, stringArray("output", NULL), intArray(1, 8), stringArray("input", NULL), intArray(1, 8)) +{ +} + +tmpl(void *)::task_func() { + srl_mwmr_t input = SRL_GET_MWMR(input); + srl_mwmr_t output = SRL_GET_MWMR(output); + + uint32_t in0[8]; + uint32_t in1[8]; + uint32_t out[8]; + + while (true) { + // srl_mwmr_read(input0, &in0, 1); // Read 8 words from input0, i.e. 1 item since the fifo is 8-word wide + //srl_mwmr_read(input1, &in1, 1); // Read 8 words from input1 + srl_mwmr_read(input, &in0, 1); //DG 4.9. corrige + srl_mwmr_read(input, &in1, 1); //DG 4.9. corrige + for (int32_t i = 0; i < 8; i++) { + out[i] = in0[i] + in1[i]; + } + srl_busy_cycles(2); // The computation takes 2 cycles + srl_mwmr_write(output, &out, 1); // Write 8 words to output + } +} + +}} diff --git a/MPSoC/soclib/soclib/platform/topcells/caba-vgmn-mutekh_kernel_tutorial/my_hwa0.h b/MPSoC/soclib/soclib/platform/topcells/caba-vgmn-mutekh_kernel_tutorial/my_hwa0.h new file mode 100644 index 0000000000000000000000000000000000000000..918e0c06159019c881d7a98b86d7843657246141 --- /dev/null +++ b/MPSoC/soclib/soclib/platform/topcells/caba-vgmn-mutekh_kernel_tutorial/my_hwa0.h @@ -0,0 +1,25 @@ +#ifndef _ADDER_COPRO_H +#define _ADDER_COPRO_H + +#include <systemc> + +#include "fifo_virtual_copro_wrapper.h" + +namespace dsx { namespace caba { + +class MyHWA0 + : public dsx::caba::FifoVirtualCoprocessorWrapper +{ + + public: + ~MyHWA0(); + MyHWA0(sc_core::sc_module_name insname); + + + private: + void * task_func(); // Task code + +}; + +}} +#endif /* _ADDER_COPRO_H */ diff --git a/MPSoC/soclib/soclib/platform/topcells/caba-vgmn-mutekh_kernel_tutorial/my_hwa0.sd b/MPSoC/soclib/soclib/platform/topcells/caba-vgmn-mutekh_kernel_tutorial/my_hwa0.sd new file mode 100644 index 0000000000000000000000000000000000000000..28472d3ed755900043f475da78c3e4fe63975ead --- /dev/null +++ b/MPSoC/soclib/soclib/platform/topcells/caba-vgmn-mutekh_kernel_tutorial/my_hwa0.sd @@ -0,0 +1,27 @@ +#-*- python -*- + +Module('caba:my_hwa0', + classname = 'dsx::caba::MyHWA0', + header_files = [ + "my_hwa0.h", + + ], + interface_files = [ + ], + implementation_files = [ + "my_hwa0.cpp", + + ], + ports = [ + ], + uses = [ + Uses('caba:fifo_virtual_copro_wrapper'), + ], + instance_parameters = [ + ], + tmpl_parameters = [ + ], + extensions = [ + ], +) + diff --git a/Makefile b/Makefile index 3301c6ce7cb4eeee8da59dd8f2a5f972b2913b38..7af3a1c8d6f3f994b8c4a365b5c7ff8b30944711 100755 --- a/Makefile +++ b/Makefile @@ -7,14 +7,14 @@ TAR = tar GZIP = gzip GRADLE = $(shell which gradle) GRADLE_VERSION_NEEDED = 3.3 -ERROR_MSG = echo "$(COLOR)\nBuild with gradle failed. Falling back to regular javac command...\n$(RESET)" +ERROR_MSG = printf "$(COLOR)\nBuild with gradle failed. Falling back to regular javac command...\n$(RESET)" ifeq "$(GRADLE)" "" ERROR_MSG = echo "Gradle was not found. Falling back to regular javac command...\n" GRADLE = false && echo >/dev/null else GRADLE_VERSION := $(shell $(GRADLE) --version | grep "^Gradle" | awk '{print $$2}') - GRADLE_VERSION_MIN := $(shell echo "$(GRADLE_VERSION_NEEDED)\n$(GRADLE_VERSION)" | sort -V 2>/dev/null | head -n1) + GRADLE_VERSION_MIN := $(shell printf "%s\n%s\n" "$(GRADLE_VERSION_NEEDED)" "$(GRADLE_VERSION)" | sort -V 2>/dev/null | head -n1) ifneq "$(GRADLE_VERSION_NEEDED)" "$(GRADLE_VERSION_MIN)" ERROR_MSG = echo "$(COLOR)Gradle $(GRADLE_VERSION) is too old. Needs at least $(GRADLE_VERSION_NEEDED). Falling back to regular javac command...\n$(RESET)" GRADLE = false && echo >/dev/null diff --git a/modeling/SoCLib/test_coproc.xml b/modeling/SoCLib/test_coproc.xml new file mode 100644 index 0000000000000000000000000000000000000000..8d118c39f6f63c79ff4d149f5037e04f0948e014 --- /dev/null +++ b/modeling/SoCLib/test_coproc.xml @@ -0,0 +1,748 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> + +<TURTLEGMODELING version="0.99-beta4"> + +<Modeling type="AVATAR Design" nameTab="Design" > +<AVATARBlockDiagramPanel name="Block Diagram" minX="10" maxX="2500" minY="10" maxY="1500" > +<MainCode value="void __user_init() {"/> +<MainCode value="}"/> +<Optimized value="true" /> +<Validated value="" /> +<Ignored value="" /> + +<CONNECTOR type="5002" id="2" > +<cdparam x="386" y="271" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="" /> +<TGConnectingPoint num="0" id="1" /> +<P1 x="386" y="271" id="32" /> +<P2 x="474" y="271" id="6" /> +<AutomaticDrawing data="true" /> +<extraparam> +<isd value="in valrec()" /> +<oso value="out val()" /> +<FIFOType asynchronous="true" size="1" blocking="false" private="true" broadcast="false" lossy="false" /> +</extraparam> +</CONNECTOR> +<COMPONENT type="5000" id="27" > +<cdparam x="474" y="171" /> +<sizeparam width="250" height="200" minWidth="5" minHeight="2" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Block1" value="Block1" /> +<TGConnectingPoint num="0" id="3" /> +<TGConnectingPoint num="1" id="4" /> +<TGConnectingPoint num="2" id="5" /> +<TGConnectingPoint num="3" id="6" /> +<TGConnectingPoint num="4" id="7" /> +<TGConnectingPoint num="5" id="8" /> +<TGConnectingPoint num="6" id="9" /> +<TGConnectingPoint num="7" id="10" /> +<TGConnectingPoint num="8" id="11" /> +<TGConnectingPoint num="9" id="12" /> +<TGConnectingPoint num="10" id="13" /> +<TGConnectingPoint num="11" id="14" /> +<TGConnectingPoint num="12" id="15" /> +<TGConnectingPoint num="13" id="16" /> +<TGConnectingPoint num="14" id="17" /> +<TGConnectingPoint num="15" id="18" /> +<TGConnectingPoint num="16" id="19" /> +<TGConnectingPoint num="17" id="20" /> +<TGConnectingPoint num="18" id="21" /> +<TGConnectingPoint num="19" id="22" /> +<TGConnectingPoint num="20" id="23" /> +<TGConnectingPoint num="21" id="24" /> +<TGConnectingPoint num="22" id="25" /> +<TGConnectingPoint num="23" id="26" /> +<extraparam> +<CryptoBlock value="false" /> +<Attribute access="0" id="valrec" value="" type="8" typeOther="" /> +<Signal value="in valrec()" attached="true" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5000" id="52" > +<cdparam x="136" y="171" /> +<sizeparam width="250" height="200" minWidth="5" minHeight="2" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Block0" value="Block0" /> +<TGConnectingPoint num="0" id="28" /> +<TGConnectingPoint num="1" id="29" /> +<TGConnectingPoint num="2" id="30" /> +<TGConnectingPoint num="3" id="31" /> +<TGConnectingPoint num="4" id="32" /> +<TGConnectingPoint num="5" id="33" /> +<TGConnectingPoint num="6" id="34" /> +<TGConnectingPoint num="7" id="35" /> +<TGConnectingPoint num="8" id="36" /> +<TGConnectingPoint num="9" id="37" /> +<TGConnectingPoint num="10" id="38" /> +<TGConnectingPoint num="11" id="39" /> +<TGConnectingPoint num="12" id="40" /> +<TGConnectingPoint num="13" id="41" /> +<TGConnectingPoint num="14" id="42" /> +<TGConnectingPoint num="15" id="43" /> +<TGConnectingPoint num="16" id="44" /> +<TGConnectingPoint num="17" id="45" /> +<TGConnectingPoint num="18" id="46" /> +<TGConnectingPoint num="19" id="47" /> +<TGConnectingPoint num="20" id="48" /> +<TGConnectingPoint num="21" id="49" /> +<TGConnectingPoint num="22" id="50" /> +<TGConnectingPoint num="23" id="51" /> +<extraparam> +<CryptoBlock value="false" /> +<Attribute access="0" id="val" value="1" type="8" typeOther="" /> +<Signal value="out val()" attached="true" /> +</extraparam> +</COMPONENT> + + +</AVATARBlockDiagramPanel> + +<AVATARStateMachineDiagramPanel name="Block1" minX="10" maxX="2500" minY="10" maxY="1500" > +<COMPONENT type="5101" id="373" > +<cdparam x="418" y="213" /> +<sizeparam width="20" height="20" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="stop state" value="null" /> +<TGConnectingPoint num="0" id="374" /> +</COMPONENT> + +<COMPONENT type="5104" id="355" > +<cdparam x="391" y="178" /> +<sizeparam width="65" height="20" minWidth="30" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Receive signal" value="valrec()" /> +<TGConnectingPoint num="0" id="356" /> +<TGConnectingPoint num="1" id="357" /> +<TGConnectingPoint num="2" id="358" /> +<TGConnectingPoint num="3" id="359" /> +<TGConnectingPoint num="4" id="360" /> +<TGConnectingPoint num="5" id="361" /> +<TGConnectingPoint num="6" id="362" /> +<TGConnectingPoint num="7" id="363" /> +<TGConnectingPoint num="8" id="364" /> +<TGConnectingPoint num="9" id="365" /> +</COMPONENT> + +<COMPONENT type="5106" id="307" > +<cdparam x="392" y="89" /> +<sizeparam width="100" height="50" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="State" value="state0" /> +<TGConnectingPoint num="0" id="308" /> +<TGConnectingPoint num="1" id="309" /> +<TGConnectingPoint num="2" id="310" /> +<TGConnectingPoint num="3" id="311" /> +<TGConnectingPoint num="4" id="312" /> +<TGConnectingPoint num="5" id="313" /> +<TGConnectingPoint num="6" id="314" /> +<TGConnectingPoint num="7" id="315" /> +<TGConnectingPoint num="8" id="316" /> +<TGConnectingPoint num="9" id="317" /> +<TGConnectingPoint num="10" id="318" /> +<TGConnectingPoint num="11" id="319" /> +<TGConnectingPoint num="12" id="320" /> +<TGConnectingPoint num="13" id="321" /> +<TGConnectingPoint num="14" id="322" /> +<TGConnectingPoint num="15" id="323" /> +<TGConnectingPoint num="16" id="324" /> +<TGConnectingPoint num="17" id="325" /> +<TGConnectingPoint num="18" id="326" /> +<TGConnectingPoint num="19" id="327" /> +<TGConnectingPoint num="20" id="328" /> +<TGConnectingPoint num="21" id="329" /> +<TGConnectingPoint num="22" id="330" /> +<TGConnectingPoint num="23" id="331" /> +<TGConnectingPoint num="24" id="332" /> +<TGConnectingPoint num="25" id="333" /> +<TGConnectingPoint num="26" id="334" /> +<TGConnectingPoint num="27" id="335" /> +<TGConnectingPoint num="28" id="336" /> +<TGConnectingPoint num="29" id="337" /> +<TGConnectingPoint num="30" id="338" /> +<TGConnectingPoint num="31" id="339" /> +<TGConnectingPoint num="32" id="340" /> +<TGConnectingPoint num="33" id="341" /> +<TGConnectingPoint num="34" id="342" /> +<TGConnectingPoint num="35" id="343" /> +<TGConnectingPoint num="36" id="344" /> +<TGConnectingPoint num="37" id="345" /> +<TGConnectingPoint num="38" id="346" /> +<TGConnectingPoint num="39" id="347" /> +<extraparam> +</extraparam> +</COMPONENT> + +<COMPONENT type="5100" id="54" > +<cdparam x="400" y="50" /> +<sizeparam width="15" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="start state" value="null" /> +<TGConnectingPoint num="0" id="53" /> +</COMPONENT> + +<CONNECTOR type="5102" id="348" > +<cdparam x="407" y="70" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="null" /> +<TGConnectingPoint num="0" id="349" /> +<P1 x="407" y="70" id="53" /> +<P2 x="392" y="89" id="308" /> +<AutomaticDrawing data="true" /> +</CONNECTOR><SUBCOMPONENT type="-1" id="350" > +<father id="348" num="0" /> +<cdparam x="408" y="79" /> +<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="List of all parameters of an Avatar SMD transition" value="" /> +<TGConnectingPoint num="0" id="351" /> +<TGConnectingPoint num="1" id="352" /> +<TGConnectingPoint num="2" id="353" /> +<TGConnectingPoint num="3" id="354" /> +<extraparam> +<guard value="[ ]" /> +<afterMin value="" /> +<afterMax value="" /> +<computeMin value="" /> +<computeMax value="" /> +</extraparam> +</SUBCOMPONENT> + +<CONNECTOR type="5102" id="366" > +<cdparam x="429" y="139" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="null" /> +<TGConnectingPoint num="0" id="367" /> +<P1 x="429" y="139" id="337" /> +<P2 x="423" y="173" id="356" /> +<AutomaticDrawing data="true" /> +</CONNECTOR><SUBCOMPONENT type="-1" id="368" > +<father id="366" num="0" /> +<cdparam x="426" y="156" /> +<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="List of all parameters of an Avatar SMD transition" value="" /> +<TGConnectingPoint num="0" id="369" /> +<TGConnectingPoint num="1" id="370" /> +<TGConnectingPoint num="2" id="371" /> +<TGConnectingPoint num="3" id="372" /> +<extraparam> +<guard value="[ ]" /> +<afterMin value="" /> +<afterMax value="" /> +<computeMin value="" /> +<computeMax value="" /> +</extraparam> +</SUBCOMPONENT> + +<CONNECTOR type="5102" id="375" > +<cdparam x="423" y="203" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="null" /> +<TGConnectingPoint num="0" id="376" /> +<P1 x="423" y="203" id="357" /> +<P2 x="428" y="208" id="374" /> +<AutomaticDrawing data="true" /> +</CONNECTOR><SUBCOMPONENT type="-1" id="377" > +<father id="375" num="0" /> +<cdparam x="425" y="205" /> +<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="List of all parameters of an Avatar SMD transition" value="" /> +<TGConnectingPoint num="0" id="378" /> +<TGConnectingPoint num="1" id="379" /> +<TGConnectingPoint num="2" id="380" /> +<TGConnectingPoint num="3" id="381" /> +<extraparam> +<guard value="[ ]" /> +<afterMin value="" /> +<afterMax value="" /> +<computeMin value="" /> +<computeMax value="" /> +</extraparam> +</SUBCOMPONENT> + + +</AVATARStateMachineDiagramPanel> + +<AVATARStateMachineDiagramPanel name="Block0" minX="10" maxX="2500" minY="10" maxY="1500" > +<CONNECTOR type="5102" id="61" > +<cdparam x="407" y="70" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="null" /> +<TGConnectingPoint num="0" id="60" /> +<P1 x="407" y="70" id="130" /> +<P2 x="403" y="85" id="89" /> +<AutomaticDrawing data="true" /> +</CONNECTOR><SUBCOMPONENT type="-1" id="59" > +<father id="61" num="0" /> +<cdparam x="405" y="77" /> +<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="List of all parameters of an Avatar SMD transition" value="" /> +<TGConnectingPoint num="0" id="55" /> +<TGConnectingPoint num="1" id="56" /> +<TGConnectingPoint num="2" id="57" /> +<TGConnectingPoint num="3" id="58" /> +<extraparam> +<guard value="[ ]" /> +<afterMin value="" /> +<afterMax value="" /> +<computeMin value="" /> +<computeMax value="" /> +</extraparam> +</SUBCOMPONENT> + +<CONNECTOR type="5102" id="68" > +<cdparam x="453" y="135" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="null" /> +<TGConnectingPoint num="0" id="67" /> +<P1 x="453" y="135" id="95" /> +<P2 x="454" y="169" id="78" /> +<AutomaticDrawing data="true" /> +</CONNECTOR><SUBCOMPONENT type="-1" id="66" > +<father id="68" num="0" /> +<cdparam x="453" y="152" /> +<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="List of all parameters of an Avatar SMD transition" value="" /> +<TGConnectingPoint num="0" id="62" /> +<TGConnectingPoint num="1" id="63" /> +<TGConnectingPoint num="2" id="64" /> +<TGConnectingPoint num="3" id="65" /> +<extraparam> +<guard value="[ ]" /> +<afterMin value="" /> +<afterMax value="" /> +<computeMin value="" /> +<computeMax value="" /> +</extraparam> +</SUBCOMPONENT> + +<CONNECTOR type="5102" id="75" > +<cdparam x="454" y="199" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="null" /> +<TGConnectingPoint num="0" id="74" /> +<P1 x="454" y="199" id="79" /> +<P2 x="462" y="203" id="76" /> +<AutomaticDrawing data="true" /> +</CONNECTOR><SUBCOMPONENT type="-1" id="73" > +<father id="75" num="0" /> +<cdparam x="458" y="201" /> +<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="List of all parameters of an Avatar SMD transition" value="" /> +<TGConnectingPoint num="0" id="69" /> +<TGConnectingPoint num="1" id="70" /> +<TGConnectingPoint num="2" id="71" /> +<TGConnectingPoint num="3" id="72" /> +<extraparam> +<guard value="[ ]" /> +<afterMin value="" /> +<afterMax value="" /> +<computeMin value="" /> +<computeMax value="" /> +</extraparam> +</SUBCOMPONENT> + +<COMPONENT type="5101" id="77" > +<cdparam x="452" y="208" /> +<sizeparam width="20" height="20" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="stop state" value="null" /> +<TGConnectingPoint num="0" id="76" /> +</COMPONENT> + +<COMPONENT type="5103" id="88" > +<cdparam x="435" y="174" /> +<sizeparam width="38" height="20" minWidth="30" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Send signal" value="val()" /> +<TGConnectingPoint num="0" id="78" /> +<TGConnectingPoint num="1" id="79" /> +<TGConnectingPoint num="2" id="80" /> +<TGConnectingPoint num="3" id="81" /> +<TGConnectingPoint num="4" id="82" /> +<TGConnectingPoint num="5" id="83" /> +<TGConnectingPoint num="6" id="84" /> +<TGConnectingPoint num="7" id="85" /> +<TGConnectingPoint num="8" id="86" /> +<TGConnectingPoint num="9" id="87" /> +</COMPONENT> + +<COMPONENT type="5106" id="129" > +<cdparam x="403" y="85" /> +<sizeparam width="100" height="50" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="State" value="state0" /> +<TGConnectingPoint num="0" id="89" /> +<TGConnectingPoint num="1" id="90" /> +<TGConnectingPoint num="2" id="91" /> +<TGConnectingPoint num="3" id="92" /> +<TGConnectingPoint num="4" id="93" /> +<TGConnectingPoint num="5" id="94" /> +<TGConnectingPoint num="6" id="95" /> +<TGConnectingPoint num="7" id="96" /> +<TGConnectingPoint num="8" id="97" /> +<TGConnectingPoint num="9" id="98" /> +<TGConnectingPoint num="10" id="99" /> +<TGConnectingPoint num="11" id="100" /> +<TGConnectingPoint num="12" id="101" /> +<TGConnectingPoint num="13" id="102" /> +<TGConnectingPoint num="14" id="103" /> +<TGConnectingPoint num="15" id="104" /> +<TGConnectingPoint num="16" id="105" /> +<TGConnectingPoint num="17" id="106" /> +<TGConnectingPoint num="18" id="107" /> +<TGConnectingPoint num="19" id="108" /> +<TGConnectingPoint num="20" id="109" /> +<TGConnectingPoint num="21" id="110" /> +<TGConnectingPoint num="22" id="111" /> +<TGConnectingPoint num="23" id="112" /> +<TGConnectingPoint num="24" id="113" /> +<TGConnectingPoint num="25" id="114" /> +<TGConnectingPoint num="26" id="115" /> +<TGConnectingPoint num="27" id="116" /> +<TGConnectingPoint num="28" id="117" /> +<TGConnectingPoint num="29" id="118" /> +<TGConnectingPoint num="30" id="119" /> +<TGConnectingPoint num="31" id="120" /> +<TGConnectingPoint num="32" id="121" /> +<TGConnectingPoint num="33" id="122" /> +<TGConnectingPoint num="34" id="123" /> +<TGConnectingPoint num="35" id="124" /> +<TGConnectingPoint num="36" id="125" /> +<TGConnectingPoint num="37" id="126" /> +<TGConnectingPoint num="38" id="127" /> +<TGConnectingPoint num="39" id="128" /> +<extraparam> +</extraparam> +</COMPONENT> + +<COMPONENT type="5100" id="131" > +<cdparam x="400" y="50" /> +<sizeparam width="15" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="start state" value="null" /> +<TGConnectingPoint num="0" id="130" /> +</COMPONENT> + + +</AVATARStateMachineDiagramPanel> + +</Modeling> + + + + +<Modeling type="ADD" nameTab="Deployment" > +<ADDDiagramPanel name="Deployment Diagram" minX="10" maxX="2500" minY="10" maxY="1500" attributes="0" masterClockFrequency="200" > +<COMPONENT type="5352" id="140" > +<cdparam x="332" y="84" /> +<sizeparam width="124" height="40" minWidth="75" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="TGComponent" value="Design::Block0" /> +<TGConnectingPoint num="0" id="132" /> +<TGConnectingPoint num="1" id="133" /> +<TGConnectingPoint num="2" id="134" /> +<TGConnectingPoint num="3" id="135" /> +<TGConnectingPoint num="4" id="136" /> +<TGConnectingPoint num="5" id="137" /> +<TGConnectingPoint num="6" id="138" /> +<TGConnectingPoint num="7" id="139" /> +<extraparam> +<info value="Design::Block0" taskName="Block0" referenceTaskName="Design" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5360" id="165" > +<cdparam x="300" y="18" /> +<sizeparam width="200" height="200" minWidth="100" minHeight="50" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Copro0" value="name" /> +<TGConnectingPoint num="0" id="141" /> +<TGConnectingPoint num="1" id="142" /> +<TGConnectingPoint num="2" id="143" /> +<TGConnectingPoint num="3" id="144" /> +<TGConnectingPoint num="4" id="145" /> +<TGConnectingPoint num="5" id="146" /> +<TGConnectingPoint num="6" id="147" /> +<TGConnectingPoint num="7" id="148" /> +<TGConnectingPoint num="8" id="149" /> +<TGConnectingPoint num="9" id="150" /> +<TGConnectingPoint num="10" id="151" /> +<TGConnectingPoint num="11" id="152" /> +<TGConnectingPoint num="12" id="153" /> +<TGConnectingPoint num="13" id="154" /> +<TGConnectingPoint num="14" id="155" /> +<TGConnectingPoint num="15" id="156" /> +<TGConnectingPoint num="16" id="157" /> +<TGConnectingPoint num="17" id="158" /> +<TGConnectingPoint num="18" id="159" /> +<TGConnectingPoint num="19" id="160" /> +<TGConnectingPoint num="20" id="161" /> +<TGConnectingPoint num="21" id="162" /> +<TGConnectingPoint num="22" id="163" /> +<TGConnectingPoint num="23" id="164" /> +<extraparam> +<info stereotype="MWMR-CoPro" nodeName="Copro0" /> +<attributes srcid="0" tgtid="0" plaps="0" fifoToCoprocDepth="0" fifoFromCoprocDepth="0" nToCopro="0" nFromCopro="0" nConfig="0" nStatus="0" useLLSC="false" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5354" id="190" > +<cdparam x="38" y="187" /> +<sizeparam width="177" height="157" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="TTY0" value="name" /> +<TGConnectingPoint num="0" id="166" /> +<TGConnectingPoint num="1" id="167" /> +<TGConnectingPoint num="2" id="168" /> +<TGConnectingPoint num="3" id="169" /> +<TGConnectingPoint num="4" id="170" /> +<TGConnectingPoint num="5" id="171" /> +<TGConnectingPoint num="6" id="172" /> +<TGConnectingPoint num="7" id="173" /> +<TGConnectingPoint num="8" id="174" /> +<TGConnectingPoint num="9" id="175" /> +<TGConnectingPoint num="10" id="176" /> +<TGConnectingPoint num="11" id="177" /> +<TGConnectingPoint num="12" id="178" /> +<TGConnectingPoint num="13" id="179" /> +<TGConnectingPoint num="14" id="180" /> +<TGConnectingPoint num="15" id="181" /> +<TGConnectingPoint num="16" id="182" /> +<TGConnectingPoint num="17" id="183" /> +<TGConnectingPoint num="18" id="184" /> +<TGConnectingPoint num="19" id="185" /> +<TGConnectingPoint num="20" id="186" /> +<TGConnectingPoint num="21" id="187" /> +<TGConnectingPoint num="22" id="188" /> +<TGConnectingPoint num="23" id="189" /> +<extraparam> +<info stereotype="TTY" nodeName="TTY0" /> +<attributes index="0" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5363" id="215" > +<cdparam x="313" y="270" /> +<sizeparam width="250" height="50" minWidth="100" minHeight="50" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Vgmn0" value="name" /> +<TGConnectingPoint num="0" id="191" /> +<TGConnectingPoint num="1" id="192" /> +<TGConnectingPoint num="2" id="193" /> +<TGConnectingPoint num="3" id="194" /> +<TGConnectingPoint num="4" id="195" /> +<TGConnectingPoint num="5" id="196" /> +<TGConnectingPoint num="6" id="197" /> +<TGConnectingPoint num="7" id="198" /> +<TGConnectingPoint num="8" id="199" /> +<TGConnectingPoint num="9" id="200" /> +<TGConnectingPoint num="10" id="201" /> +<TGConnectingPoint num="11" id="202" /> +<TGConnectingPoint num="12" id="203" /> +<TGConnectingPoint num="13" id="204" /> +<TGConnectingPoint num="14" id="205" /> +<TGConnectingPoint num="15" id="206" /> +<TGConnectingPoint num="16" id="207" /> +<TGConnectingPoint num="17" id="208" /> +<TGConnectingPoint num="18" id="209" /> +<TGConnectingPoint num="19" id="210" /> +<TGConnectingPoint num="20" id="211" /> +<TGConnectingPoint num="21" id="212" /> +<TGConnectingPoint num="22" id="213" /> +<TGConnectingPoint num="23" id="214" /> +<extraparam> +<info stereotype="VGMN" nodeName="Vgmn0" /> +<attributes index="0" nbOfAttachedInitiators="0" nbOfAttachedTargets="0" minLatency="10" fifoDepth="8" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5355" id="249" > +<cdparam x="218" y="377" /> +<sizeparam width="200" height="200" minWidth="100" minHeight="35" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Memory0" value="name" /> +<TGConnectingPoint num="0" id="225" /> +<TGConnectingPoint num="1" id="226" /> +<TGConnectingPoint num="2" id="227" /> +<TGConnectingPoint num="3" id="228" /> +<TGConnectingPoint num="4" id="229" /> +<TGConnectingPoint num="5" id="230" /> +<TGConnectingPoint num="6" id="231" /> +<TGConnectingPoint num="7" id="232" /> +<TGConnectingPoint num="8" id="233" /> +<TGConnectingPoint num="9" id="234" /> +<TGConnectingPoint num="10" id="235" /> +<TGConnectingPoint num="11" id="236" /> +<TGConnectingPoint num="12" id="237" /> +<TGConnectingPoint num="13" id="238" /> +<TGConnectingPoint num="14" id="239" /> +<TGConnectingPoint num="15" id="240" /> +<TGConnectingPoint num="16" id="241" /> +<TGConnectingPoint num="17" id="242" /> +<TGConnectingPoint num="18" id="243" /> +<TGConnectingPoint num="19" id="244" /> +<TGConnectingPoint num="20" id="245" /> +<TGConnectingPoint num="21" id="246" /> +<TGConnectingPoint num="22" id="247" /> +<TGConnectingPoint num="23" id="248" /> +<extraparam> +<info stereotype="RAM" nodeName="Memory0" /> +<attributes byteDataSize="65536" index="0" /> +</extraparam> +</COMPONENT> +<SUBCOMPONENT type="5362" id="224" > +<father id="249" num="0" /> +<cdparam x="261" y="464" /> +<sizeparam width="122" height="40" minWidth="75" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="0" maxX="78" minY="0" maxY="160" /> +<infoparam name="TGComponent" value="Block0/out val" /> +<TGConnectingPoint num="0" id="216" /> +<TGConnectingPoint num="1" id="217" /> +<TGConnectingPoint num="2" id="218" /> +<TGConnectingPoint num="3" id="219" /> +<TGConnectingPoint num="4" id="220" /> +<TGConnectingPoint num="5" id="221" /> +<TGConnectingPoint num="6" id="222" /> +<TGConnectingPoint num="7" id="223" /> +<extraparam> +<info value="Block0/out val" channelName="Block0/out val() #--# Block1/in valrec()" fullChannelName="Design::Block0/out val() #--# Block1/in valrec()" referenceDiagram="Design" /> +</extraparam> +</SUBCOMPONENT> + +<COMPONENT type="5351" id="283" > +<cdparam x="578" y="43" /> +<sizeparam width="250" height="200" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="CPU0" value="name" /> +<TGConnectingPoint num="0" id="259" /> +<TGConnectingPoint num="1" id="260" /> +<TGConnectingPoint num="2" id="261" /> +<TGConnectingPoint num="3" id="262" /> +<TGConnectingPoint num="4" id="263" /> +<TGConnectingPoint num="5" id="264" /> +<TGConnectingPoint num="6" id="265" /> +<TGConnectingPoint num="7" id="266" /> +<TGConnectingPoint num="8" id="267" /> +<TGConnectingPoint num="9" id="268" /> +<TGConnectingPoint num="10" id="269" /> +<TGConnectingPoint num="11" id="270" /> +<TGConnectingPoint num="12" id="271" /> +<TGConnectingPoint num="13" id="272" /> +<TGConnectingPoint num="14" id="273" /> +<TGConnectingPoint num="15" id="274" /> +<TGConnectingPoint num="16" id="275" /> +<TGConnectingPoint num="17" id="276" /> +<TGConnectingPoint num="18" id="277" /> +<TGConnectingPoint num="19" id="278" /> +<TGConnectingPoint num="20" id="279" /> +<TGConnectingPoint num="21" id="280" /> +<TGConnectingPoint num="22" id="281" /> +<TGConnectingPoint num="23" id="282" /> +<extraparam> +<info stereotype="CPU" nodeName="CPU0" /> +<attributes nbOfIrq="6" iCacheWays="8" iCacheSets="1" iCacheWords="4" dCacheWays="8" dCacheSets="1" dCacheWords="4" /> +</extraparam> +</COMPONENT> +<SUBCOMPONENT type="5352" id="258" > +<father id="283" num="0" /> +<cdparam x="631" y="98" /> +<sizeparam width="123" height="40" minWidth="75" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="0" maxX="127" minY="0" maxY="160" /> +<infoparam name="TGComponent" value="Design::Block1" /> +<TGConnectingPoint num="0" id="250" /> +<TGConnectingPoint num="1" id="251" /> +<TGConnectingPoint num="2" id="252" /> +<TGConnectingPoint num="3" id="253" /> +<TGConnectingPoint num="4" id="254" /> +<TGConnectingPoint num="5" id="255" /> +<TGConnectingPoint num="6" id="256" /> +<TGConnectingPoint num="7" id="257" /> +<extraparam> +<info value="Design::Block1" taskName="Block1" referenceTaskName="Design" /> +</extraparam> +</SUBCOMPONENT> + +<CONNECTOR type="5350" id="284" > +<cdparam x="369" y="223" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="{info}" /> +<P1 x="400" y="218" id="147" /> +<P2 x="438" y="270" id="192" /> +<AutomaticDrawing data="true" /> +<extraparam> +<spy value="false" /> +</extraparam> +</CONNECTOR> +<CONNECTOR type="5350" id="285" > +<cdparam x="703" y="243" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="{info}" /> +<P1 x="703" y="243" id="265" /> +<P2 x="563" y="282" id="202" /> +<AutomaticDrawing data="true" /> +<extraparam> +<spy value="false" /> +</extraparam> +</CONNECTOR> +<CONNECTOR type="5350" id="286" > +<cdparam x="318" y="377" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="{info}" /> +<P1 x="318" y="377" id="226" /> +<P2 x="375" y="320" id="205" /> +<AutomaticDrawing data="true" /> +<extraparam> +<spy value="false" /> +</extraparam> +</CONNECTOR> +<CONNECTOR type="5350" id="287" > +<cdparam x="215" y="265" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="{info}" /> +<P1 x="215" y="265" id="170" /> +<P2 x="313" y="282" id="201" /> +<AutomaticDrawing data="true" /> +<extraparam> +<spy value="false" /> +</extraparam> +</CONNECTOR> + +</ADDDiagramPanel> + +</Modeling> + + + + +</TURTLEGMODELING> \ No newline at end of file diff --git a/src/main/java/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java b/src/main/java/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java index b4f2edf4d80629425e12956a75eed7be4fbe62a0..87693017daec44592b4272706cb5176c8120f6a3 100755 --- a/src/main/java/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java +++ b/src/main/java/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java @@ -43,6 +43,7 @@ package ddtranslatorSoclib.toSoclib; import avatartranslator.*; import ddtranslatorSoclib.AvatarRAM; +import ddtranslatorSoclib.AvatarCoproMWMR; import ddtranslatorSoclib.AvatarTask; import ddtranslatorSoclib.AvatarddSpecification; import ddtranslatorSoclib.toTopCell.TopCellGenerator; @@ -1033,8 +1034,7 @@ public class TasksAndMainGenerator { mainFile.appendToMainCode("/* Activating randomness */" + CR); mainFile.appendToMainCode("initRandom();" + CR); - /* DG 7.9.2017 additions for use of hardware MWMR controller */ - + /* Use of hardware MWMR controller */ /*void mwmr_hw_init( void *coproc, enum SoclibMwmrWay way, size_t no, const struct mwmr_s* mwmr );*/ @@ -1044,14 +1044,78 @@ public class TasksAndMainGenerator { /* mwmr_t *p_mwmr_in = (mwmr_t*)(base(MWMRd)+0x1000);*/ -/*mwmr_initialize_pointer(p_mwmr_in, WIDTH, DEPTH, fifo_data_in, lock_in );*/ + /*mwmr_initialize_pointer(p_mwmr_in, WIDTH, DEPTH, fifo_data_in, lock_in );*/ + + /* mwmr_hw_init(base(MWMR), MWMR_TO_COPROC, 0 , p_mwmr_in);*/ + + /*for all coproc + uint32_t *fifo = (uint32_t*) + i*4096;*/ + + //DG 11.09. + int width = 4; //nb_params;//ToDo -/* mwmr_hw_init(base(MWMR), MWMR_TO_COPROC, 0 , p_mwmr_in);*/ + int i=0; + int MWMRd_SIZE=12288; + + for (AvatarCoproMWMR copro : TopCellGenerator.avatardd.getAllCoproMWMR()){ + + for(AvatarRelation ar: avspec.getRelations()) { + + if(ar.nbOfSignals()!=0){ + for(i=0; i<ar.nbOfSignals() ; i++) { + if(((ar.block1.getName()==copro.getName())||(ar.block2.getName()==copro.getName()))){ + + + mainFile.appendToMainCode("uint32_t *fifo_data"+i+"=(uint32_t*)(0x"+Integer.toHexString(538968064+MWMRd_SIZE*i)+");"+CR); + //one single RAMLOCKS, fixed address + mainFile.appendToMainCode("uint32_t *fifo_lock"+i+"= (uint32_t*)("+0x1A200000+");"+CR); + mainFile.appendToMainCode("mwmr_t *"+getChannelName(ar, i)+" = (mwmr_t*)(0x"+Integer.toHexString(538968064+MWMRd_SIZE*i)+");"+CR); + //depth 100 per default, to be changed later + + mainFile.appendToMainCode("mwmr_initialize_pointer("+getChannelName(ar, i)+","+(width*4)+", 100, fifo_data"+i+",fifo_lock"+i+");"+CR); + + //DG 10.09. il faut encore associer p_mwmr_i avec le canal dans le main.c + //mainFile.appendToBeforeMainCode("struct mwmr_s "+getChannelName(ar, i) +" CHANNEL"+k+";" + CR2); + i++; + } + } + } + } + } + + i=0; + int MWMR_SIZE=4096; + + for (AvatarCoproMWMR copro : TopCellGenerator.avatardd.getAllCoproMWMR()){ + + for(AvatarRelation ar: avspec.getRelations()) { + + if(ar.nbOfSignals()!=0){ + for(i=0; i<ar.nbOfSignals() ; i++) { + // detect if there is a coprocessors implicated in the FIFO MWMR communication + //in this case we have to address the hardware wrapper rather than the software channel + + if(((ar.block1.getName()==copro.getName())||(ar.block2.getName()==copro.getName()))){ + + // 0 = MWMR_FROM_COPROC = READ + // 1 = MWMR_FROM_COPROC = WRITE + //distinguish incoming and outgoing FIFOs + + AvatarSignal sig = ar.getSignal1(i); + if(sig.isIn()){ + mainFile.appendToMainCode("mwmr_hw_init(0xA0"+ Integer.toHexString(2097152+MWMR_SIZE*i)+","+ 0 +",1,"+getChannelName(ar, i)+");"+CR); + } + else{ //sig.isOut() + mainFile.appendToMainCode("mwmr_hw_init(0xA0"+ Integer.toHexString(2097152+MWMR_SIZE*i)+","+ 0 +",0,"+getChannelName(ar, i)+");"+CR); + } + i++; + } + } + } + } + } -/*for all coproc - uint32_t *fifo = (uint32_t*) + i*4096;*/ -/* end ajoute 7.9. */ mainFile.appendToMainCode("/* Initializing the main mutex */" + CR); mainFile.appendToMainCode("if (pthread_mutex_init(&__mainMutex, NULL) < 0) { exit(-1);}" + CR + CR); @@ -1073,7 +1137,7 @@ public class TasksAndMainGenerator { String channelString= ""; int j=0; for(AvatarRelation ar: avspec.getRelations()) { - int i; + // int i; if(ar.nbOfSignals()!=0){ for(i=0; i<ar.nbOfSignals() ; i++) { diff --git a/src/main/java/ddtranslatorSoclib/toTopCell/MappingTable.java b/src/main/java/ddtranslatorSoclib/toTopCell/MappingTable.java index 871c0b60449c6d65f119965bbd5a17b24dc5eba5..360ee2b1826baa8c8a03ea966ef825c35bff39e1 100755 --- a/src/main/java/ddtranslatorSoclib/toTopCell/MappingTable.java +++ b/src/main/java/ddtranslatorSoclib/toTopCell/MappingTable.java @@ -171,21 +171,19 @@ public class MappingTable { /* Instanciation of the MWMR wrappers for hardware accellerators */ /* The accelerators themselves are specifies on DIPLODOCUS level */ - + int count = l+5; int hwa_count=0; int MWMR_SIZE=4096; + int MWMRd_SIZE=12288; // int MWMR_BASE=0xA0200000; i=0; for (AvatarCoproMWMR MWMRwrapper : TopCellGenerator.avatardd.getAllCoproMWMR()) { - mapping += "maptab.add(Segment(\"mwmr_ram"+hwa_count+"\", 0xA0"+ Integer.toHexString(2097152+MWMR_SIZE*i)+", 0x00001000, IntTab("+(l+5+hwa_count)+"), false));" + CR; - hwa_count++; + mapping += "maptab.add(Segment(\"mwmr_ram"+hwa_count+"\", 0xA0"+ Integer.toHexString(2097152+MWMR_SIZE*i)+", 0x00001000, IntTab("+count+"), false));" + CR; + mapping += "maptab.add(Segment(\"mwmrd_ram"+hwa_count+"\", 0x20"+ Integer.toHexString(2097152+MWMRd_SIZE*i)+", 0x00003000, IntTab("+(count+1)+"), false));" + CR; + hwa_count++; + count+=2; } - hwa_count=0; - /* - for (AvatarCoproMWMR MWMRwrapper : TopCellGenerator.avatardd.getAllCoproMWMR()) { - mapping += "maptab.add(Segment(\"mwmr_ram"+hwa_count+"\", 0x"+(Integer.toHexString(MWMRd_BASE+i*4096))+", 0x"+Integer.toHexString(MWMRd_SIZE)+", IntTab("+(l+5+hwa_count)+"), false));" + CR2; - hwa_count++; - } */ + hwa_count=0; return mapping; } diff --git a/src/main/java/ddtranslatorSoclib/toTopCell/NetList.java b/src/main/java/ddtranslatorSoclib/toTopCell/NetList.java index 5299c2125def2d1157fdf37d45d25b4d8313a73f..75262fe7f6e99bfa0f0201038be4c9c74f90f89c 100755 --- a/src/main/java/ddtranslatorSoclib/toTopCell/NetList.java +++ b/src/main/java/ddtranslatorSoclib/toTopCell/NetList.java @@ -222,18 +222,47 @@ public class NetList { } if(nb_clusters==0){ - /* we can have several TTYs and each is associated to the fdtrom */ - if(icn=="vgmn"){ + // we can have several TTYs and each is associated to the fdtrom + + /* if(icn=="vgmn"){ netlist = netlist + "vgmn.p_to_target["+(TopCellGenerator.avatardd.getNb_target())+"](signal_vci_vcifdaccesst);" + CR; netlist = netlist + "vgmn.p_to_target["+(TopCellGenerator.avatardd.getNb_target()+1)+"](signal_vci_ethernett);" + CR; netlist = netlist + "vgmn.p_to_target["+(TopCellGenerator.avatardd.getNb_target()+2)+"](signal_vci_bdt);" + CR; netlist = netlist + "vgmn.p_to_target["+(TopCellGenerator.avatardd.getNb_target()+3)+"](signal_vci_vcilocks);" + CR; - }else{ /* vgsb */ + }else{ //vgsb netlist = netlist + "vgsb.p_to_target["+(TopCellGenerator.avatardd.getNb_target())+"](signal_vci_vcifdaccesst);" + CR; netlist = netlist + "vgsb.p_to_target["+(TopCellGenerator.avatardd.getNb_target()+1)+"](signal_vci_ethernett);" + CR; netlist = netlist + "vgsb.p_to_target["+(TopCellGenerator.avatardd.getNb_target()+2)+"](signal_vci_bdt);" + CR; netlist = netlist + "vgsb.p_to_target["+(TopCellGenerator.avatardd.getNb_target()+3)+"](signal_vci_vcilocks);" + CR; - } + }*/ + + int l=8; //number of last tty ToDo + if(icn=="vgmn"){ + netlist = netlist + "vgmn.p_to_target["+(l)+"](signal_vci_vcifdaccesst);" + CR; + netlist = netlist + "vgmn.p_to_target["+(l+1)+"](signal_vci_ethernett);" + CR; + netlist = netlist + "vgmn.p_to_target["+(l+2)+"](signal_vci_bdt);" + CR; + netlist = netlist + "vgmn.p_to_target["+(l+3)+"](signal_vci_vcilocks);" + CR; + int i; + //DG 14.09. + int coproc_count=0; + for(i=0;i<coproc_count;i++){ + + netlist = netlist + "vgmn.p_to_target["+(l+4+i)+"](signal_mwmr_"+i+"_target);" + CR; + } + }else{ //vgsb + netlist = netlist + "vgsb.p_to_target["+(l)+"](signal_vci_vcifdaccesst);" + CR; + netlist = netlist + "vgsb.p_to_target["+(l+1)+"](signal_vci_ethernett);" + CR; + netlist = netlist + "vgsb.p_to_target["+(l+2)+"](signal_vci_bdt);" + CR; + netlist = netlist + "vgsb.p_to_target["+(l+3)+"](signal_vci_vcilocks);" + CR; + + //DG 14.09. + int coproc_count=0; + int i; + for(i=0;i<coproc_count;i++){ + netlist = netlist + "vgmn.p_to_target["+(l+4+i)+"](signal_mwmr_"+i+"_target);" + CR; + } + } + }else{ /* cluster case */ if(icn=="vgmn"){ @@ -340,6 +369,8 @@ public class NetList { ////////////////MWMR controller; hypothesis 1 per coprocessor // if(nb_cluster == 0){ i=0; + int coproc_count=0; + for (AvatarCoproMWMR copro : TopCellGenerator.avatardd.getAllCoproMWMR()){ //a coprocessor with its FIFO interface built from HWA netlist = netlist +"hwa"+i+".p_clk(signal_clk);" + CR; @@ -358,6 +389,7 @@ netlist = netlist +copro.getCoprocName() +".p_to_coproc["+i+"](signal_fifo_"+i+" // netlist = netlist +copro.getCoprocName() +".status();" + CR; // netlist = netlist +copro.getCoprocName() +".config();" + CR; i++; +coproc_count++; } diff --git a/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSBlocks.java b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSBlocks.java new file mode 100755 index 0000000000000000000000000000000000000000..ad65f4379403da30d18310b78df84daf1ba57557 --- /dev/null +++ b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSBlocks.java @@ -0,0 +1,152 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package heterogeneoustranslator.systemCAMStranslator; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; +import java.util.Vector; +import ui.*; + +/** +* Class CAMSBlocks +* Simulation Block for SystemC-AMS Diagrams +* Creation: 28/08/2017 +* @version 1.0 28/08/2017 +* @author Côme DEMARIGNY + */ + +public class CAMSBlocks{ + + private String name; + private int nbOfIn; + private int nbOfOut; + private int nbOfHybridIn; + private int nbOfHybridOut; + private LinkedList<TAttribute> myAttributes; + private LinkedList<CAMSSignal> mySignals; + private String [] processCode; + + + public CAMSBlocks(String _name, int _nbOfIn, int _nbOfOut, int _nbOfHybridIn, int _nbOfHybridOut, LinkedList<TAttribute> _myAttributes, LinkedList<CAMSSignal> _mySignals, String [] _processCode){ + name=_name; + nbOfIn=_nbOfIn; + nbOfOut=_nbOfOut; + nbOfHybridIn=_nbOfHybridIn; + nbOfHybridOut=_nbOfHybridOut; + myAttributes=_myAttributes; + mySignals=_mySignals; + processCode=_processCode; + + } + + public void setBlockName(String newName){ + name = newName; + } + + public void setNbOfIn(int newIn){ + nbOfIn = newIn; + } + + public void setNbOfOut(int newOut){ + nbOfOut = newOut; + } + + public void setNbOfHybridIn(int newIn){ + nbOfHybridIn = newIn; + } + + public void setNbOfHybridOut(int newOut){ + nbOfHybridOut = newOut; + } + + public void setMyAttributes(LinkedList<TAttribute> newMyAttributes){ + myAttributes = newMyAttributes; + } + + public void setMySignals(LinkedList<CAMSSignal> newMySignals){ + mySignals = newMySignals; + } + + public void setProcessCode(String[] newProcessCode){ + processCode = newProcessCode; + } + + public String getBlockName(){ + return name; + } + + public int getNbOfIn() { + return nbOfIn; + } + + public int getNbOfOut() { + return nbOfOut; + } + public int getNbOfHybridIn() { + return nbOfHybridIn; + } + + public int getNbOfHybridOut() { + return nbOfHybridOut; + } + public int getTotalIn() { + return nbOfIn + nbOfHybridIn; + } + + public int getTotalOut() { + return nbOfOut + nbOfHybridOut; + } + + public LinkedList<TAttribute> getMyAttributes(){ + return myAttributes; + } + + public LinkedList<CAMSSignal> getMySignals(){ + return mySignals; + } + + public String[] getProcessCode(){ + return processCode; + } + +} \ No newline at end of file diff --git a/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSConnection.java b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSConnection.java new file mode 100755 index 0000000000000000000000000000000000000000..1d3961178b432a319805925dd62652b2361b01dc --- /dev/null +++ b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSConnection.java @@ -0,0 +1,78 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package heterogeneoustranslator.systemCAMStranslator; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; +import java.util.Vector; +import ui.*; + +/** +* Class CAMSConnection +* Connection beetwen blocks for SystemC-AMS Diagrams +* Creation: 30/08/2017 +* @version 1.0 30/08/2017 +* @author Côme DEMARIGNY + */ + +public class CAMSConnection{ + + public String name; + public CAMSBlocks inputBlock, outputBlock; + public int rate; + public int type; + + public CAMSConnection(CAMSBlocks _inputBlock, CAMSBlocks _outputBlock){ + inputBlock = _inputBlock; + outputBlock = _outputBlock; + } + + public CAMSBlocks getInputBlock(){ + return inputBlock; + } + + public CAMSBlocks getOutputBlock(){ + return outputBlock; + } + +} \ No newline at end of file diff --git a/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java new file mode 100755 index 0000000000000000000000000000000000000000..3c0cc72cb5908f9b89a137717286f44bdbde1aa9 --- /dev/null +++ b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java @@ -0,0 +1,111 @@ + /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package heterogeneoustranslator.systemCAMStranslator; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.het.*; +import ui.util.IconManager; +import ui.window.JDialogCAMSBlocks; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; +import java.util.Vector; + + +/** +* Class CAMSSignal +* Signals for SystemC-AMS Diagrams +* Creation: 27/06/2017 +* @version 1.0 27/06/2017 +* @author Côme DEMARIGNY + */ +public class CAMSSignal { + + public final static int IN = 0; + public final static int OUT= 1; + public final static int HYBRID_IN = 2; + public final static int HYBRID_OUT= 3; + public final static int INCORRECT=-1; + + private static int i=0; + + private String name; + + public int inout; + + public CAMSSignal (String _name, int _inout) { + inout = _inout; + } + + + public CAMSSignal makeclone(){ + return this; + } + + public static CAMSSignal isAValidSignal(String _name, int _inout) { + if (_inout==INCORRECT) { + return null; + } + String s = signalName(_name); + CAMSSignal cs = new CAMSSignal(s, _inout); + + return cs; + } + + public int getInout(){ + return inout; + } + + public static String signalName(String _n){ + String s=""; + s+= _n + ": " + signalID(); + return s; + } + + public static int signalID(){i++;return i;} + +} \ No newline at end of file diff --git a/src/main/java/ui/ActionPerformer.java b/src/main/java/ui/ActionPerformer.java index 3714467acd0159593bfe49ca38a113c2dc087e07..c4f7230d77076dcddbdba01067d86cb518bb50eb 100755 --- a/src/main/java/ui/ActionPerformer.java +++ b/src/main/java/ui/ActionPerformer.java @@ -839,8 +839,8 @@ public class ActionPerformer { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_BRIDGENODE); } else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_HWANODE].getActionCommand())) { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_HWANODE); - //} else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_CAMSNODE].getActionCommand())) { - //mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_CAMSNODE); + } else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_CAMSNODE].getActionCommand())) { + mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_CAMSNODE); } else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_MEMORYNODE].getActionCommand())) { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_MEMORYNODE); } else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_DMANODE].getActionCommand())) { @@ -895,12 +895,12 @@ public class ActionPerformer { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLSD_ACTION_STATE); //SystemC AMS - /*} else if (command.equals(mgui.actions[TGUIAction.CAMS_EDIT].getActionCommand())) { + } else if (command.equals(mgui.actions[TGUIAction.CAMS_EDIT].getActionCommand())) { mgui.actionOnButton(TGComponentManager.EDIT, -1); } else if (command.equals(mgui.actions[TGUIAction.CAMS_BLOCK].getActionCommand())) { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_BLOCK); } else if (command.equals(mgui.actions[TGUIAction.CAMS_CONNECTOR].getActionCommand())) { - mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_CONNECTOR);*/ + mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_CONNECTOR); // Attack Tree Diagrams } else if (command.equals(mgui.actions[TGUIAction.ATD_BLOCK].getActionCommand())) { diff --git a/src/main/java/ui/AttackTreePanel.java b/src/main/java/ui/AttackTreePanel.java index 04b66b7f6511388ebd23e9303389eacade9e70c2..2eedf505cfdcc45f7e9d8076794a9daf3d8f57cd 100755 --- a/src/main/java/ui/AttackTreePanel.java +++ b/src/main/java/ui/AttackTreePanel.java @@ -51,6 +51,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.*; import java.util.Iterator; +import java.util.ArrayList; /** * Class AttackTreePanel @@ -155,6 +156,20 @@ public class AttackTreePanel extends TURTLEPanel { return true; } + public ArrayList<TGComponent> getAllAttacks(){ + ArrayList<TGComponent> list = new ArrayList<TGComponent>(); + TDiagramPanel tp; + for(int i=0; i<panels.size(); i++) { + tp = panels.get(i); + if (tp instanceof AttackTreeDiagramPanel) { + for (TGComponent s:((AttackTreeDiagramPanel)tp).getAllAttacks()){ + list.add(s); + } + } + } + return list; + + } public void resetMetElements() { //TraceManager.addDev("Reset met elements"); TGComponent tgc; diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java index 15147592f8316ed826532a9f253d80de90b83377..09d1a9a57fe54c640ad0d2abdef70d653455068a 100755 --- a/src/main/java/ui/GTURTLEModeling.java +++ b/src/main/java/ui/GTURTLEModeling.java @@ -120,7 +120,7 @@ import ui.tmlcompd.*; import ui.tmlcp.TMLCPPanel; import ui.tmldd.*; import ui.tmlsd.TMLSDPanel; -//import ui.het.*; +import ui.het.*; import ui.tree.GraphTree; import ui.tree.InvariantDataTree; import ui.tree.SearchTree; @@ -6053,7 +6053,7 @@ public class GTURTLEModeling { } } - /*} else if (tdp instanceof CAMSBlockDiagramPanel) { //ajout CD 24.07----mark + } else if (tdp instanceof CAMSBlockDiagramPanel) { //ajout CD 24.07----mark nl = doc.getElementsByTagName("CAMSBlockDiagramPanelCopy"); if (nl == null) { @@ -6081,7 +6081,7 @@ public class GTURTLEModeling { camsp.structureChanged(); makePostLoading(camsp, beginIndex); } - }*/ + } } else if (tdp instanceof AvatarADPanel) { nl = doc.getElementsByTagName("AvatarADPanelCopy"); @@ -6283,8 +6283,8 @@ public class GTURTLEModeling { loadAvatarMethodology(node); } else if (type.compareTo("Sysmlsec Methodology") == 0) { loadSysmlsecMethodology(node); - /*} else if (type.compareTo("SystemC-AMS") == 0) { - loadSystemCAMS(node);*/ + } else if (type.compareTo("SystemC-AMS") == 0) { + loadSystemCAMS(node); } else if (type.compareTo("TML Design") == 0) { loadTMLDesign(node); } else if (type.compareTo("TML Component Design") == 0) { @@ -6789,7 +6789,7 @@ public class GTURTLEModeling { } } - /*public void loadSystemCAMS(Node node) throws MalformedModelingException, SAXException { + public void loadSystemCAMS(Node node) throws MalformedModelingException, SAXException { Element elt = (Element) node; String nameTab; NodeList diagramNl; @@ -6815,7 +6815,7 @@ public class GTURTLEModeling { } } } - }*/ + } public void loadTMLDesign(Node node) throws MalformedModelingException, SAXException { Element elt = (Element) node; @@ -7086,10 +7086,10 @@ public class GTURTLEModeling { ((AvatarADPanel)tdp).setConnectorsToFront(); } - /*if (tdp instanceof CAMSBlockDiagramPanel) { + if (tdp instanceof CAMSBlockDiagramPanel) { //TraceManager.addDev("Connectors..."); ((CAMSBlockDiagramPanel)tdp).setConnectorsToFront(); - }*/ + } } // AVATAR @@ -8994,7 +8994,7 @@ public class GTURTLEModeling { } } - //public boolean checkSyntaxSystemCAMS(Vector<TGComponent> blocksToTakeIntoAccount, SystemCAMSPanel scp, boolean optimize) { //ajout CD 04/07 FIXME + public boolean checkSyntaxSystemCAMS(Vector<TGComponent> blocksToTakeIntoAccount, SystemCAMSPanel scp, boolean optimize) { //ajout CD 04/07 FIXME // List<TMLError> warningsOptimize = new ArrayList<TMLError>(); // warnings = new LinkedList<CheckingError> (); // mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO); @@ -9023,9 +9023,9 @@ public class GTURTLEModeling { // mgui.resetAllDIPLOIDs(); // listE.useDIPLOIDs(); // mgui.setMode(MainGUI.GEN_DESIGN_OK); - //return true; + return true; // } - //} + } public boolean checkSyntaxTMLMapping(Vector<TGComponent> nodesToTakeIntoAccount, TMLArchiPanel tmlap, boolean optimize) { List<TMLError> warningsOptimize = new ArrayList<TMLError>(); diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index 49d2c6b0f12ac3ff51ccd766e4c664dc6c19c90f..3d72644cc0e857a8af2f220172f4e74357846c42 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -83,8 +83,9 @@ import ui.tmlcompd.TMLCCompositeComponent; import ui.tmlcompd.TMLComponentTaskDiagramPanel; import ui.tmlcp.TMLCPPanel; import ui.tmldd.TMLArchiDiagramPanel; +import ui.tmldd.TMLArchiCAMSNode; import ui.tmlsd.TMLSDPanel; -//import ui.het.*; +import ui.het.*; import ui.tree.DiagramTreeModel; import ui.tree.DiagramTreeRenderer; import ui.tree.JDiagramTree; @@ -989,8 +990,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe //ystem.out.println("Design added"); return index; } - - /*public int addSystemCAMSPanel(String name, int index) { //ajout CD -----Mark + + public int addSystemCAMSPanel(String name, int index) { //ajout CD -----Mark if (index == -1) { index = tabs.size(); } @@ -1018,7 +1019,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe mainTabbedPane.setIconAt(index, IconManager.imgic60); scp.init(); return scp.getCAMSBlockDiagramPanel(); - }*/ + } //Return the list of all the TMLArchiDiagramPanels public Vector<TMLArchiPanel> getTMLArchiDiagramPanels() { @@ -1395,11 +1396,11 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe return index; } - /*public int createSystemCAMS(String name) { //ajout CD + public int createSystemCAMS(String name) { //ajout CD int index = addSystemCAMSPanel(name, -1); mainTabbedPane.setSelectedIndex(index); return index; - }*/ + } public int createADD(String name) { int index = addADDPanel(name, -1); @@ -1774,14 +1775,14 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe //frame.repaint(); } - /*public void newSystemCAMS() {//ajout CD + public void newSystemCAMS() {//ajout CD //TraceManager.addDev("NEW DIPLO Architecture"); addSystemCAMSPanel("SystemC-AMS", -1); tabs.elementAt(tabs.size()-1).tabbedPane.setSelectedIndex(0); mainTabbedPane.setSelectedIndex(tabs.size()-1); //paneAction(null); //frame.repaint(); - }*/ + } public void newADD() { //TraceManager.addDev("NEW Avatar deployment"); @@ -3332,7 +3333,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe } } } - /*} else if (tp instanceof SystemCAMSPanel) { //Ajout CD + } else if (tp instanceof SystemCAMSPanel) { //Ajout CD SystemCAMSPanel camsp = (SystemCAMSPanel)tp; JDialogSelectSystemCAMSBlock.validated = camsp.validated; @@ -3367,7 +3368,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe JOptionPane.INFORMATION_MESSAGE); } } - }*/ + } } else if (tp instanceof TMLArchiPanel) { tmlap = (TMLArchiPanel)tp; @@ -3766,6 +3767,22 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe return list; } + public ArrayList<TGComponent> getAllAttacks(){ + TURTLEPanel tp; + ArrayList<TGComponent> list = new ArrayList<TGComponent>(); + + for(int i=0; i<tabs.size(); i++) { + tp = tabs.elementAt(i); + if (tp instanceof AttackTreePanel) { + for (TGComponent s:((AttackTreePanel)tp).getAllAttacks()){ + list.add(s); + } + } + } + return list; + + } + public ArrayList<TGComponent> getAllRequirements(){ TURTLEPanel tp; ArrayList<TGComponent> list = new ArrayList<TGComponent>(); @@ -8392,9 +8409,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe mgui.newAvatarMADs(); } else if (e.getSource() == newAVATARAnalysis) { mgui.newAvatarAnalysis(); - } /*else if (e.getSource() == newSystemCAMS) { //ajout CD + } else if (e.getSource() == newSystemCAMS) { //ajout CD mgui.newSystemCAMS(); - }*/ + } } }; } @@ -8403,7 +8420,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe /** * This adapter is constructed to handle mouse over component events. */ - private class MouseHandler extends MouseAdapter { + private class MouseHandler extends MouseAdapter { private JLabel label; diff --git a/src/main/java/ui/SystemCAMSPanel.java b/src/main/java/ui/SystemCAMSPanel.java new file mode 100755 index 0000000000000000000000000000000000000000..19587244f2999b9acaf9975317b845d3b20b6add --- /dev/null +++ b/src/main/java/ui/SystemCAMSPanel.java @@ -0,0 +1,140 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package ui; + +import myutil.GraphicLib; +import ui.het.CAMSBlockDiagramToolBar; +import ui.het.CAMSBlockDiagramPanel; +import ui.util.IconManager; +import ui.TDiagramPanel; +import ui.window.JDialogCAMSBlocks; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.util.Vector; + +/** + * Class SystemCAMSPanel + * Managenemt of TML architecture panels + * Creation: 23/06/2017 + * @version 0.1 23/06/2107 + * @author Côme DEMARIGNY + * @see MainGUI + */ +public class SystemCAMSPanel extends TURTLEPanel { + public SystemCAMSPanel scp; + public CAMSBlockDiagramPanel camsbdp; + public TURTLEPanel tp; + public TDiagramPanel tdp; + public Vector<TGComponent> validated, ignored; + + public SystemCAMSPanel(MainGUI _mgui) { + super(_mgui); + + tabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane(); + + cl = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e){ + mgui.paneDesignAction(e); + } + }; + tabbedPane.addChangeListener(cl); + tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui)); + } + + public void init() { + + // Class Diagram toolbar + CAMSBlockDiagramToolBar camstoolBar = new CAMSBlockDiagramToolBar(mgui); + toolbars.add(camstoolBar); + toolBarPanel = new JPanel(); + toolBarPanel.setLayout(new BorderLayout()); + + //Class Diagram Panel + camsbdp = new CAMSBlockDiagramPanel(mgui, camstoolBar); + camsbdp.setName("SystemC-AMS Diagram"); + + // Diagram toolbar + camsbdp.tp = this; + tp = scp; + panels.add(camsbdp); // Always first in list + JScrollDiagramPanel jsp = new JScrollDiagramPanel(camsbdp); + camsbdp.jsp = jsp; + jsp.setWheelScrollingEnabled(true); + jsp.getVerticalScrollBar().setUnitIncrement( MainGUI.INCREMENT ); + toolBarPanel.add(camstoolBar, BorderLayout.NORTH); + toolBarPanel.add(jsp, BorderLayout.CENTER); + tabbedPane.addTab("SystemC-AMS Diagram", IconManager.imgic60, toolBarPanel, "opens SystemC-AMS diagram"); + tabbedPane.setSelectedIndex(0); + mgui.changeMade(camsbdp, TDiagramPanel.NEW_COMPONENT); + + + } + + public String saveHeaderInXml(String extensionToName) { + if (extensionToName == null) { + return "<Modeling type=\"SystemC-AMS\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; + } + return "<Modeling type=\"SystemC-AMS\" nameTab=\"" + mgui.getTabName(this) + extensionToName +"\" >\n"; + } + + public String saveTailInXml() { + return "</Modeling>\n\n\n"; + } + + public String toString() { + return mgui.getTitleAt(this) + " (SystemC-AMS Diagram)"; + } + + public void renameMapping(String oldName, String newName) { + if (scp != null) { + scp.renameMapping(oldName, newName); + } + } + + public CAMSBlockDiagramPanel getCAMSBlockDiagramPanel(){ + return camsbdp; + } +} diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index b743fbc219d102d6ec723efe85035419a8e64879..377d6fd324798af19dcf7423aab2c3cc82c6ecb8 100755 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -62,7 +62,7 @@ import ui.tmlcd.TMLTaskOperator; import ui.tmlcompd.TMLCCompositeComponent; import ui.tmlcompd.TMLCPrimitiveComponent; import ui.tmlcompd.TMLCRecordComponent; -//import ui.het.*; +import ui.het.*; import ui.window.JDialogCode; import ui.window.JDialogNote; import ui.window.JDialogSearchBox; @@ -109,7 +109,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { protected List<TGComponent> componentList; protected TGConnectingPoint selectedConnectingPoint; - //protected CAMSConnectingPoint selectedCAMSConnectingPoints; + protected CAMSConnectingPoint selectedCAMSConnectingPoints; protected TGComponent componentPointed; protected TGComponent componentPopup; protected TToolBar ttb; @@ -178,7 +178,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { protected int y2; protected Vector<Point> listPoint; protected TGConnectingPoint p1, p2; - //protected CAMSConnectingPoint cp1, cp2; + protected CAMSConnectingPoint cp1, cp2; protected int type; // For component selection @@ -475,8 +475,8 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { if (this.javaVisible && (tgc.hasPostJavaCode () || tgc.hasPreJavaCode ())) tgc.drawJavaCode (g); - //if (this instanceof CAMSBlockDiagramPanel) //Connecting points should always be visible in System-C AMS panels - //tgc.drawTGConnectingPoint (g, this.type); + if (this instanceof CAMSBlockDiagramPanel) //Connecting points should always be visible in System-C AMS panels + tgc.drawTGConnectingPoint (g, this.type); } // Draw name of component selected @@ -907,9 +907,9 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { return selectedConnectingPoint; } - //public CAMSConnectingPoint getSelectedCAMSConnectingPoint(){ - //return selectedCAMSConnectingPoints; - //} + public CAMSConnectingPoint getSelectedCAMSConnectingPoint(){ + return selectedCAMSConnectingPoints; + } // Adding component public TGComponent addComponent(int x, int y, boolean swallow) { @@ -1050,7 +1050,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { listPoint = null; } - /*public void addingCAMSConnector() { + public void addingCAMSConnector() { listPoint = new Vector<Point>(); cp1 = getSelectedCAMSConnectingPoint(); x1 = cp1.getX(); y1 = cp1.getY(); @@ -1086,7 +1086,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { stopAddingConnector(true); cp1.setFree(true); } - }*/ + } // -------------mark @@ -2628,7 +2628,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { }); } - /*public String findCAMSBlockName(String name) { + public String findCAMSBlockName(String name) { return this.findGoodName (name, new NameChecker () { public boolean checkCAMSBlock (CAMSBlock o, String name) { if (o.getValue ().equals (name)) @@ -2636,7 +2636,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { return o.hasBlockWithName(); } }); - }*/ + } public String findAvatarSMDStateName(String name) { return this.findGoodName (name, new NameChecker () { diff --git a/src/main/java/ui/TGComponentManager.java b/src/main/java/ui/TGComponentManager.java index 8c2843d656eb5f6740984b60834d9a674510df65..ba9a69d77d81b426bbf551b127012529dbb37f23 100755 --- a/src/main/java/ui/TGComponentManager.java +++ b/src/main/java/ui/TGComponentManager.java @@ -75,7 +75,7 @@ import ui.tmlcompd.*; import ui.tmlcp.*; import ui.tmldd.*; import ui.tmlsd.*; -//import ui.het.*; +import ui.het.*; import ui.ucd.*; import java.awt.*; @@ -262,7 +262,7 @@ public class TGComponentManager { public static final int TMLARCHI_BUSNODE = 1102; public static final int TMLARCHI_COMMUNICATION_ARTIFACT = 1103; public static final int TMLARCHI_HWANODE = 1104; - //public static final int TMLARCHI_CAMSNODE = 1115; + public static final int TMLARCHI_CAMSNODE = 1115; public static final int TMLARCHI_MEMORYNODE = 1105; public static final int TMLARCHI_BRIDGENODE = 1106; public static final int TMLARCHI_DMANODE = 1107; @@ -323,8 +323,8 @@ public class TGComponentManager { public static final int TMLSD_ACTION_STATE = 1524; // SystemC-AMS - //public static final int CAMS_CONNECTOR = 1601; - //public static final int CAMS_BLOCK = 1602 ; + public static final int CAMS_CONNECTOR = 1601; + public static final int CAMS_BLOCK = 1602 ; // SMD diagram public static final int PROSMD_START_STATE = 2000; @@ -1178,9 +1178,9 @@ public class TGComponentManager { case TMLARCHI_HWANODE: tgc = new TMLArchiHWANode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; - /*case TMLARCHI_CAMSNODE: + case TMLARCHI_CAMSNODE: tgc = new TMLArchiCAMSNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); - break;*/ + break; case TMLARCHI_MEMORYNODE: tgc = new TMLArchiMemoryNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; @@ -1202,9 +1202,9 @@ public class TGComponentManager { case TMLARCHI_KEY: tgc = new TMLArchiKey(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; - //case CAMS_BLOCK: - //tgc = new CAMSBlock(x,y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); - //break; + case CAMS_BLOCK: + tgc = new CAMSBlock(x,y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; // Communication patterns + SD case TMLCP_CHOICE: @@ -1588,8 +1588,8 @@ public class TGComponentManager { return AAD_ASSOCIATION_CONNECTOR; //SystemC-AMS -----mark - //} else if (tgc instanceof CAMSBlockConnector) { - //return CAMS_CONNECTOR; + } else if (tgc instanceof CAMSBlockConnector) { + return CAMS_CONNECTOR; // Others } else if (tgc instanceof TADDeterministicDelay) { @@ -1901,12 +1901,12 @@ public class TGComponentManager { return TMLARCHI_BRIDGENODE; } else if (tgc instanceof TMLArchiFirewallNode) { return TMLARCHI_FIREWALL; - // } else if (tgc instanceof AvatarBDFirewall) { - // return AVATAR_FIREWALL; + } else if (tgc instanceof AvatarBDFirewall) { + return AVATAR_FIREWALL; } else if (tgc instanceof TMLArchiHWANode) { return TMLARCHI_HWANODE; - /*} else if (tgc instanceof TMLArchiCAMSNode) { - return TMLARCHI_CAMSNODE;*/ + } else if (tgc instanceof TMLArchiCAMSNode) { + return TMLARCHI_CAMSNODE; } else if (tgc instanceof TMLArchiMemoryNode) { return TMLARCHI_MEMORYNODE; } else if (tgc instanceof TMLArchiDMANode) { @@ -2312,10 +2312,10 @@ public class TGComponentManager { } - /*public final static CAMSBlockConnector addCAMSConnector(int x, int y, int id, TDiagramPanel tdp, CAMSConnectingPoint p1, CAMSConnectingPoint p2, Vector<Point> listPoint) { + public final static CAMSBlockConnector addCAMSConnector(int x, int y, int id, TDiagramPanel tdp, CAMSConnectingPoint p1, CAMSConnectingPoint p2, Vector<Point> listPoint) { CAMSBlockConnector cbc = null; cbc = new CAMSBlockConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint); return cbc; - }*/ + } } // Class diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index fb5c60c1ab5b85f3465cd7147397ee6706de1103..d2124ee84ad9cb5022a35ad6aacaed27b5924fcc 100755 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -50,6 +50,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import myutil.*; + /** * Class TGUIAction @@ -243,6 +245,7 @@ public class TGUIAction extends AbstractAction { public static final int TMLARCHI_PORT_ARTIFACT = 412; public static final int TMLARCHI_EVENT_ARTIFACT = 395; public static final int TMLARCHI_HWANODE = 223; + public static final int TMLARCHI_CAMSNODE = 461; public static final int TMLARCHI_MEMORYNODE = 224; public static final int TMLARCHI_DMANODE = 364; public static final int TMLARCHI_BRIDGENODE = 225; @@ -268,6 +271,9 @@ public class TGUIAction extends AbstractAction { public static final int TMLSD_MESSAGE_ASYNC = 390; public static final int TMLSD_EDIT = 391; + public static final int CAMS_EDIT = 458; + public static final int CAMS_BLOCK = 459; + public static final int CAMS_CONNECTOR = 460; public static final int EBRDD_EDIT = 271; public static final int EBRDD_CONNECTOR = 272; @@ -608,7 +614,7 @@ public class TGUIAction extends AbstractAction { public static final int ACT_INTERNAL_SEARCH = 415; //-- - public static final int NB_ACTION = 458; + public static final int NB_ACTION = 462; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -753,7 +759,7 @@ public class TGUIAction extends AbstractAction { actions[ACT_VIEW_PM_AUT] = new TAction("viewpmaut-command", "Power Management Analysis (last AUT graph)", IconManager.imgic28, IconManager.imgic29, "Power Management Analysis (last AUT graph)", "Power Management Analysis on the last generated reachability graph generated in AUT (Aldebaran) format", 0); actions[ACT_VIEW_PM_AUTPROJ] = new TAction("viewpmautproj-command", "Power Management Analysis (last minimized AUT graph)", IconManager.imgic28, IconManager.imgic29, "Power Management Analysis (last minimized AUT graph)", "Power Management Analysis on the last minimized reachability graph in AUT (Aldebaran) format", 0); actions[ACT_VIEW_PM_SAVED_AUT] = new TAction("viewpmsavedautproj-command", "Power Management Analysis (saved AUT graph)", IconManager.imgic28, IconManager.imgic29, "Power Management Analysis (saved AUT graph)", "Power Management Analysis on a graph saved in AUT (Aldebaran) format", 0); - actions[ACT_DSE] = new TAction("auto-dse", "Automated Design Space Exploration", IconManager.imgic89, IconManager.imgic89, "Automated Design Space Exploration", "Find the optimal mapping and security additions automatically",0); + actions[ACT_DSE] = new TAction("auto-dse", "Automated Design Space Exploration", IconManager.imgic89, IconManager.imgic89, "Automated Design Space Exploration", "Find the optimal mapping and security additions automatically",0); // AVATAR actions[ACT_AVATAR_SIM] = new TAction("avatar-simu", "Interactive simulation", IconManager.imgic18, IconManager.imgic18, "Interactive simulation", "Interactive simulation of the AVATAR design under edition", '2'); actions[ACT_AVATAR_FV_UPPAAL] = new TAction("avatar-formal-verification-uppaal", "Safety formal verification with UPPAAL (Safety)", IconManager.imgic86, IconManager.imgic86, "Formal verification with UPPAAL (Safety)", "Formal verification with UPPAAL (Safety) of the AVATAR design under edition", '3'); @@ -786,7 +792,7 @@ public class TGUIAction extends AbstractAction { actions[ACT_DIAGRAM_CAPTURE] = new TAction("diagram-capture", "Current diagram capture (PNG)", IconManager.imgic338, IconManager.imgic339, "Diagram capture", "Capture the currenlty opened diagram", 0); actions[ACT_SVG_DIAGRAM_CAPTURE] = new TAction("svg-diagram-capture", "Current diagram capture (SVG)", IconManager.imgic338, IconManager.imgic339, "Diagram capture (SVG)", "Capture the currenlty opened diagram in svg format", 0); actions[ACT_ALL_DIAGRAM_CAPTURE] = new TAction("all-diagram-capture", "All diagrams capture (PNG)", IconManager.imgic338, IconManager.imgic339, "All diagram capture (PNG)", "Capture in png images the currenlty opened set of diagram (analysis, design, etc.)", 0); - actions[ACT_ALL_DIAGRAM_CAPTURE_SVG] = new TAction("all-diagram-capture-svg", "All diagrams capture (SVG)", IconManager.imgic338, IconManager.imgic339, "All diagram capture (SVG)", "Capture in svg images the currenlty opened set of diagram (analysis, design, etc.)", 0); + actions[ACT_ALL_DIAGRAM_CAPTURE_SVG] = new TAction("all-diagram-capture-svg", "All diagrams capture (SVG)", IconManager.imgic338, IconManager.imgic339, "All diagram capture (SVG)", "Capture in svg images the currenlty opened set of diagram (analysis, design, etc.)", 0); actions[ACT_SELECTED_CAPTURE] = new TAction("selected-capture", "Capture of selected components", IconManager.imgic338, IconManager.imgic339, "Capture of selected components", "Capture the selected components of the currently opened diagram", 0); actions[ACT_GEN_DOC] = new TAction("gen-doc", "Documentation generation", IconManager.imgic28, IconManager.imgic28, "Documentation generation", "Documentation may be automatically generated, in html format, from edited diagrams", 0); actions[ACT_GEN_DOC_REQ] = new TAction("gen-doc-req", "SysML requirements documentation", IconManager.imgic28, IconManager.imgic28, "SysML requirements documentation", "SysML requirements documentation is displayed in an array, and may be further automatically generated in html format", 0); @@ -837,8 +843,8 @@ public class TGUIAction extends AbstractAction { actions[ADD_CPUNODE] = new TAction("add-add-cpunode", "Add a CPU", IconManager.imgic1100, IconManager.imgic1100, "CPU", "Add a cpu node to the currently opened AVATAR deployment diagram", 0); actions[ADD_BUSNODE] = new TAction("add-add-busnode", "Add a Bus", IconManager.imgic1102, IconManager.imgic1102, "Bus", "Add a bus node to the currently opened AVATAR deployment diagram", 0); - actions[ADD_VGMNNODE] = new TAction("add-add-vgmnnode", "Add a VGMN", IconManager.imgic1102, IconManager.imgic1102, "VGMN", "Add a VGMN node to the currently opened AVATAR deployment diagram", 0); - actions[ADD_CROSSBARNODE] = new TAction("add-add-crossbarnode", "Add a CROSSBAR", IconManager.imgic1102, IconManager.imgic1102, "Crossbar", "Add a Crossbar node to the currently opened AVATAR deployment diagram", 0); + actions[ADD_VGMNNODE] = new TAction("add-add-vgmnnode", "Add a VGMN", IconManager.imgic1102, IconManager.imgic1102, "VGMN", "Add a VGMN node to the currently opened AVATAR deployment diagram", 0); + actions[ADD_CROSSBARNODE] = new TAction("add-add-crossbarnode", "Add a CROSSBAR", IconManager.imgic1102, IconManager.imgic1102, "Crossbar", "Add a Crossbar node to the currently opened AVATAR deployment diagram", 0); actions[ADD_TTYNODE] = new TAction("add-add-tty", "Add a TTY node", IconManager.imgic1108, IconManager.imgic1108, "TTY", "Add a tty node to the currently opened AVATAR deployment diagram", 0); actions[ADD_BLOCKARTIFACT] = new TAction("add-add-blockartifact", "Map an AVATAR block", IconManager.imgic702, IconManager.imgic702, "Map an AVATAR block", "Map an AVATAR block onto a node in the currently opened AVATAR deployment diagram", 0); @@ -854,7 +860,7 @@ public class TGUIAction extends AbstractAction { actions[ADD_ROMNODE] = new TAction("add-add-romnode", "Add a ROM", IconManager.imgic1108, IconManager.imgic1108, "ROM", "Add a memory node to the currently opened AVATAR deployment diagram", 0); actions[ADD_DMANODE] = new TAction("add-add-dmanode", "Add a DMA", IconManager.imgic1110, IconManager.imgic1110, "DMA", "Add a DMA node to the currently opened AVATAR deployment diagram", 0); actions[ADD_ICUNODE] = new TAction("add-add-icunode", "Add an ICU", IconManager.imgic1112, IconManager.imgic1112, "ICU", "Add a ICU node to the currently opened AVATAR deployment diagram", 0); - actions[ADD_COPROMWMRNODE] = new TAction("add-add-copromwmrnode", "Add a MWMR Copro", IconManager.imgic1114, IconManager.imgic1114, "MWMR Copro", "Add a MWMR Coprocessor node to the currently opened AVATAR deployment diagram", 0); + actions[ADD_COPROMWMRNODE] = new TAction("add-add-copromwmrnode", "Add a MWMR Copro", IconManager.imgic1114, IconManager.imgic1114, "MWMR Copro", "Add a DMA node to the currently opened AVATAR deployment diagram", 0); actions[ADD_TIMERNODE] = new TAction("add-add-timernode", "Add a Timer", IconManager.imgic1116, IconManager.imgic1116, "Timer", "Add a timer node to the currently opened AVATAR deployment diagram", 0); @@ -901,7 +907,7 @@ public class TGUIAction extends AbstractAction { actions[SD_COREGION] = new TAction("add-sd-coregion", "Coregion", IconManager.imgic520, IconManager.imgic520, "Coregion", "Add a coregion to the currently opened sequence diagram", 0); actions[SD_ALIGN_INSTANCES] = new TAction("add-sd-align_instances", "Align instances", IconManager.imgic522, IconManager.imgic522, "Align instances", "align instances of the currently opened sequence diagram", 0); - actions[SDZV_EDIT] = new TAction("edit-sdzv-diagram", "Edit sequence diagram", IconManager.imgic100, IconManager.imgic101, "Edit sequence diagram", "Make it possible to edit the currently opened sequence diagram", 0); + actions[SDZV_EDIT] = new TAction("edit-sdzv-diagram", "Edit sequence diagram", IconManager.imgic100, IconManager.imgic101, "Edit sequence diagram", "Make it possible to edit the currently opened sequence diagram", 0); actions[SDZV_INSTANCE] = new TAction("add-sdzv-instance", "Add an instance", IconManager.imgic500, IconManager.imgic500, "Instance", "Add a new instance to the currently opened sequence diagram", 0); actions[SDZV_CONNECTOR_MESSAGE_ASYNC] = new TAction("add-sdzv-connector-message-async", "Add asynchronous message", IconManager.imgic504, IconManager.imgic504, "Asynchronous message", "Add an asynchronous message between two instances of the currently opened sequence diagram", 0); actions[SDZV_CONNECTOR_MESSAGE_SYNC] = new TAction("add-sdzv-connector-message-sync", "Add synchronous message", IconManager.imgic502, IconManager.imgic502, "Synchronous message", "Add an synchronous message between two instances of the currently opened sequence diagram", 0); @@ -988,9 +994,12 @@ public class TGUIAction extends AbstractAction { actions[TMLAD_SELECT_EVT] = new TAction("add-tmlad-select-evt", "Add select event", IconManager.imgic916, IconManager.imgic916, "Select event", "Add a selection between events to the currently opened TML Task activity diagram", 0); actions[TMLAD_RANDOM] = new TAction("add-tmlad-random", "Add random", IconManager.imgic924, IconManager.imgic924, "Select random", "Add a random operator to the currently opened TML Task activity diagram", 0); actions[TMLAD_READ_REQUEST_ARG] = new TAction("add-tmladd-read-request-arg", "Reading request arguments", IconManager.imgic930, IconManager.imgic930, "Reading request arguments", "Add a reading request argument operator to the currently opened TML activity diagram", 0); - - actions[TMLAD_ENCRYPT] = new TAction("add-tmlad-encrypt", "Add Encryption", IconManager.imgic940, IconManager.imgic940, "Encryption", "Add an encryption operator to the currently opened TML Task activity diagram", 0); - actions[TMLAD_DECRYPT] = new TAction("add-tmlad-decrypt", "Add Decryption", IconManager.imgic941, IconManager.imgic941, "Decryption", "Add a decryption operator to the currently opened TML Task activity diagram", 0); + + + + actions[TMLAD_ENCRYPT] = new TAction("add-tmlad-encrypt", "Add Encryption", IconManager.imgic940, IconManager.imgic940, "Encryption", "Add an encryption operator to the currently opened TML Task activity diagram", 0); + actions[TMLAD_DECRYPT] = new TAction("add-tmlad-decrypt", "Add Decryption", IconManager.imgic941, IconManager.imgic941, "Decryption", "Add a decryption operator to the currently opened TML Task activity diagram", 0); + actions[EBRDD_EDIT] = new TAction("edit-ebrdd-diagram", "Edit EBRDD", IconManager.imgic100, IconManager.imgic101, "Edit EBRDD", "Make it possible to edit the currently opened Event-Based Requirement Description Diagram", 0); actions[EBRDD_CONNECTOR] = new TAction("add-ebrdd-connector", "Connect two operators together", IconManager.imgic202, IconManager.imgic202, "Connect two operators together", "Connect two operators of the currently opened Event-Based Requirement Description Diagram", 0); @@ -1017,10 +1026,11 @@ public class TGUIAction extends AbstractAction { actions[TMLARCHI_EVENT_ARTIFACT] = new TAction("add-tmlarchi-event-artifact", "Map an event / request", IconManager.imgic702, IconManager.imgic702, "Map an event/request", "Map an event or a request onto a node in the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_BRIDGENODE] = new TAction("add-tmlarchi-bridgenode", "Add a Bridge node", IconManager.imgic1104, IconManager.imgic1104, "Bridge node", "Add a bridge node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_HWANODE] = new TAction("add-tmlarchi-hwanode", "Add a hardware accelerator node", IconManager.imgic1106, IconManager.imgic1106, "Hardware accelerator node", "Add a hardware accelerator node to the currently opened DIPLODOCUS architecture diagram", 0); + actions[TMLARCHI_CAMSNODE] = new TAction("add-tmlarchi-camsnode", "Add a System C-AMS node", IconManager.imgic1106, IconManager.imgic1106, "System C-AMS node", "Add a System C-AMS node to the currently open DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_MEMORYNODE] = new TAction("add-tmlarchi-memorynode", "Add a memory node", IconManager.imgic1108, IconManager.imgic1108, "Memory node", "Add a memory node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_DMANODE] = new TAction("add-tmlarchi-dmanode", "Add a DMA node", IconManager.imgic1110, IconManager.imgic1110, "DMA node", "Add a DMA node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_KEY] = new TAction("add-tmlarchi-key", "Map a key", IconManager.imgic1118, IconManager.imgic1118, "Map a key", "Map a key onto a node in the currently opened DIPLODOCUS architecture diagram", 0); - actions[TMLARCHI_FIREWALL] = new TAction("add-tmlarchi-firewall", "Add a Firewall", IconManager.imgic7001, IconManager.imgic7001, "Add a Firewall", "Add a Firewall in the currently opened DIPLODOCUS architecture diagram",0); + actions[TMLARCHI_FIREWALL] = new TAction("add-tmlarchi-firewall", "Add a Firewall", IconManager.imgic7001, IconManager.imgic7001, "Add a Firewall", "Add a Firewall in the currently opened DIPLODOCUS architecture diagram",0); actions[TMLCP_EDIT] = new TAction("edit-tmlcp-diagram", "Edit communication pattern diagram", IconManager.imgic100, IconManager.imgic101, "Edit communication pattern diagram", "Make it possible to edit the currently opened communication pattern diagram", 0); actions[TMLCP_CONNECTOR] = new TAction("add-tmlcp-connector", "Add CP Connector", IconManager.imgic202, IconManager.imgic202, "Connector", "Add a Connector between two components of the currently opened communication pattern diagram", 0); @@ -1032,7 +1042,7 @@ public class TGUIAction extends AbstractAction { actions[TMLCP_START] = new TAction("add-tmlcp-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened communication pattern diagram", 0); actions[TMLCP_STOP] = new TAction("add-tmlcp-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened communication pattern diagram", 0); actions[TMLCP_JUNCTION] = new TAction("add-tmlcp-junction", "Add Junction", IconManager.imgic212, IconManager.imgic212, "Junction", "Add a junction with three inputs to the currently opened communication pattern diagram", 0); - actions[TMLCP_FOR_LOOP] = new TAction("add-tmlcp-forloop", "Add loop", IconManager.imgic912, IconManager.imgic912, "Loop", "Add a for loop to the currently opened communication pattern diagram", 0); + actions[TMLCP_FOR_LOOP] = new TAction("add-tmlcp-forloop", "Add loop", IconManager.imgic912, IconManager.imgic912, "Loop", "Add a for loop to the currently opened communication pattern diagram", 0); actions[TMLSD_EDIT] = new TAction("edit-tmlsd-diagram", "Edit CP-SD diagram", IconManager.imgic100, IconManager.imgic101, "Edit the Sequence Diagram", "Make it possible to edit the currently opened communication pattern sequence diagram", 0); actions[TMLSD_MESSAGE_ASYNC] = new TAction("add-tmlsd-messageasync", "Add async msg", IconManager.imgic202, IconManager.imgic202, "Asynchronous message", "Add an asynchronous message between two components of the currently opened communication pattern sequence diagram", 0); @@ -1041,6 +1051,11 @@ public class TGUIAction extends AbstractAction { actions[TMLSD_CONTROLLER_INSTANCE] = new TAction("add-controller-instance-tmlsd", "Controller instance", IconManager.imgic500, IconManager.imgic500, "Controller instance", "Add a controller instance to the currently opened communication pattern sequence diagram", 0); actions[TMLSD_ACTION_STATE] = new TAction("add-action-tmlsd", "Action state", IconManager.imgic512, IconManager.imgic512, "Action state", "Add an action state to the currently opened communication pattern sequence diagram", 0); + //System C-AMS + actions[CAMS_EDIT] = new TAction("add-action-C-AMS", "Action state", IconManager.imgic100, IconManager.imgic101, "Action state", "Add an action state to the currently opened SystemC-AMS diagram", 0); + actions[CAMS_BLOCK] = new TAction("C-AMS-block", "Add a block", IconManager.imgic5000, IconManager.imgic5000, "Block", "Add a Block to the currently opened SystemC-AMS Diagram", 0); + actions[CAMS_CONNECTOR] = new TAction("C-AMS-connector", "Add a connection", IconManager.imgic202, IconManager.imgic202, "Connector", "Connects two block of the currently opened SystemC-AMS Diagram", 0); + //ProActive State Machine Diagram actions[PROSMD_EDIT] = new TAction("edit-prosmd-diagram", "Edit ProActive state machine diagram", IconManager.imgic100, IconManager.imgic101, "Edit ProActive state machine diagram", "Make it possible to edit the currently opened ProActive state machine diagram", 0); @@ -1088,8 +1103,8 @@ public class TGUIAction extends AbstractAction { actions[ATD_ATTACK_CONNECTOR] = new TAction("atd-attack-connector", "Add a connector between attacks /constraints", IconManager.imgic1080, IconManager.imgic1080, "Connector", "Add a connector between attacks / constraints of the currently opened attack tree diagram", 0); actions[ATD_COMPOSITION_CONNECTOR] = new TAction("atd-composition-connector", "Add a composition connector between blocks", IconManager.imgic1076, IconManager.imgic1076, "Composition connector", "Add a composition between blocks of the currently opened attack tree diagram", 0); actions[ATD_CONSTRAINT] = new TAction("atd-constraint", "Add an constraint", IconManager.imgic1078, IconManager.imgic1078, "Constraint", "Add a constraint to the currently opened attack tree diagram", 0); - actions[ATD_COUNTERMEASURE] = new TAction("atd-countermeasure", "Add a countermeasure", IconManager.imgic1082, IconManager.imgic1082, "Countermeasure", "Add a countermeasure to the currently opened attack tree diagram", 0); - actions[ATD_COUNTERMEASURE_CONNECTOR] = new TAction("atd-countermeasure-connector", "Add a connector between attacks / countermeasures", IconManager.imgic1084, IconManager.imgic1084, "Connect countermeasure", "Add a connector between attacks / countermeasures of the currently opened attack tree diagram", 0); + actions[ATD_COUNTERMEASURE] = new TAction("atd-countermeasure", "Add a countermeasure", IconManager.imgic1082, IconManager.imgic1082, "Countermeasure", "Add a countermeasure to the currently opened attack tree diagram", 0); + actions[ATD_COUNTERMEASURE_CONNECTOR] = new TAction("atd-countermeasure-connector", "Add a connector between attacks / countermeasures", IconManager.imgic1084, IconManager.imgic1084, "Connect countermeasure", "Add a connector between attacks / countermeasures of the currently opened attack tree diagram", 0); // TURTLE-OS actions[TOS_TCLASS] = new TAction("add-tclass-os", "Add Tclass", IconManager.imgic104, IconManager.imgic104, "Tclass", "Add a TClass to the currently opened class diagram", 0); @@ -1146,17 +1161,17 @@ public class TGUIAction extends AbstractAction { actions[AMAD_VERSIONING_CONNECTOR] = new TAction("add-amad-versioning", "Add a versioning link", IconManager.imgic5064, IconManager.imgic5064, "Versioning", "Add a versioning link between two assumptions of the currently opened avatar Modeling Assumptions diagram", 0); actions[AMAD_IMPACT_CONNECTOR] = new TAction("add-amad-impact", "Add an impact link", IconManager.imgic5066, IconManager.imgic5066, "Impact", "Add an impact link between two references to model elements, in the currently opened avatar Modeling Assumptions diagram", 0); actions[AMAD_MEET_CONNECTOR] = new TAction("add-amad-meet", "Add an meet link", IconManager.imgic5066, IconManager.imgic5066, "Meet", "Add an meet link between a model element and an assumption in the currently opened Avatar Modeling Assumptions diagram", 0); - actions[AMAD_BELONGSTOCOMPOSITION_CONNECTOR] = new TAction("amad-belongstocomposition-connector", "Add a composition connector between references", IconManager.imgic5002, IconManager.imgic5002, "Composition connector", "Add a composition between blocks of the currently opened Avatar Modeling Assumptions diagram", 0); + actions[AMAD_BELONGSTOCOMPOSITION_CONNECTOR] = new TAction("amad-belongstocomposition-connector", "Add a composition connector between references", IconManager.imgic5002, IconManager.imgic5002, "Composition connector", "Add a composition between blocks of the currently opened Avatar Modeling Assumptions diagram", 0); // AVATAR Requirement Diagrams actions[ARD_EDIT] = new TAction("edit-ard-diagram", "Edit Requirement Diagram", IconManager.imgic100, IconManager.imgic101, "Edit Requirement Diagram", "Make it possible to edit the currently opened Requirement Diagram", 0); actions[ARD_REQUIREMENT] = new TAction("add-ard-requirement", "Add a requirement", IconManager.imgic5006, IconManager.imgic5006, "Requirement", "Add a requirement to the currently opened requirement diagram", 0); actions[ARD_PROPERTY] = new TAction("add-ard-property", "Add a property", IconManager.imgic5008, IconManager.imgic5008, "Property", "Add a reference to a property of the currently opened requirement diagram", 0); - actions[ARD_ELEMENT_REFERENCE] = new TAction("add-ard-element-reference", "Add a reference to an element", IconManager.imgic5068, IconManager.imgic5068, "Element Reference", "Add a reference to an element of the currently opened requirement diagram", 0); + actions[ARD_ELEMENT_REFERENCE] = new TAction("add-ard-element-reference", "Add a reference to an element", IconManager.imgic5068, IconManager.imgic5068, "Element Reference", "Add a reference to an element of the currently opened requirement diagram", 0); actions[ARD_DERIVE_CONNECTOR] = new TAction("add-ard-derive", "Add a <<deriveReqt>> link", IconManager.imgic1008, IconManager.imgic1008, "DeriveReqt", "Add a <<deriveReqt>> link between two requirements of the currently opened requirement diagram", 0); - actions[ARD_SATISFY_CONNECTOR] = new TAction("add-ard-satisfy", "Add a <<satisfy>> link", IconManager.imgic1018, IconManager.imgic1018, "Satisfy", "Add a <<satisfy>> link between two requirements of the currently opened requirement diagram", 0); + actions[ARD_SATISFY_CONNECTOR] = new TAction("add-ard-satisfy", "Add a <<satisfy>> link", IconManager.imgic1018, IconManager.imgic1018, "Satisfy", "Add a <<satisfy>> link between two requirements of the currently opened requirement diagram", 0); - actions[ARD_REFINE_CONNECTOR] = new TAction("add-ard-refine", "Add a <<refine>> link", IconManager.imgic1016, IconManager.imgic1016, "refine", "Add a <<refine>> link between two requirements of the currently opened requirement diagram", 0); + actions[ARD_REFINE_CONNECTOR] = new TAction("add-ard-refine", "Add a <<refine>> link", IconManager.imgic1016, IconManager.imgic1016, "refine", "Add a <<refine>> link between two requirements of the currently opened requirement diagram", 0); actions[ARD_VERIFY_CONNECTOR] = new TAction("add-ard-verify", "Add a <<verify>> link", IconManager.imgic1006, IconManager.imgic1006, "Verify", "Add a <<verify>> link between an observer and a requirement of the currently opened requirement diagram", 0); actions[ARD_COPY_CONNECTOR] = new TAction("add-ard-copy", "Add a <<copy>> link", IconManager.imgic1010, IconManager.imgic1010, "Copy", "Add a <<copy>> link between two requirements of the currently opened requirement diagram", 0); actions[ARD_COMPOSITION_CONNECTOR] = new TAction("add-ard-composition", "Add a composition link", IconManager.imgic1012, IconManager.imgic1012, "Composition", "Add a composition link between two requirements of the currently opened requirement diagram", 0); @@ -1206,8 +1221,11 @@ public class TGUIAction extends AbstractAction { actions[ACT_GENERATE_ONTOLOGIES_CURRENT_DIAGRAM] = new TAction("generate-ontology-current-diagram", "Generate ontology (current diagram)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (current diagram)", "Generate the ontology for the diagram under edition", 0); actions[ACT_GENERATE_ONTOLOGIES_CURRENT_SET_OF_DIAGRAMS] = new TAction("generate-ontology-current-set-of-diagrams", "Generate ontology (current set of diagrams)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (current set of diagrams)", "Generate the ontology for the current set of diagrams under edition", 0); actions[ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS] = new TAction("generate-ontology-all-diagrams", "Generate ontology (all diagrams)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (all diagrams)", "Generate the ontology for the diagrams under edition", 0); + + } + public String getActionCommand() { return (String)getValue(Action.ACTION_COMMAND_KEY); } diff --git a/src/main/java/ui/atd/AttackTreeDiagramPanel.java b/src/main/java/ui/atd/AttackTreeDiagramPanel.java index 1f901e4ea1f8919845536248c4044cf1c6b28ee8..d552f0e685ceea02ce63faa6e8dc51f048862d1e 100644 --- a/src/main/java/ui/atd/AttackTreeDiagramPanel.java +++ b/src/main/java/ui/atd/AttackTreeDiagramPanel.java @@ -47,6 +47,8 @@ import ui.*; import java.util.ArrayList; import java.util.Iterator; +import java.util.LinkedList; +import java.util.ListIterator; //import org.w3c.dom.*; //import org.xml.sax.*; @@ -116,7 +118,22 @@ public class AttackTreeDiagramPanel extends TDiagramPanel implements TDPWithAttr // Position correctly guards of choice } - + public LinkedList<TGComponent> getAllAttacks() { + LinkedList<TGComponent> list = new LinkedList<TGComponent>(); + TGComponent tgc; + + ListIterator iterator = getComponentList().listIterator(); + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (tgc instanceof ATDAttack) { + list.add(tgc); + } + } + + return list; + + } public boolean hasAutoConnect() { return false; diff --git a/src/main/java/ui/het/CAMSBlock.java b/src/main/java/ui/het/CAMSBlock.java new file mode 100755 index 0000000000000000000000000000000000000000..97852637283904d48b72f3e71f9ce9ff1391c7b0 --- /dev/null +++ b/src/main/java/ui/het/CAMSBlock.java @@ -0,0 +1,394 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package ui.het; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.util.IconManager; +import ui.window.JDialogCAMSBlocks; +import heterogeneoustranslator.systemCAMStranslator.*; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; +import java.util.Vector; + + +/** +* Class CAMSBlock +* Block for SystemC-AMS Diagrams +* Creation: 27/06/2017 +* @version 1.0 27/06/2017 +* @author Côme DEMARIGNY + */ +public class CAMSBlock extends TGComponent { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "block"; + + private int nbOfIn = 0; + private int nbOfOut = 0; + private int nbOfHybridIn = 0; + private int nbOfHybridOut = 0; + private int totIn = 0; + private int totOut = 0; + + protected int index = 0; + + private int maxFontSize = 12; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + private int textX = 7; + + private int limitName = -1; + private int limitAttr = -1; + private int limitMethod = -1; + + public String name; + public String Value= "Block0"; + private JDialogCAMSBlocks dialog; + + // TAttribute, ProcessCode, CAMSSignal + protected LinkedList<TAttribute> myAttributes; + protected LinkedList<CAMSSignal> mySignals; + protected String [] processCode; + + //Simulation Object + private CAMSBlocks SBlock; + + public CAMSBlock (int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + tdp = _tdp; + width = 250; + height = 200; + minWidth = 150; + minHeight = 100; + + createConnectingPoints(); + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + getBlockName(); + + myImageIcon = IconManager.imgic700; + + if(this.myAttributes == null){this.myAttributes = new LinkedList<TAttribute>();} + if(this.mySignals == null){this.mySignals = new LinkedList<CAMSSignal>();} + + SBlock= new CAMSBlocks(name, nbOfIn, nbOfOut, nbOfHybridIn, nbOfHybridOut, myAttributes, mySignals, processCode); + } + + public void createConnectingPoints(){ + int i; + double h; + + resetInOut(); + + if(this.mySignals!=null){ + for(i=0;i<mySignals.size();i++){ + if(mySignals.get(i).getInout()==0){ + nbOfIn++; + } else if(mySignals.get(i).getInout()==1) { + nbOfOut++; + } else if(mySignals.get(i).getInout()==2) { + nbOfHybridIn++; + } else{ + nbOfHybridOut++; + } + } + } + + nbConnectingPoint = nbOfIn + nbOfOut + nbOfHybridIn + nbOfHybridOut; + totIn = nbOfIn + nbOfHybridIn; + totOut = nbOfOut + nbOfHybridOut; + + connectingPoint = new CAMSConnectingPoint[nbConnectingPoint]; + + for (i = 1; i<= totIn; i++){ + h = i/(totIn + 1.0); + if((i-1)<nbOfIn){ + connectingPoint[i-1] = new CAMSConnectingPoint(this, 0, 0, true, false, false, 0.0, h); + } else{ + connectingPoint[i-1] = new CAMSConnectingPoint(this, 0, 0, true, false, true, 0.0, h); + } + } + + for (i = 1; i<=totOut; i++){ + h = i/(totOut + 1.0); + if ((i+totIn-1)<(nbOfOut + totIn)){ + connectingPoint[i+totIn-1] = new CAMSConnectingPoint(this, 0, 0, false, true, false, 1.0, h); + } else { + connectingPoint[i+totIn-1] = new CAMSConnectingPoint(this, 0, 0, false, true, true, 1.0, h); + } + } + + addTGConnectingPointsComment(); + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.HWA_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + g.setFont(f); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, x + (width - w)/2, y + textY2); + + + actionOnAdd(); + } + + public void addSignal(CAMSSignal sig){ + mySignals.add(sig); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + return null; + } + + public void setState(int _s){ + } + + public TGComponent isOnMe(int _x, int _y){ + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public boolean editOndoubleClick(JFrame frame) { + + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + boolean changeMade=false; + + if(dialog ==null){ + dialog = new JDialogCAMSBlocks(this.myAttributes, this.mySignals, null, frame, "Setting Block attributes", "Attributes", this, processCode, true); + } + setJDialogOptions(dialog); + GraphicLib.centerOnParent(dialog, 1050, 700); + dialog.setVisible( true ); // blocked until dialog has been closed + mySignals = dialog.getSignals(); + createConnectingPoints(); + getBlockName(); + setSimulationBlock(); + + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + return true; + } + + + @Override + public void loadExtraParam(NodeList bl, int decX, int decY, int decId) throws MalformedModelingException{ + try { + + NodeList bli; + Node b1, b2; + Element elt; + String sstereotype = null, sblockName = null; + + for(int i=0; i<bl.getLength(); i++) { + b1 = bl.item(i); + //System.out.println(n1); + if (b1.getNodeType() == Node.ELEMENT_NODE) { + bli = b1.getChildNodes(); + for(int j=0; j<bli.getLength(); j++) { + b2 = bli.item(j); + if (b2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) b2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + sblockName = elt.getAttribute("blockName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (sblockName != null){ + name = sblockName; + } + + if (elt.getTagName().equals("attributes")) { + + nbOfIn = Integer.decode(elt.getAttribute("nbOfIn")).intValue(); + nbOfOut =Integer.decode(elt.getAttribute("nbOfOut")).intValue(); + + } + } + } + } + } + } catch (Exception e) { + System.out.println("load failure"); + throw new MalformedModelingException(); + } + } + + public void setSimulationBlock(){ + SBlock.setBlockName(name); + SBlock.setNbOfIn(nbOfIn); + SBlock.setNbOfOut(nbOfOut); + SBlock.setNbOfHybridIn(nbOfHybridIn); + SBlock.setNbOfHybridOut(nbOfHybridOut); + SBlock.setMyAttributes(myAttributes); + SBlock.setMySignals(mySignals); + SBlock.setProcessCode(processCode); + } + + protected void setJDialogOptions(JDialogCAMSBlocks _jdab) { + _jdab.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE)); + _jdab.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC)); + _jdab.addType(TAttribute.getStringCAMSType(TAttribute.BOOLEAN), true); + _jdab.addType(TAttribute.getStringCAMSType(TAttribute.DOUBLE), true); + _jdab.enableInitialValue(true); + _jdab.enableRTLOTOSKeyword(false); + _jdab.enableJavaKeyword(false); + } + + public String getAttributes() { + String attr = ""; + attr += "Nb of in = " + totIn + "\n"; + attr += "Nb of out = " + totOut + "\n"; + + return attr; + } + + public int getType() { + return TGComponentManager.CAMS_BLOCK; + } + + public boolean hasBlockWithName(){ + return true; + } + + public void getBlockName() { + if(dialog != null) { + name = dialog.getBlockName(); + if (name.length()==0){ + name = tdp.findCAMSBlockName("Block"); + return ; + } + return ; + } + name = Value; + } + + public void resetInOut(){ + nbOfIn = 0; + nbOfOut= 0; + nbOfHybridIn = 0; + nbOfHybridOut= 0; + totIn = 0; + totOut= 0; + } + + public int getNbOfIn() { + return totIn; + } + + public int getNbOfOut() { + return totOut; + } + + public int getNbOfHybridIn() { + return nbOfHybridIn; + } + + public int getNbOfHybridOut() { + return nbOfHybridOut; + } + + public int getNbOfNonHybridIn() { + return nbOfIn; + } + + public int getNbOfNonHybridOut() { + return nbOfOut; + } + + public int getDefaultConnector() { + return TGComponentManager.CAMS_CONNECTOR; + } + +} diff --git a/src/main/java/ui/het/CAMSBlockConnector.java b/src/main/java/ui/het/CAMSBlockConnector.java new file mode 100755 index 0000000000000000000000000000000000000000..36edcd8bc817943e4d5235292b3dd35ee622489c --- /dev/null +++ b/src/main/java/ui/het/CAMSBlockConnector.java @@ -0,0 +1,302 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package ui.het; + +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.awt.*; +import java.awt.geom.Point2D; +import java.util.Vector; + + +/** + * Class SystemCAMSConnectingPoint + * Definition of connecting points on which attribute connectors can be connected + * Creation: 27/06/2017 + * @version 1.0 27/06/2017 + * @author Côme Demarigny + */ +public class CAMSBlockConnector extends TGConnector { + + public CAMSBlockConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, CAMSConnectingPoint _p1, CAMSConnectingPoint _p2, Vector<Point> _listPoint){ + super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; + + name = "connector"; + _p1.setReferenceToConnector( this ); + _p2.setReferenceToConnector( this ); + + } + + public int getType() { + return TGComponentManager.CAMS_CONNECTOR; + } + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { + g.drawLine(x1, y1, x2, y2); + } else { + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); + } + } + + // protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + // Point p_one; + // boolean isp1; + // if (getIndexOfLastTGCPointOfConnector() == -1) { + // p_one = new Point(p1.getX(), p1.getY()); + // isp1 = true; + // } else { + // TGComponent tmpc = tgcomponent[getIndexOfLastTGCPointOfConnector()]; + // p_one = new Point(tmpc.getX(), tmpc.getY()); + // isp1 = false; + // } + + // //g.drawLine(x1, y1, x2, y2); + // Color col = g.getColor(); + // int cz = (int)(tdp.getZoom() * c); + // if (isAsynchronous()) { + // g.setColor(Color.WHITE); + // } + // g.fillRect(x2-(cz/2), y2-(cz/2), cz, cz); + // g.fillRect(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz); + // g.setColor(col); + // if (isAsynchronous()) { + // g.drawRect(x2-(cz/2), y2-(cz/2), cz, cz); + // g.drawRect(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz); + // if (isBlocking()) { + // g.drawLine(x2-(cz/2), y2-(cz/2), x2-(cz/2)+cz, y2-(cz/2)+cz); + // g.drawLine(x2-(cz/2), y2-(cz/2)+cz, x2-(cz/2)+cz, y2-(cz/2)); + // g.drawLine(p1.getX()-(cz/2), p1.getY()+(cz/2), p1.getX()+(cz/2), p1.getY()-(cz/2)); + // g.drawLine(p1.getX()-(cz/2), p1.getY()-(cz/2), p1.getX()+(cz/2), p1.getY()+(cz/2)); + // } + // } + + + // if (!isPrivate() /*&& !isAsynchronous()*/) { + // int czz = (int)(cz*1.4); + // int x3 = p1.getX(); + // int y3 = p1.getY(); + + // Polygon p1 = new Polygon(); + // p1.addPoint(x2-(czz/2)+czz, y2-cz); + // p1.addPoint(x2+(czz/2)+czz, y2-cz); + // p1.addPoint(x2+czz, y2-(2*czz)); + + // Polygon p2 = new Polygon(); + // p2.addPoint(x3-(czz/2)+czz, y3-cz); + // p2.addPoint(x3+(czz/2)+czz, y3-cz); + // p2.addPoint(x3+czz, y3-(2*czz)); + + // // Adding illuminatis sign at the end + // g.setColor(Color.WHITE); + // g.fillPolygon(p1); + // g.fillPolygon(p2); + + // g.setColor(col); + // g.drawPolygon(p1); + // g.drawPolygon(p2); + // g.drawOval(x2+czz-4, y2-cz-7, 8, 6); + // g.drawOval(x3+czz-4, y3-cz-7, 8, 6); + // g.fillOval(x2+czz-2, y2-cz-6, 5, 4); + // g.fillOval(x3+czz-2, y3-cz-6, 5, 4); + + // } + + + // Point p11; + // if (isp1) { + // p11 = GraphicLib.intersectionRectangleSegment(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz, x1, y1, x2, y2); + // } else { + // p11 = new Point(p_one.x, p_one.y); + // } + // if (p11 == null) { + // p11 = new Point(p1.getX(), p1.getY()); + // //System.out.println("null point"); + // } + // Point p22 = GraphicLib.intersectionRectangleSegment(x2-(cz/2), y2-(cz/2), cz, cz, x1, y1, x2, y2); + // if (p22 == null) { + // p22 = new Point(p2.getX(), p2.getY()); + // //System.out.println("null point"); + // } + + // g.drawLine(p11.x, p11.y, p22.x, p22.y); + + // Font f = g.getFont(); + // Font fold = f; + // f = f.deriveFont((float)fontSize); + // g.setFont(f); + // int h = - decY; + // int step = fontSize + 1; + // int w; + // String s; + + + // if (((g.getColor() == ColorManager.POINTER_ON_ME_0) && (tdp.getAttributeState() == tdp.PARTIAL)) || (tdp.getAttributeState() == tdp.FULL)) { + // // Signals at origin + // if (inSignalsAtOrigin.size() > 0) { + // //g.drawString("in:", p1.getX() + decX, p1.getY() + h); + // for(String iso: inSignalsAtOrigin) { + // h += step; + // s = getShortName(iso); + // if (p1.getX() <= p2.getX()) { + // g.drawString(s, p1.getX() + decX, p1.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p1.getX() - decX - w, p1.getY() + h); + // } + // } + // } + // if (outSignalsAtOrigin.size() > 0) { + // //h += step; + // //g.drawString("out:", p1.getX() + decX, p1.getY() + h); + // for(String oso: outSignalsAtOrigin) { + // h += step; + // s = getShortName(oso); + // if (p1.getX() <= p2.getX()) { + // g.drawString(s, p1.getX() + decX, p1.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p1.getX() - decX - w, p1.getY() + h); + // } + // } + // } + // // Signals at destination + // h = - decY; + // if (outSignalsAtDestination.size() > 0) { + // //h += step; + // //g.drawString("out:", p2.getX() + decX, p2.getY() + h); + // for(String osd: outSignalsAtDestination) { + // h += step; + // s = getShortName(osd); + // if (p1.getX() > p2.getX()) { + // g.drawString(s, p2.getX() + decX, p2.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p2.getX() - decX - w, p2.getY() + h); + // } + // } + // } + // if (inSignalsAtDestination.size() > 0) { + // //g.drawString("in:", p2.getX() + decX, p2.getY() + h); + // for(String isd: inSignalsAtDestination) { + // h += step; + // s = getShortName(isd); + // if (p1.getX() > p2.getX()) { + // g.drawString(s, p2.getX() + decX, p2.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p2.getX() - decX - w, p2.getY() + h); + // } + // } + // } + // } + + // g.setFont(fold); + + // /*if (value.length() > 0) { + // Font f = g.getFont(); + // if (tdp.getZoom() < 1) { + // Font f0 = f.deriveFont((float)(fontSize*tdp.getZoom())); + // g.setFont(f0); + // } + // g.drawString(value, x2-(cz/2), y2-(cz/2)-1); + // g.setFont(f); + // }*/ + + // // Animation? + // if ((TDiagramPanel.AVATAR_ANIMATE_ON) && (isAsynchronous())){ + // //TraceManager.addDev("anim port connector: " + this); + // String messageInformation[] = tdp.getMGUI().hasMessageInformationForAvatarConnector(this); + // if (messageInformation != null) { + // if (messageInformation[0] != null) { + // g.setColor(Color.BLUE); + // g.drawString(messageInformation[0], p1.getX() + decX, p1.getY()); + // } + // if (messageInformation[1] != null) { + // g.setColor(Color.BLUE); + // g.drawString(messageInformation[1], p2.getX() + decX, p2.getY()); + // } + // g.setColor(Color.BLACK); + // } + // } + // } + + @Override + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + //int t1id; + String tmp = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + + // Issue #17 copy-paste error on j index + for(int j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + +} //class diff --git a/src/main/java/ui/het/CAMSBlockDiagramPanel.java b/src/main/java/ui/het/CAMSBlockDiagramPanel.java new file mode 100755 index 0000000000000000000000000000000000000000..b00ae26c6af890492710c3841dc5df1dada4b84c --- /dev/null +++ b/src/main/java/ui/het/CAMSBlockDiagramPanel.java @@ -0,0 +1,217 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici + * + * ludovic.apvrille AT enst.fr + * andrea.enrici AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package ui.het; + + +import myutil.TraceManager; +import org.w3c.dom.Element; +import ui.*; + +import java.util.*; + +/** + * Class CAMSBlockDiagramPanel + * Panel for drawing TML Blocks + * Creation: 26/06/2017 + * @version 1.0 26/06/2017 + * @author Côme DEMARIGNY + */ +public class CAMSBlockDiagramPanel extends TDiagramPanel implements TDPWithAttributes { + + public CAMSBlockDiagramPanel(MainGUI mgui, TToolBar _ttb) { + super(mgui, _ttb); + } + + public void initFromDiplodocus(){ + TGComponentManager.addComponent(100,100,TGComponentManager.CAMS_BLOCK,this); + TGComponentManager.addComponent(600,100,TGComponentManager.CAMS_BLOCK,this); + } + + public boolean actionOnDoubleClick(TGComponent tgc) { + /*if (tgc instanceof TCDTClass) { + TCDTClass t = (TCDTClass)tgc; + return mgui.newTClassName(tp, t.oldValue, t.getValue()); + } else if (tgc instanceof TCDActivityDiagramBox) { + if (tgc.getFather() instanceof TCDTClass) { + mgui.selectTab(tp, tgc.getFather().getValue()); + } else if (tgc.getFather() instanceof TCDTObject) { + TCDTObject to = (TCDTObject)(tgc.getFather()); + TCDTClass t = to.getMasterTClass(); + if (t != null) { + mgui.selectTab(tp, t.getValue()); + } + } + return false; // because no change made on any diagram + }*/ + return false; + } + + public boolean actionOnAdd(TGComponent tgc) { + return false; + } + + public boolean actionOnRemove(TGComponent tgc) { + return false; + } + + public boolean actionOnValueChanged(TGComponent tgc) { + return false; + } + + public void setConnectorsToFront() { + TGComponent tgc; + + //System.out.println("list size=" + componentList.size()); + + Iterator iterator = componentList.listIterator(); + + ArrayList<TGComponent> list = new ArrayList<TGComponent>(); + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (!(tgc instanceof TGConnector)) { + list.add(tgc); + } + } + + //System.out.println("Putting to back ..."); + for(TGComponent tgc1: list) { + //System.out.println("Putting to back: " + tgc1); + componentList.remove(tgc1); + componentList.add(tgc1); + } + } + + public String getXMLHead() { + return "<CAMSBlockDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + zoomParam() +" >"; + } + + public String getXMLTail() { + return "</CAMSBlockDiagramPanel>"; + } + + public String getXMLSelectedHead() { + return "<CAMSBlockDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; + } + + public String getXMLSelectedTail() { + return "</CAMSBlockDiagramPanelCopy>"; + } + + public String getXMLCloneHead() { + return "<CAMSBlockDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; + } + + public String getXMLCloneTail() { + return "</CAMSBlockDiagramPanelCopy>"; + } + + + + public boolean areAttributesVisible() { + return attributesVisible; + } + + + public boolean areChannelVisible() { + return synchroVisible; + } + + public void setAttributesVisible(boolean b) { + attributesVisible = b; + } + + + public void setChannelVisible(boolean b) { + channelVisible = b; + } + + public String displayParam() { + String s = ""; + if (channelsVisible) { + s += " channels=\"true\""; + } else { + s += " channels=\"false\""; + } + if (eventsVisible) { + s += " events=\"true\""; + } else { + s += " events=\"false\""; + } + if (requestsVisible) { + s += " requests=\"true\""; + } else { + s += " requests=\"false\""; + } + + return s; + } + + public boolean areAllVisible() { + return channelsVisible && eventsVisible && requestsVisible; + } + + public boolean areChannelsVisible() { + return channelsVisible; + } + + public boolean areEventsVisible() { + return eventsVisible; + } + + public boolean areRequestsVisible() { + return requestsVisible; + } + + public void setChannelsVisible(boolean b) { + channelsVisible = b; + } + + public void setEventsVisible(boolean b) { + eventsVisible = b; + } + + public void setRequestsVisible(boolean b) { + requestsVisible = b; + } +} diff --git a/src/main/java/ui/het/CAMSBlockDiagramToolBar.java b/src/main/java/ui/het/CAMSBlockDiagramToolBar.java new file mode 100755 index 0000000000000000000000000000000000000000..993669fd52105317a60f42e93a515ea6a5ac23c3 --- /dev/null +++ b/src/main/java/ui/het/CAMSBlockDiagramToolBar.java @@ -0,0 +1,134 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package ui.het; + +import ui.MainGUI; +import ui.TGUIAction; +import ui.TToolBar; + +import javax.swing.*; + +/** + * Class TMLTaskDiagramToolBar + * Implements the toolbar to be used in conjunction with the panel of a TMLTask diagram + * Creation: 26/06/2017 + * @version 1.0 26/06/2017 + * @author Côme DEMARIGNY + * @see TMLBlockDiagramToolbar + */ +public class CAMSBlockDiagramToolBar extends TToolBar { + + public CAMSBlockDiagramToolBar(MainGUI _mgui) { + super(_mgui); + + } + + protected void setActive(boolean b) { + mgui.actions[TGUIAction.CAMS_EDIT].setEnabled(b); + mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); + mgui.actions[TGUIAction.CAMS_BLOCK].setEnabled(b); + mgui.actions[TGUIAction.CAMS_CONNECTOR].setEnabled(b); + + mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(true); + mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(true); + mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(true); + + mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); + mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); + mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC].setEnabled(b); + + mgui.updateZoomInfo(); + } + + protected void setButtons() { + JButton button; + + button = this.add(mgui.actions[TGUIAction.CAMS_EDIT]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.UML_NOTE]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.CAMS_BLOCK]); + button.addMouseListener(mgui.mouseHandler); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_ASSOC]); + // button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.CAMS_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + + // this.addSeparator(); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_TASK]); + // button.addMouseListener(mgui.mouseHandler); + + + // this.addSeparator(); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_CHANNEL]); + // button.addMouseListener(mgui.mouseHandler); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_EVENT]); + // button.addMouseListener(mgui.mouseHandler); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_REQ]); + // button.addMouseListener(mgui.mouseHandler); + + + this.addSeparator(); + + // button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID]); + // button.addMouseListener(mgui.mouseHandler); + + } + +} // Class + + + + + diff --git a/src/main/java/ui/het/CAMSConnectingPoint.java b/src/main/java/ui/het/CAMSConnectingPoint.java new file mode 100755 index 0000000000000000000000000000000000000000..7839f4d2d9577949633ba47f9f1dfea748b11e29 --- /dev/null +++ b/src/main/java/ui/het/CAMSConnectingPoint.java @@ -0,0 +1,173 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package ui.het; + +import myutil.GraphicLib; +import ui.*; +import ui.window.JDialogCAMSConnectingPoint; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Point2D; +import javax.swing.*; +import java.util.Vector; + + +/** + * Class SystemCAMSConnectingPoint + * Definition of connecting points on which attribute connectors can be connected + * Creation: 27/06/2017 + * @version 1.0 27/06/2017 + * @author Côme Demarigny + */ +public class CAMSConnectingPoint extends TGConnectingPointWidthHeight { + + protected int x, y; // relative cd and center of the point + protected int state; + protected CDElement container; + private boolean free = true; + protected boolean editable= true; + + private int id; + + protected TGConnectingPointGroup cpg; + + public String type, rate, ccpName = "Connection"; + + protected boolean in; + protected boolean out; + protected boolean hybrid; + + public JDialogCAMSConnectingPoint dialog; + + protected Color myColor; + + protected static final Color IN = Color.gray; + protected static final Color OUT = Color.black; + protected static final Color INOUT = Color.red; + protected static final Color NO = Color.white; + + + protected TGConnector referenceToConnector; + + public CAMSConnectingPoint (CDElement _container, int _x, int _y, boolean _in, boolean _out,boolean _hybrid, double _w, double _h) { + super(_container, _x, _y, _in, _out, _w, _h); + hybrid = _hybrid; + + //color selection + if (_in) { + if (_out) { + myColor = INOUT; + } else { + myColor = IN; + } + } else { + if (_out) { + myColor = OUT; + } else { + myColor = NO; + } + } + + id = TGComponent.getGeneralId(); + TGComponent.setGeneralId(id + 1); + + } + + // public CAMSConnectingPoint (CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { + // super(_container, _x, _y, _in, _out, _w, _h); + // CAMSConnectingPoint camsco = new CAMSConnectingPoint (_container, _x, _y, _in, _out, false, _w, _h); + // } + + public void draw(Graphics g) { + int mx = getX(); + int my = getY(); + g.setColor(myColor); + + //taking into account hybrid connectors + if(this.hybrid==false){ + g.fillRect(mx - width, my - width, width*2, height*2); + }else if (this.in==true){ + System.out.println("test"); + g.setColor(Color.white); + g.fillRect(mx - width, my - width, width*2, height*2); + g.setColor(myColor); + g.fillRect(mx - width, my - width, width, height*2); + }else { + g.setColor(Color.white); + g.fillRect(mx - width, my - width, width*2, height*2); + g.setColor(myColor); + g.fillRect(mx - width, my - width, width, height*2); + } + + GraphicLib.doubleColorRect(g, mx - width, my - width, width*2, height*2, Color.white, Color.black); + } + + public boolean editOndoubleClick(JFrame frame) { + + if(dialog == null){ + dialog = new JDialogCAMSConnectingPoint(frame, "Setting connector attributes", this); + } + dialog.setSize(350, 300); + GraphicLib.centerOnParent(dialog); + dialog.setVisible(true); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + return true; + } + + public String getccpName() { + return ccpName; + } + + public String getPointType() { + return type; + } + + public String getRate() { + return rate; + } + +} //class diff --git a/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java b/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java index 5c20aa99e507c80ac7f83c5ad7419eea9aec4809..17b99582ac483ec55e0ad9263f1f514c4dfc4cf6 100755 --- a/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java +++ b/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java @@ -548,7 +548,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent for (TGComponent req: tdp.getMGUI().getAllRequirements()){ //System.out.println("req " + req); if (req instanceof AvatarRDRequirement){ - refs.add(((AvatarRDRequirement) req).getID()+ ":" + ((AvatarRDRequirement) req).getText()); + refs.add(((AvatarRDRequirement) req).getID()+ ":" + ((AvatarRDRequirement) req).getText().trim()); } } @@ -583,6 +583,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent oldTypep = typep; typep = jda.getPortType(); checkConf = jda.checkConf; + referenceReq = jda.getReferenceReq(); if (checkConf){ if (checkConfStatus==NOCHECK){ checkConfStatus=TOCHECK; @@ -650,6 +651,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent sb.append("\" checkAuth=\"" + checkAuth); sb.append("\" checkWeakAuthStatus=\"" + checkWeakAuthStatus); sb.append("\" checkStrongAuthStatus=\"" + checkStrongAuthStatus); + sb.append("\" referenceReq=\"" + referenceReq); sb.append("\" />\n"); for(int i=0; i<nbMaxAttribute; i++) { //System.out.println("Attribute:" + i); @@ -710,7 +712,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent if (elt.getTagName().equals("Prop")) { commName = elt.getAttribute("commName"); - + referenceReq = elt.getAttribute("referenceReq"); try { //System.out.println("Setting type"); typep = Integer.decode(elt.getAttribute("commType")).intValue(); @@ -719,6 +721,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent maxSamples = Integer.decode(elt.getAttribute("maxSamples")).intValue(); //System.out.println("Setting width"); widthSamples = Integer.decode(elt.getAttribute("widthSamples")).intValue(); + } catch (Exception e) { } diff --git a/src/main/java/ui/tmldd/TMLArchiBUSNode.java b/src/main/java/ui/tmldd/TMLArchiBUSNode.java index c879ad3fc2630a63a5d6aa2eca3585f3e1d2055f..cb731ab15ef593fbfa48fae512a496cdefd6349f 100755 --- a/src/main/java/ui/tmldd/TMLArchiBUSNode.java +++ b/src/main/java/ui/tmldd/TMLArchiBUSNode.java @@ -49,9 +49,11 @@ import tmltranslator.HwBus; import ui.*; import ui.util.IconManager; import ui.window.JDialogBUSNode; +import ui.atd.ATDAttack; import javax.swing.*; import java.awt.*; +import java.util.Vector; /** * Class TMLArchiBUSNode @@ -73,7 +75,7 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo private int sliceTime = HwBus.DEFAULT_SLICE_TIME; private int privacy = HwBus.BUS_PUBLIC; - + public String referenceAttack; public TMLArchiBUSNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -195,6 +197,10 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo } + public String getRefAttack(){ + return referenceAttack; + } + public String getNodeName() { return name; } @@ -204,8 +210,14 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo String errors = ""; int tmp; String tmpName; - - JDialogBUSNode dialog = new JDialogBUSNode(frame, "Setting VGMN attributes", this); + Vector<String> attacks = new Vector<String>(); + for (TGComponent attack: tdp.getMGUI().getAllAttacks()){ + if (attack instanceof ATDAttack){ + attacks.add(((ATDAttack) attack).getValue().trim()); + } + } + + JDialogBUSNode dialog = new JDialogBUSNode(frame, "Setting VGMN attributes", this, attacks); // dialog.setSize(500, 450); GraphicLib.centerOnParent(dialog, 500, 450); dialog.setVisible( true ); // blocked until dialog has been closed @@ -227,6 +239,7 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo arbitrationPolicy = dialog.getArbitrationPolicy(); privacy = dialog.getPrivacy(); + referenceAttack = dialog.getReferenceAttack(); if (arbitrationPolicy == HwBus.BASIC_ROUND_ROBIN) { stereotype = "BUS-RR"; } @@ -303,6 +316,7 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo } } + if (error) { JOptionPane.showMessageDialog(frame, "Invalid value for the following attributes: " + errors, @@ -329,6 +343,7 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo sb.append(" pipelineSize=\"" + pipelineSize + "\" "); sb.append(" clockRatio=\"" + clockRatio + "\" "); sb.append(" privacy=\"" + privacy + "\" "); + sb.append(" referenceAttack=\"" + referenceAttack + "\" "); sb.append("/>\n"); sb.append("</extraparam>\n"); return new String(sb); @@ -365,6 +380,7 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo } if (elt.getTagName().equals("attributes")) { byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + referenceAttack = elt.getAttribute("referenceAttack"); arbitrationPolicy =Integer.decode(elt.getAttribute("arbitrationPolicy")).intValue(); pipelineSize = Integer.decode(elt.getAttribute("pipelineSize")).intValue(); if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); diff --git a/src/main/java/ui/tmldd/TMLArchiCAMSNode.java b/src/main/java/ui/tmldd/TMLArchiCAMSNode.java new file mode 100755 index 0000000000000000000000000000000000000000..0795ccc507b311547ae7d31dc736ef27409e8056 --- /dev/null +++ b/src/main/java/ui/tmldd/TMLArchiCAMSNode.java @@ -0,0 +1,405 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package ui.tmldd; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import tmltranslator.HwCPU; +import ui.*; +import ui.het.*; +import ui.util.IconManager; + +import javax.swing.*; +import java.awt.*; +import java.util.Vector; + +/** + * Class TMLArchiCAMSNode + * System C-AMS Node. To be used in TML architecture diagrams. + * Creation: 06/09/2017 + * @version 1.0 06/09/2017 + * @author Côme DEMARIGNY + */ +public class TMLArchiCAMSNode extends TMLArchiNode implements SwallowTGComponent, WithAttributes { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "CAMS"; + + private int byteDataSize = HwCPU.DEFAULT_BYTE_DATA_SIZE; + private int execiTime = HwCPU.DEFAULT_EXECI_TIME; + + private CAMSBlockDiagramPanel cbdp; + + + public TMLArchiCAMSNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 200; + height = 200; + minWidth = 100; + minHeight = 100; + + nbConnectingPoint = 16; + connectingPoint = new TGConnectingPoint[16]; + + connectingPoint[0] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); + connectingPoint[1] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[2] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.0); + connectingPoint[3] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[4] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 1.0); + connectingPoint[6] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[7] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 1.0); + + connectingPoint[8] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[9] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[10] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[11] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[12] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[13] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[14] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[15] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("CAMS"); + value = "name"; + + myImageIcon = IconManager.imgic700; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.HWA_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + g.setFont(f); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, x + (width - w)/2, y + textY2); + + // Icon + g.drawImage(IconManager.imgic1106.getImage(), x + 4, y + 4, null); + g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + + Polygon pol = new Polygon(); + pol.addPoint(x, y); + pol.addPoint(x + derivationx, y - derivationy); + pol.addPoint(x + derivationx + width, y - derivationy); + pol.addPoint(x + derivationx + width, y + height - derivationy); + pol.addPoint(x + width, y + height); + pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { + return this; + } + + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public String getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + if ( cbdp == null){ + MainGUI mgui = tdp.getMainGUI(); + cbdp = mgui.addSystemCAMSPanel("System C-AMS Deployment of DIPLODOCUS Node", -1, this); + cbdp.setVisible(true); + cbdp.initFromDiplodocus(); + + } + return true; + } + + // boolean error = false; + // String errors = ""; + // int tmp; + // String tmpName; + + // JDialogHwANode dialog = new JDialogHwANode(frame, "Setting HWA attributes", this); + // // dialog.setSize(500, 450); + // GraphicLib.centerOnParent(dialog, 500, 450); + // dialog.setVisible( true ); // blocked until dialog has been closed + + // if (!dialog.isRegularClose()) { + // return false; + // } + + // if (dialog.getNodeName().length() != 0) { + // tmpName = dialog.getNodeName(); + // tmpName = tmpName.trim(); + // if (!TAttribute.isAValidId(tmpName, false, false)) { + // error = true; + // errors += "Name of the node "; + // } else { + // name = tmpName; + // } + // } + + // if (dialog.getByteDataSize().length() != 0) { + // try { + // tmp = byteDataSize; + // byteDataSize = Integer.decode(dialog.getByteDataSize()).intValue(); + // if (byteDataSize <= 0) { + // byteDataSize = tmp; + // error = true; + // errors += "Data size "; + // } + // } catch (Exception e) { + // error = true; + // errors += "Data size "; + // } + // } + + // if (dialog.getExeciTime().length() != 0) { + // try { + // tmp = execiTime; + // execiTime = Integer.decode(dialog.getExeciTime()).intValue(); + // if (execiTime < 0) { + // execiTime = tmp; + // error = true; + // errors += "execi time "; + // } + // } catch (Exception e) { + // error = true; + // errors += "execi time "; + // } + // } + + // if (dialog.getClockRatio().length() != 0) { + // try { + // tmp = clockRatio; + // clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + // if (clockRatio <= 0) { + // clockRatio = tmp; + // error = true; + // errors += "Clock divider "; + // } + // } catch (Exception e) { + // error = true; + // errors += "Clock divider "; + // } + // } + + // if (error) { + // JOptionPane.showMessageDialog(frame, + // "Invalid value for the following attributes: " + errors, + // "Error", + // JOptionPane.INFORMATION_MESSAGE); + // return false; + // } + + // return true; + // } + + + public int getType() { + return TGComponentManager.TMLARCHI_CAMSNODE; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + return (tgc instanceof TMLArchiArtifact) && (nbInternalTGComponent == 0); + + } + + public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { + if ((tgc instanceof TMLArchiArtifact) && (nbInternalTGComponent == 0)){ + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + + return false; + } + + public void removeSwallowedTGComponent(TGComponent tgc) { + removeInternalComponent(tgc); + } + + + public Vector<TMLArchiArtifact> getArtifactList() { + Vector<TMLArchiArtifact> v = new Vector<TMLArchiArtifact>(); + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof TMLArchiArtifact) { + v.add( (TMLArchiArtifact) tgcomponent[i]); + } + } + + return v; + } + + public void hasBeenResized() { + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof TMLArchiArtifact) { + tgcomponent[i].resizeWithFather(); + } + } + + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + sb.append("<attributes byteDataSize=\"" + byteDataSize + "\" "); + sb.append(" execiTime=\"" + execiTime + "\" "); + sb.append(" clockRatio=\"" + clockRatio + "\" "); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + @Override + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + // int t1id; + String sstereotype = null, snodeName = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + + if (elt.getTagName().equals("attributes")) { + byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + execiTime = Integer.decode(elt.getAttribute("execiTime")).intValue(); + if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ + clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); + } + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_NODE_TMLARCHI; + } + + public int getByteDataSize(){ + return byteDataSize; + } + + public int getExeciTime(){ + return execiTime; + } + + + public String getAttributes() { + String attr = ""; + attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Execi execution time (in cycle) = " + execiTime + "\n"; + attr += "Clock divider = " + clockRatio + "\n"; + return attr; + } + + public int getComponentType() { + return CONTROLLER; + } + +} diff --git a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java index 2c061d023edcdae704e026837f0cfd70ebe8738d..ac1070c2493207316c65302876f32c4f38234969 100755 --- a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java +++ b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java @@ -37,6 +37,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmldd; import myutil.TraceManager; @@ -52,7 +55,7 @@ import java.awt.event.ActionListener; * Class TMLArchiDiagramToolBar * Implements the toolbar to be used in conjunction with the panel of a TML Architecture diagram * Creation: 18/09/2007 - * @version 1.0 18/09/2007 + * @version 1.0 08/09/2017 * @author Ludovic APVRILLE * @see ui.cd.TClassDiagramPanel */ @@ -73,6 +76,7 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener mgui.actions[TGUIAction.TMLARCHI_LINK].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_CPUNODE].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_HWANODE].setEnabled(b); + mgui.actions[TGUIAction.TMLARCHI_CAMSNODE].setEnabled(b); //ajout CD mgui.actions[TGUIAction.TMLARCHI_BUSNODE].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_CPNODE].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_BRIDGENODE].setEnabled(b); @@ -121,6 +125,8 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener button.addMouseListener(mgui.mouseHandler); button = this.add(mgui.actions[TGUIAction.TMLARCHI_HWANODE]); button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.TMLARCHI_CAMSNODE]); //ajout CD + button.addMouseListener(mgui.mouseHandler); button = this.add(mgui.actions[TGUIAction.TMLARCHI_ARTIFACT]); button.addMouseListener(mgui.mouseHandler); @@ -137,32 +143,26 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener button.addMouseListener(mgui.mouseHandler); button = this.add(mgui.actions[TGUIAction.TMLARCHI_MEMORYNODE]); button.addMouseListener(mgui.mouseHandler); - this.addSeparator(); + this.addSeparator(); - button = this.add(mgui.actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT]); + button = this.add(mgui.actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT]); button.addMouseListener(mgui.mouseHandler); /*button = this.add(mgui.actions[TGUIAction.TMLARCHI_EVENT_ARTIFACT]); button.addMouseListener(mgui.mouseHandler);*/ - - // Issue #66: CP mapping now part of core functions - this.addSeparator(); - button = this.add( mgui.actions[ TGUIAction.TMLARCHI_CPNODE ] ); - button.addMouseListener( mgui.mouseHandler ); - if ( MainGUI.experimentalOn ) { -// this.addSeparator(); -// button = this.add(mgui.actions[TGUIAction.TMLARCHI_CPNODE]); -// button.addMouseListener(mgui.mouseHandler); - button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]); + if (MainGUI.experimentalOn) { + this.addSeparator(); + button = this.add(mgui.actions[TGUIAction.TMLARCHI_CPNODE]); button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]); + button.addMouseListener(mgui.mouseHandler); } - - this.addSeparator(); + this.addSeparator(); button = this.add(mgui.actions[TGUIAction.TMLARCHI_KEY]); button.addMouseListener(mgui.mouseHandler); - button = this.add(mgui.actions[TGUIAction.TMLARCHI_FIREWALL]); + button = this.add(mgui.actions[TGUIAction.TMLARCHI_FIREWALL]); button.addMouseListener(mgui.mouseHandler); @@ -175,7 +175,7 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID]); button.addMouseListener(mgui.mouseHandler); - setPluginButtons("TMLArchiDiagramPanel"); + setPluginButtons("TMLArchiDiagramPanel"); this.addSeparator(); if (viewInfos == null) { @@ -184,20 +184,22 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener box = new JComboBox<>(viewInfos); this.add(box); box.addActionListener(this); + + } public void setPanel(TMLArchiDiagramPanel _panel) { panel = _panel; } - @Override + public void actionPerformed(ActionEvent e) { - super.actionPerformed(e); - - if (e.getSource() == box) { + super.actionPerformed(e); + if (e.getSource() == box) { if (panel != null) { panel.setCurrentView(box.getSelectedIndex()); } } } + } // Class diff --git a/src/main/java/ui/window/JDialogBUSNode.java b/src/main/java/ui/window/JDialogBUSNode.java index fdc82228ab56915cfdec42395a14423a33824d35..a8bb5455608ef9a8cc7b6e349cd40a97db1f9d57 100755 --- a/src/main/java/ui/window/JDialogBUSNode.java +++ b/src/main/java/ui/window/JDialogBUSNode.java @@ -48,7 +48,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - +import java.util.Vector; /** * Class JDialogBUSNode @@ -69,15 +69,15 @@ public class JDialogBUSNode extends javax.swing.JDialog implements ActionListene // Panel2 protected JTextField byteDataSize, pipelineSize, clockRatio; - private JComboBox<String> arbitrationPolicy, privacy; + private JComboBox<String> arbitrationPolicy, privacy, refAttacks; protected JTextField sliceTime; - + private Vector<String> refs; /** Creates new form */ - public JDialogBUSNode(Frame _frame, String _title, TMLArchiBUSNode _node) { + public JDialogBUSNode(Frame _frame, String _title, TMLArchiBUSNode _node, Vector<String> _refs) { super(_frame, _title, true); node = _node; - + refs= _refs; initComponents(); myInitComponents(); pack(); @@ -166,6 +166,13 @@ public class JDialogBUSNode extends javax.swing.JDialog implements ActionListene privacy.setSelectedIndex(node.getPrivacy()); panel2.add(privacy, c2); + c2.gridwidth = 1; + panel2.add(new JLabel("Reference Attack:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + refAttacks = new JComboBox<>(refs); + refAttacks.setSelectedItem(node.getRefAttack()); + panel2.add(refAttacks, c2); + // main panel; c0.gridheight = 10; c0.weighty = 1.0; @@ -241,6 +248,10 @@ public class JDialogBUSNode extends javax.swing.JDialog implements ActionListene public int getPrivacy(){ return privacy.getSelectedIndex(); } + + public String getReferenceAttack(){ + return (String) refAttacks.getSelectedItem(); + } public String getSliceTime() { return sliceTime.getText(); } diff --git a/src/main/java/ui/window/JDialogCAMSBlocks.java b/src/main/java/ui/window/JDialogCAMSBlocks.java new file mode 100755 index 0000000000000000000000000000000000000000..9ae2084b9ac86042887dee4ccd06a7dcdc109d0d --- /dev/null +++ b/src/main/java/ui/window/JDialogCAMSBlocks.java @@ -0,0 +1,846 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package ui.window; + +import myutil.Conversion; +import myutil.GraphicLib; +import ui.util.IconManager; +import ui.TGComponent; +import ui.het.CAMSBlock; +import heterogeneoustranslator.systemCAMStranslator.CAMSSignal; +import ui.TAttribute; +import ui.TDiagramPanel; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Vector; +import java.util.LinkedList; + + +/** + * Class JDialogCAMSBlocks + * Dialog for managing nodes to be validated + * Creation: 23/06/2017 + * @version 0.1 23/06/2017 + * @author Côme DEMARIGNY + */ + +public class JDialogCAMSBlocks extends javax.swing.JDialog implements ActionListener, ListSelectionListener { + + private LinkedList<TAttribute> attributes, attributesPar, forbidden; + private LinkedList<Boolean> initValues; + private LinkedList<CAMSSignal> signals, signalsPar; + private boolean checkKeyword, checkJavaKeyword; + + private boolean cancelled = false; + private boolean regularClose; + + protected String [] processCode; + protected JTextArea jtaProcessCode; + protected boolean hasProcessCode; + + private JPanel panel1, panel2; + + private TDiagramPanel tdp; + private Frame frame; + private int tab; + private String defaultName; + private String previousName; + + private String attrib; // "Attributes", "Gates", etc. + + // Panel1 + private JComboBox<String> accessBox, typeBox; + private JTextField identifierText; + private JTextField initialValue; + private JTextField blockName; + private JButton addButton; + + //Panel2 + private JList<TAttribute> listAttribute; + private JTextField nbOfIn, nbOfOut; + private CAMSBlock block; + private JButton upButton; + private JButton downButton; + private JButton removeButton; + + + // Signals + private boolean hasSignals = true; + private JPanel panel5, panel6; + private JComboBox<String> signalInOutBox; + private JTextField signalText; + private JButton addSignalButton; + private JList<CAMSSignal> listSignal; + private JButton upSignalButton; + private JButton downSignalButton; + private JButton removeSignalButton; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /** Creates new form */ + public JDialogCAMSBlocks(LinkedList<TAttribute> _attributes, LinkedList<CAMSSignal> _signals, LinkedList<TAttribute> _forbidden, Frame _frame, String _title, String _attrib, CAMSBlock _block, String []_processCode, boolean _hasProcessCode) { + super(_frame, _title, true); + frame = _frame; + block = _block; + attributesPar = _attributes; + signalsPar = _signals; + processCode = _processCode; + attrib = _attrib; + + if (signalsPar == null) { + signalsPar = new LinkedList<CAMSSignal> (); + hasSignals = false; + } + + hasProcessCode = _hasProcessCode; + if (processCode == null) { + processCode = new String[1]; + processCode[0] = ""; + } + + + forbidden = _forbidden; + initValues = new LinkedList<Boolean> (); + this.attrib = attrib; + + attributes = new LinkedList<TAttribute> (); + signals = new LinkedList<CAMSSignal> (); + + for(TAttribute attr: this.attributesPar) + this.attributes.add (attr.makeClone()); + + // for(CAMSSignal sig: this.signalsPar) + // this.signals.add (sig.makeClone()); + pack(); + initComponents(); + myInitComponents(); + pack(); + } + + + private void myInitComponents() { + removeButton.setEnabled(false); + upButton.setEnabled(false); + downButton.setEnabled(false); + } + + private void initComponents() { + + // Issue #41 Ordering of tabbed panes + JTabbedPane tabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane(); + Container c = getContentPane(); + + JPanel panelAttr = new JPanel(new BorderLayout()); + JPanel panelSignal = new JPanel(new BorderLayout()); + JPanel panelCode; + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagLayout gridbag2 = new GridBagLayout(); + // GridBagLayout gridbag3 = new GridBagLayout(); + // GridBagLayout gridbag4 = new GridBagLayout(); + GridBagLayout gridbag5 = new GridBagLayout(); + GridBagLayout gridbag6 = new GridBagLayout(); + GridBagLayout gridbag7 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + GridBagConstraints c1 = new GridBagConstraints(); + GridBagConstraints c2 = new GridBagConstraints(); + // GridBagConstraints c3 = new GridBagConstraints(); + // GridBagConstraints c4 = new GridBagConstraints(); + GridBagConstraints c5 = new GridBagConstraints(); + GridBagConstraints c6 = new GridBagConstraints(); + GridBagConstraints c7 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + panel1 = new JPanel(); + panel1.setLayout(gridbag1); + panel1.setBorder(new javax.swing.border.TitledBorder("Adding " + attrib)); + panel1.setPreferredSize(new Dimension(500, 500)); + panel1.setMinimumSize(new Dimension(500, 500)); + + panel2 = new JPanel(); + panel2.setLayout(gridbag2); + panel2.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib)); + panel2.setPreferredSize(new Dimension(500, 500)); + panel2.setMinimumSize(new Dimension(500, 500)); + + // first line panel1 + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.BOTH; + c1.gridheight = 3; + panel1.add(new JLabel("Block Name: "), c1); + blockName = new JTextField(); + blockName.setColumns(5); + blockName.setEditable(true); + panel1.add(blockName, c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + panel1.add(new JLabel("access"), c1); + panel1.add(new JLabel("identifier"), c1); + if (attrib.equals("Attribute") || attrib.equals("Variable")) { + panel1.add(new JLabel(" "), c1); + panel1.add(new JLabel("initial value"), c1); + } + panel1.add(new JLabel(" "), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + panel1.add(new JLabel("type"), c1); + + // second line panel1 + c1.gridwidth = 2; + c1.fill = GridBagConstraints.HORIZONTAL; + c1.anchor = GridBagConstraints.CENTER; + accessBox = new JComboBox<String>(); + panel1.add(accessBox, c1); + identifierText = new JTextField(); + identifierText.setColumns(15); + identifierText.setEditable(true); + panel1.add(identifierText, c1); + + initialValue = new JTextField(); + initialValue.setColumns(5); + initialValue.setEditable(true); + + if (attrib.equals("Attribute") || attrib.equals("Variable")) { + panel1.add(new JLabel(" = "), c1); + panel1.add(initialValue, c1); + } + + panel1.add(new JLabel(" : "), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + typeBox = new JComboBox<String>(); + typeBox.addActionListener(this); + panel1.add(typeBox, c1); + + // third line panel1 + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.BOTH; + c1.gridheight = 3; + panel1.add(new JLabel(" "), c1); + + // fourth line panel1 + c1.gridheight = 1; + c1.fill = GridBagConstraints.HORIZONTAL; + addButton = new JButton("Add / Modify " + attrib); + addButton.addActionListener(this); + panel1.add(addButton, c1); + + // 1st line panel2 + listAttribute = new JList<TAttribute> (this.attributes.toArray (new TAttribute[0])); + listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listAttribute.addListSelectionListener(this); //fixme + JScrollPane scrollPane = new JScrollPane(listAttribute); + scrollPane.setSize(500, 500); + c2.gridwidth = 2; //end row + c2.fill = GridBagConstraints.BOTH; + c2.gridheight = 5; + c2.weighty = 10.0; + c2.weightx = 10.0; + panel2.add(scrollPane, c2); + + // 2nd line panel2 + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.BOTH; + c2.gridheight = 1; + panel2.add(new JLabel(""), c2); + + // third line panel2 + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + c2.fill = GridBagConstraints.HORIZONTAL; + upButton = new JButton(" Up "); + upButton.addActionListener(this); + panel2.add(upButton, c2); + + downButton = new JButton("Down"); + downButton.addActionListener(this); + panel2.add(downButton, c2); + + removeButton = new JButton("Remove " + attrib); + removeButton.addActionListener(this); + panel2.add(removeButton, c2); + + // Signals + panel5 = new JPanel(); + panel5.setLayout(gridbag5); + panel5.setBorder(new javax.swing.border.TitledBorder("Adding signals")); + panel5.setPreferredSize(new Dimension(500, 500)); + + panel6 = new JPanel(); + panel6.setLayout(gridbag6); + panel6.setBorder(new javax.swing.border.TitledBorder("Managing signals")); + panel6.setPreferredSize(new Dimension(500, 500)); + + // first line panel5 + c5.gridwidth = 1; + c5.gridheight = 1; + c5.weighty = 1.0; + c5.weightx = 1.0; + c5.gridwidth = GridBagConstraints.REMAINDER; //end row + c5.fill = GridBagConstraints.BOTH; + c5.gridheight = 3; + panel5.add(new JLabel(" "), c5); + + c5.gridwidth = 1; + c5.gridheight = 1; + c5.weighty = 1.0; + c5.weightx = 1.0; + c5.anchor = GridBagConstraints.CENTER; + c5.gridwidth = GridBagConstraints.REMAINDER; //end row + panel5.add(new JLabel("signal:"), c5); + + // second line panel5 + c5.gridwidth = 1; + c5.fill = GridBagConstraints.HORIZONTAL; + String[] v = new String[4]; + v[0] = "in"; + v[1] = "out"; + v[2] = "hybrid in"; + v[3] = "hybrid out"; + signalInOutBox = new JComboBox<String>(v); + panel5.add(signalInOutBox, c5); + signalText = new JTextField(); + signalText.setColumns(50); + signalText.setEditable(true); + panel5.add(signalText, c5); + + // third line panel5 + c5.gridwidth = GridBagConstraints.REMAINDER; //end row + c5.fill = GridBagConstraints.BOTH; + c5.gridheight = 3; + panel5.add(new JLabel(" "), c5); + + // fourth line panel5 + c5.gridheight = 1; + c5.fill = GridBagConstraints.HORIZONTAL; + addSignalButton = new JButton("Add signal"); + addSignalButton.addActionListener(this); + panel5.add(addSignalButton, c5); + + // 1st line panel6 + listSignal = new JList<CAMSSignal> (this.signals.toArray (new CAMSSignal[0])); + listSignal.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listSignal.addListSelectionListener(this); + scrollPane = new JScrollPane(listSignal); + scrollPane.setSize(500, 500); + c6.gridwidth = GridBagConstraints.REMAINDER; //end row + c6.fill = GridBagConstraints.BOTH; + c6.gridheight = 5; + c6.weighty = 10.0; + c6.weightx = 10.0; + panel6.add(scrollPane, c6); + + // 2nd line panel4 + c6.weighty = 1.0; + c6.weightx = 1.0; + c6.fill = GridBagConstraints.BOTH; + c6.gridheight = 1; + panel6.add(new JLabel(""), c6); + + // third line panel4 + c6.gridwidth = GridBagConstraints.REMAINDER; //end row + c6.fill = GridBagConstraints.HORIZONTAL; + upSignalButton = new JButton("Up"); + upSignalButton.addActionListener(this); + panel6.add(upSignalButton, c6); + + downSignalButton = new JButton("Down"); + downSignalButton.addActionListener(this); + panel6.add(downSignalButton, c6); + + removeSignalButton = new JButton("Remove signal"); + removeSignalButton.addActionListener(this); + panel6.add(removeSignalButton, c6); + + // Prototyping + panelCode = new JPanel(); + panelCode.setLayout(gridbag7); + + panelCode.setBorder(new javax.swing.border.TitledBorder("Process code")); + // guard + c7.weighty = 1.0; + c7.weightx = 1.0; + c7.gridwidth = 1; + c7.gridheight = 1; + c7.fill = GridBagConstraints.BOTH; + c7.gridwidth = GridBagConstraints.REMAINDER; + c7.gridheight = 1; + + + panelCode.add(new JLabel("Process code of block:"), c7); + //panelCode.add(new JLabel("To implement a method m of block B: \"userImplemented_B_m(...){...}\""), c7); + jtaProcessCode = new JTextArea(); + jtaProcessCode.setEditable(true); + jtaProcessCode.setMargin(new Insets(10, 10, 10, 10)); + jtaProcessCode.setTabSize(3); + String files = ""; + if (processCode != null) { + for(int i=0; i<processCode.length; i++) { + files += processCode[i] + "\n"; + } + } + jtaProcessCode.append(files); + jtaProcessCode.setFont(new Font("times", Font.PLAIN, 12)); + JScrollPane jsp = new JScrollPane(jtaProcessCode, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + jsp.setPreferredSize(new Dimension(500, 500)); + panelCode.add(jsp, c7); + + + // main panel; + panelAttr.add(panel1, BorderLayout.WEST); + panelAttr.add(panel2, BorderLayout.EAST); + tabbedPane.addTab("Attributes", panelAttr); + + if (hasSignals) { + panelSignal.add(panel5, BorderLayout.WEST); + panelSignal.add(panel6, BorderLayout.EAST); + tabbedPane.addTab("Signals", panelSignal); + } + + if (hasProcessCode) { + tabbedPane.addTab("Process", panelCode); + } + + tabbedPane.setSelectedIndex(tab); + + //c.add(panel1, c0); + //c.add(panel2, c0); + + c0.gridwidth = 1; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c0.fill = GridBagConstraints.HORIZONTAL; + c.add(tabbedPane, c0); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + //closeButton.setPreferredSize(new Dimension(600, 50)); + closeButton.addActionListener(this); + c.add(closeButton, c0); + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + c.add(cancelButton, c0); + } + + public void actionPerformed(ActionEvent evt) { + if (evt.getSource() == typeBox) { + boolean b = initValues.get (typeBox.getSelectedIndex()).booleanValue(); + initialValue.setEnabled(b); + return; + } + + + //String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (evt.getSource() == closeButton) { + closeDialog(); + } else if (evt.getSource() == addButton) { + addAttribute(); + } else if (evt.getSource() == cancelButton) { + cancelDialog(); + } else if (evt.getSource() == removeButton) { + removeAttribute(); + } else if (evt.getSource() == downButton) { + downAttribute(); + } else if (evt.getSource() == upButton) { + upAttribute(); + } else if (evt.getSource() == downSignalButton) { + downSignal(); + } else if (evt.getSource() == upSignalButton) { + upSignal(); + } else if (evt.getSource() == removeSignalButton) { + removeSignal(); + } else if (evt.getSource() == addSignalButton) { + addSignal(); + } + } + + public void addAccess(String s) { + accessBox.addItem(s); + } + + public void addType(String s) { + initValues.add(new Boolean(true)); + typeBox.addItem(s); + } + + public void addType(String s, boolean b) { + initValues.add(new Boolean(b)); + typeBox.addItem(s); + } + + public void enableInitialValue(boolean b) { + initialValue.setEnabled(b); + } + + public void enableRTLOTOSKeyword(boolean b) { + checkKeyword = !b; + } + + public void enableJavaKeyword(boolean b) { + checkJavaKeyword = !b; + } + + + + public void addAttribute() { + Object o1 = accessBox.getSelectedItem(); + Object o2 = typeBox.getSelectedItem(); + String s = identifierText.getText(); + String value = initialValue.getText(); + TAttribute a; + + if (s.length()>0) { + if ((TAttribute.isAValidId(s, checkKeyword, checkJavaKeyword)) && (TAttribute.notIn(s, forbidden))){ + int i = TAttribute.getAccess(o1.toString()); + int j = TAttribute.getCAMSType(o2.toString()); + if ((j == TAttribute.ARRAY_NAT) && (value.length() < 1)) { + value = "2"; + } + + if ((i != -1) && (j!= -1)) { + + if ((value.length() < 1) || (initialValue.isEnabled() == false)){ + + value = ""; + } else { + if (!TAttribute.isAValidInitialValue(j, value)) { + JOptionPane.showMessageDialog(frame, + "The initial value is not valid", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } + if (j == TAttribute.OTHER) { + a = new TAttribute(i, s, value, o2.toString()); + a.isCAMS = true; + //System.out.println("New attribute: " + o2.toString()); + } else { + a = new TAttribute(i, s, value, j); + a.isCAMS = true; + } + //checks whether the same attribute already belongs to the list + int index = attributes.size(); + if (attributes.contains(a)) { + index = attributes.indexOf(a); + a = attributes.get (index); + a.setAccess(i); + if (j == TAttribute.OTHER) { + a.setTypeOther(o2.toString()); + } + a.setType(j); + a.setInitialValue(value); + } else { + attributes.add(index, a); + } + listAttribute.setListData(attributes.toArray (new TAttribute[0])); + identifierText.setText(""); + } else { + JOptionPane.showMessageDialog(frame, + "Bad access / type", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } else { + JOptionPane.showMessageDialog(frame, + "Bad identifier: identifier already in use, or invalid identifier", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } else { + JOptionPane.showMessageDialog(frame, + "Bad identifier", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } + + + public void addSignal() { + String s = signalText.getText(); + CAMSSignal cs = CAMSSignal.isAValidSignal(s, signalInOutBox.getSelectedIndex()); + CAMSSignal cstmp; + int inout; + + if (cs != null) { + // Checks whether the same signal already belongs to the list + int index = -1; + for(int i=0; i<signals.size(); i++) { + cstmp = signals.get(i); + // Same id? + if (cstmp.equals(cs)) { + index = i; + break; + } + } + if(signalInOutBox.getSelectedIndex()==0){ + inout=0; + }else if(signalInOutBox.getSelectedIndex()==1){ + inout=1; + }else if(signalInOutBox.getSelectedIndex()==2){ + inout=2; + }else if(signalInOutBox.getSelectedIndex()==3){ + inout=3; + }else{ + inout=-1; + } + cs = new CAMSSignal(s,inout); + if (index == -1) { + signals.add(cs); + } else { + signals.remove (index); + signals.add (index, cs); + } + listSignal.setListData(signals.toArray (new CAMSSignal[0])); + signalText.setText(""); + + } else { + JOptionPane.showMessageDialog(frame, + "Badly formatted signal declaration", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } + + public void removeAttribute() { + int i = listAttribute.getSelectedIndex() ; + if (i!= -1) { + TAttribute a = attributes.get (i); + a.setAccess(-1); + attributes.remove (i); + listAttribute.setListData(attributes.toArray (new TAttribute[0])); + } + } + + public void downAttribute() { + int i = listAttribute.getSelectedIndex(); + if ((i!= -1) && (i != attributes.size() - 1)) { + TAttribute o = attributes.get (i); + attributes.remove (i); + attributes.add (i+1, o); + listAttribute.setListData(attributes.toArray (new TAttribute[0])); + listAttribute.setSelectedIndex(i+1); + } + } + + public void upAttribute() { + int i = listAttribute.getSelectedIndex(); + if (i > 0) { + TAttribute o = attributes.get (i); + attributes.remove (i); + attributes.add (i-1, o); + listAttribute.setListData(attributes.toArray (new TAttribute[0])); + listAttribute.setSelectedIndex(i-1); + } + } + + public void removeSignal() { + int i = listSignal.getSelectedIndex() ; + if (i!= -1) { + signals.remove (i); + listSignal.setListData(signals.toArray (new CAMSSignal [0])); + } + } + + public void upSignal() { + int i = listSignal.getSelectedIndex(); + if (i > 0) { + CAMSSignal o = signals.get (i); + signals.remove (i); + signals.add (i-1, o); + listSignal.setListData(signals.toArray (new CAMSSignal [0])); + listSignal.setSelectedIndex(i-1); + } + } + + public void downSignal() { + int i = listSignal.getSelectedIndex(); + if ((i!= -1) && (i != signals.size() - 1)) { + CAMSSignal o = signals.get (i); + signals.remove(i); + signals.add (i+1, o); + listSignal.setListData(signals.toArray (new CAMSSignal [0])); + listSignal.setSelectedIndex(i+1); + } + } + + + public void closeDialog() { + cancelled = false; + attributesPar.clear (); + for(TAttribute attr: this.attributes) + attributesPar.add (attr); + + signalsPar.clear (); + for(CAMSSignal sig: this.signals) + signalsPar.add (sig); + + processCode = Conversion.wrapText(jtaProcessCode.getText()); + dispose(); + } + + public boolean hasBeenCancelled() { + return cancelled; + } + + public boolean isRegularClose() { + return regularClose; + } + + public void cancelDialog() { + cancelled = true; + dispose(); + } + + public void valueChanged(ListSelectionEvent e) { + int i = listAttribute.getSelectedIndex() ; + if (i == -1) { + removeButton.setEnabled(false); + upButton.setEnabled(false); + downButton.setEnabled(false); + identifierText.setText(""); + //initialValue.setText(""); + } else { + TAttribute a = attributes.get (i); + identifierText.setText(a.getId()); + initialValue.setText(a.getInitialValue()); + select(accessBox, TAttribute.getStringAccess(a.getAccess())); + if (a.getType() == TAttribute.OTHER) { + select(typeBox, a.getTypeOther()); + } else { + //select(typeBox, TAttribute.getStringCAMSType(a.getType())); //fixme + } + removeButton.setEnabled(true); + if (i > 0) { + upButton.setEnabled(true); + } else { + upButton.setEnabled(false); + } + if (i != attributes.size() - 1) { + downButton.setEnabled(true); + } else { + downButton.setEnabled(false); + } + } + + i = listSignal.getSelectedIndex() ; + if (i == -1) { + removeSignalButton.setEnabled(false); + upSignalButton.setEnabled(false); + downSignalButton.setEnabled(false); + signalText.setText(""); + //initialValue.setText(""); + } else { + CAMSSignal as = signals.get (i); + //signalText.setText(as.toBasicString()); //fixme + // signalInOutBox.setSelectedIndex(as.getInOut()); + removeSignalButton.setEnabled(true); + if (i > 0) { + upSignalButton.setEnabled(true); + } else { + upSignalButton.setEnabled(false); + } + if (i != signals.size() - 1) { + downSignalButton.setEnabled(true); + } else { + downSignalButton.setEnabled(false); + } + } + } + + public void select(JComboBox<String> jcb, String text) { + String s; + for(int i=0; i<jcb.getItemCount(); i++) { + s = jcb.getItemAt(i); + if (s.equals(text)) { + jcb.setSelectedIndex(i); + return; + } + } + } + + + public String getBlockName() { + if(blockName.getText() == null || blockName.getText() == "" || blockName.getText() == " ") { + return "Block0"; + } else { + return blockName.getText(); + } + } + + public LinkedList<CAMSSignal> getSignals(){ + return signals; + } + + public String[] getProcessCode() { + return processCode; + } + +} diff --git a/src/main/java/ui/window/JDialogCAMSConnectingPoint.java b/src/main/java/ui/window/JDialogCAMSConnectingPoint.java new file mode 100755 index 0000000000000000000000000000000000000000..cb85316df4063c7d07b5a9df519087f3bc304585 --- /dev/null +++ b/src/main/java/ui/window/JDialogCAMSConnectingPoint.java @@ -0,0 +1,211 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + +package ui.window; + +import ui.util.IconManager; +import ui.het.*; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +//import javax.swing.event.*; +//import java.util.*; + + +/** +* Class JDialogADDCPUNode +* Dialog for managing attributes of cpu nodes in ADD +* Creation: 02/07/2014 +* @version 1.0 02/07/2014 +* @author Ludovic APVRILLE + */ +public class JDialogCAMSConnectingPoint extends javax.swing.JDialog implements ActionListener { + + private boolean regularClose; + + private JPanel panel2; + private Frame frame; + public CAMSConnectingPoint ccp; + + protected JComboBox<String> tracemode; + private static int selectedTracemode = 0; + + + // Panel1 + protected JTextField ccpName; + + // Panel2 + protected JTextField type, rate; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /** Creates new form */ + public JDialogCAMSConnectingPoint(Frame _frame, String _title, CAMSConnectingPoint _ccp) { + super(_frame, _title, true); + frame = _frame; + ccp = _ccp; + + initComponents(); + myInitComponents(); + pack(); + } + + private void myInitComponents() { + } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + //GridBagConstraints c1 = new GridBagConstraints(); + GridBagConstraints c2 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + + panel2 = new JPanel(); + panel2.setLayout(gridbag2); + panel2.setBorder(new javax.swing.border.TitledBorder("Connecting Point attributes")); + panel2.setPreferredSize(new Dimension(400, 300)); + + c2.gridwidth = 1; + c2.gridheight = 1; + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + panel2.add(new JLabel("Connecting Point name:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + ccpName = new JTextField(ccp.getccpName(), 30); + ccpName.setEditable(true); + ccpName.setFont(new Font("times", Font.PLAIN, 12)); + panel2.add(ccpName, c2); + + c2.gridwidth = 1; + c2.gridheight = 1; + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + + + c2.gridwidth = 1; + panel2.add(new JLabel("Type :"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + type = new JTextField(""+ccp.getPointType(), 15); + panel2.add(type, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Rate:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + rate = new JTextField(""+ccp.getRate(), 15); + panel2.add(rate, c2); + + // main panel; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c.add(panel2, c0); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + //closeButton.setPreferredSize(new Dimension(600, 50)); + closeButton.addActionListener(this); + c.add(closeButton, c0); + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + c.add(cancelButton, c0); + } + + public void actionPerformed(ActionEvent evt) { + + if (evt.getSource() == tracemode) { + selectedTracemode = tracemode.getSelectedIndex(); + } + + String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (command.equals("Save and Close")) { + closeDialog(); + } else if (command.equals("Cancel")) { + cancelDialog(); + } + } + + public void closeDialog() { + regularClose = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean isRegularClose() { + return regularClose; + } + + public String getccpName() { + return ccpName.getText(); + } + + public String getPointType() { + return type.getText(); + } + + public String getRate() { + return rate.getText(); + } + +}//class \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSelectSystemCAMSBlock.java b/src/main/java/ui/window/JDialogSelectSystemCAMSBlock.java index dc13279e3a4fcd0b9ecafd99746abfdf254a60be..2d2a66b1101f2635fb985e84ff86ab0e4435f261 100755 --- a/src/main/java/ui/window/JDialogSelectSystemCAMSBlock.java +++ b/src/main/java/ui/window/JDialogSelectSystemCAMSBlock.java @@ -45,7 +45,7 @@ package ui.window; import myutil.TraceManager; import ui.util.IconManager; import ui.TGComponent; -//import ui.het.*; +import ui.het.*; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -122,17 +122,17 @@ public class JDialogSelectSystemCAMSBlock extends javax.swing.JDialog implements for( int i = 0; i < list.size(); i++ ) { tgc = list.get(i); // System.out.println(tgc); - //if (tgc instanceof CAMSBlock) { - // v.addElement( tgc ); - //} + if (tgc instanceof CAMSBlock) { + v.addElement( tgc ); + } } return v; } private void checkBlock( Vector<TGComponent> tobeChecked, List<TGComponent> source ) { - /*CAMSBlock block; - + CAMSBlock block; + for(int i = 0; i < tobeChecked.size(); i++ ) { if( tobeChecked.elementAt(i) instanceof CAMSBlock ){ block = (CAMSBlock) tobeChecked.elementAt(i); @@ -141,12 +141,12 @@ public class JDialogSelectSystemCAMSBlock extends javax.swing.JDialog implements i--; } } - }*/ + } } public void addNewBlock( Vector<TGComponent> added, List<TGComponent> source, Vector<TGComponent> notSource ) { - /*TGComponent tgc; + TGComponent tgc; for( int i = 0; i < source.size(); i++ ) { tgc = source.get(i); @@ -154,7 +154,7 @@ public class JDialogSelectSystemCAMSBlock extends javax.swing.JDialog implements added.addElement( tgc ); System.out.println("New element"); } - }*/ + } } private void myInitComponents() { diff --git a/src/main/java/ui/window/JDialogTMLCompositePort.java b/src/main/java/ui/window/JDialogTMLCompositePort.java index ed4c1fef805eb3226f53b649b2ecbfdb5b040457..764c805faedefb5734c5a40dfe84af7c560c37f2 100755 --- a/src/main/java/ui/window/JDialogTMLCompositePort.java +++ b/src/main/java/ui/window/JDialogTMLCompositePort.java @@ -88,13 +88,13 @@ public class JDialogTMLCompositePort extends JDialog implements ActionListener { private Vector<String> origins, finites, blockings, portTypes, types1, types2, types3, types4, types5; private Vector<String> types; private Vector<String> refs; - + private String referenceReq; // Robustness private JCheckBox isLossyBox, isPrexCB, isPostexCB, confCheckBox, authCheckBox; private JTextField lossPercentageText, maxNbOfLossText; - public JDialogTMLCompositePort(String _name, int _portIndex, TType _type1, TType _type2, TType _type3, TType _type4, TType _type5, boolean _isOrigin, boolean _isFinite, boolean _isBlocking, String _maxInFIFO, String _widthSamples, boolean _isLossy, int _lossPercentage, int _maxNbOfLoss, Frame f, String title, Vector<String> _types, String _dataFlowType, String _associatedEvent, boolean _isPrex, boolean _isPostex , boolean _checkConf, boolean _checkAuth, String referenceReq, Vector<String> _refs) { + public JDialogTMLCompositePort(String _name, int _portIndex, TType _type1, TType _type2, TType _type3, TType _type4, TType _type5, boolean _isOrigin, boolean _isFinite, boolean _isBlocking, String _maxInFIFO, String _widthSamples, boolean _isLossy, int _lossPercentage, int _maxNbOfLoss, Frame f, String title, Vector<String> _types, String _dataFlowType, String _associatedEvent, boolean _isPrex, boolean _isPostex , boolean _checkConf, boolean _checkAuth, String _referenceReq, Vector<String> _refs) { super(f, title, true); frame = f; @@ -122,7 +122,7 @@ public class JDialogTMLCompositePort extends JDialog implements ActionListener { checkConf = _checkConf; checkAuth = _checkAuth; refs=_refs; - + referenceReq= _referenceReq; myInitComponents(); initComponents(); checkMode(); @@ -295,6 +295,15 @@ public class JDialogTMLCompositePort extends JDialog implements ActionListener { c2.gridwidth = GridBagConstraints.REMAINDER; //end row refReq = new JComboBox<>(refs); panel2.add(refReq,c2); + int index=-1; + for (int ind=0; ind<refs.size(); ind++) { + if (referenceReq.equals(refs.get(ind))){ + index=ind; + } + } + if (index!=-1){ + refReq.setSelectedIndex(index); + } c2.gridwidth = 1; c2.fill = GridBagConstraints.HORIZONTAL; @@ -556,6 +565,7 @@ public class JDialogTMLCompositePort extends JDialog implements ActionListener { JButton cancelButton = new JButton("Cancel", IconManager.imgic27); cancelButton.addActionListener(this); c.add(cancelButton, c0); + repaint(); } public void actionPerformed(ActionEvent evt) { @@ -600,9 +610,9 @@ public class JDialogTMLCompositePort extends JDialog implements ActionListener { dispose(); } - public String getDataFlowType() { - return dataFlowType; - } + public String getDataFlowType() { + return dataFlowType; + } public String getAssociatedEvent() { return associatedEvent; @@ -611,6 +621,9 @@ public class JDialogTMLCompositePort extends JDialog implements ActionListener { public void cancelDialog() { dispose(); } + public String getReferenceReq(){ + return (String) refReq.getSelectedItem(); + } public void checkMode() { int index = typePort.getSelectedIndex();