First functional example, ADC an Framebuffer Test

This commit is contained in:
Juan64Bits 2010-12-04 15:12:02 -05:00
parent 62d0edf217
commit 8d95564253
138 changed files with 14826 additions and 538 deletions

105
Software/sie_cg/adc_test.sie Executable file
View File

@ -0,0 +1,105 @@
<!--
File for SIE Code Generator.
**WARNING**If you are going to edit this file note that:
In order to segmentation faults prevention the load process
is started loading the libraries, then items and finally arrows.
Arrows depend of items, and items depend of libraries!!!!
-->
<Diagram>
<Libraries>
<Library Dir="block_editor/timer.die"/>
<Library Dir="block_editor/adc_single.die"/>
<Library Dir="block_editor/framebuffer_line.die"/>
<Library Dir="block_editor/framebuffer_drawline.die"/>
<Library Dir="block_editor/framebuffer_put_int.die"/>
<Library Dir="block_editor/printf_int.die"/>
<Library Dir="block_editor/left_shift.die"/>
<Library Dir="block_editor/right_shift.die"/>
<Library Dir="block_editor/pwm_single.die"/>
<Library Dir="block_editor/constant.die"/>
<Library Dir="block_editor/constant_bool.die"/>
<Library Dir="block_editor/while.die"/>
</Libraries>
<Options templateDir="templates/basic" workDir="tmp" executableFile="SIE_APP" configApp="xc3sprog $FPGA_BINARY" sieWorkDir="/tmp/CG" fpgaFile="templates/basic/basic.bit" templateFile="main.cpp" makeFile="Makefile" mipsToolChainDir="/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.32/usr/bin" mipsToolChain="mipsel-openwrt-linux" sieIP="192.168.254.101"/>
<DiagramItems>
<DiagramItem x="2480" y="2650" z="500" type="FB Put Int" ID="9" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="7"/>
<diagramValue value="16" ID="3"/>
<diagramValue value="32" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2670" y="2590" z="500" type="FB Draw HLine" ID="3" color="#a0a0a4">
<diagramValues>
<diagramValue value="64" ID="1"/>
<diagramValue value="16" ID="2"/>
<diagramValue value="255" ID="7"/>
<diagramValue value="24" ID="9"/>
<diagramValue value="4" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2650" y="2330" z="500" type="FB Print Line" ID="2" color="#a0a0a4">
<diagramValues>
<diagramValue value="1" ID="9"/>
<diagramValue value="0" ID="7"/>
<diagramValue value="160" ID="5"/>
<diagramValue value="1" ID="3"/>
<diagramValue value="Wellcome to SIE {Executing Code...}" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2190" y="2340" z="500" type="Constant Bool" ID="1" color="#a0a0a4">
<diagramValues>
<diagramValue value="1" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2370" y="2320" z="500" type="System While" ID="5" color="#a0a0a4">
<diagramValues/>
</DiagramItem>
<DiagramItem x="2210" y="2600" z="500" type="ADC Single" ID="0" color="#a0a0a4">
<diagramValues>
<diagramValue value="0" ID="0"/>
<diagramValue value="255" ID="4"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2440" y="2580" z="500" type="Right Shift" ID="8" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2510" y="2550" z="500" type="Printf Int" ID="7" color="#a0a0a4">
<diagramValues>
<diagramValue value="&quot;[%04X]&quot;" ID="0"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2650" y="2400" z="500" type="FB Print Line" ID="10" color="#a0a0a4">
<diagramValues>
<diagramValue value="3" ID="9"/>
<diagramValue value="16" ID="7"/>
<diagramValue value="0" ID="5"/>
<diagramValue value="0" ID="3"/>
<diagramValue value="CHA [0]" ID="1"/>
</diagramValues>
</DiagramItem>
</DiagramItems>
<Arrows>
<Arrow end-ID="1" end-Owner="9" start-x="110" start-y="-10" start-Owner="0" ID="0" start-ID="2" end-x="-100" end-y="0" color="#000000">
<arrowCorners>
<arrowCorner x="2349.5" y="2589.5"/>
<arrowCorner x="2349.5" y="2649.5"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="0" end-Owner="8" start-x="110" start-y="-10" start-Owner="0" ID="1" start-ID="2" end-x="-60" end-y="10" color="#000000"/>
<Arrow end-ID="3" end-Owner="7" start-x="110" start-y="-10" start-Owner="0" ID="2" start-ID="2" end-x="-130" end-y="-10" color="#000000">
<arrowCorners>
<arrowCorner x="2349" y="2589"/>
<arrowCorner x="2349" y="2539"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="3" end-Owner="3" start-x="70" start-y="10" start-Owner="8" ID="3" start-ID="1" end-x="-80" end-y="0" color="#000000"/>
<Arrow end-ID="6" end-Owner="5" start-x="100" start-y="0" start-Owner="1" ID="4" start-ID="3" end-x="-50" end-y="20" color="#000000"/>
</Arrows>
<TextItems>
<TextItem x="2130" Family="Times New Roman" y="2240" Bold="1" PointSize="26" Text="Basic Example:" Italic="1" Underline="0" Color="#000000"/>
<TextItem x="2150" Family="Chancery Uralic" y="2450" Bold="0" PointSize="24" Text="Hello world!!!" Italic="0" Underline="0" Color="#000000"/>
</TextItems>
</Diagram>

View File

@ -0,0 +1,432 @@
<!--
File for SIE Code Generator.
**WARNING**If you are going to edit this file note that:
In order to segmentation faults prevention the load process
is started loading the libraries, then items and finally arrows.
Arrows depend of items, and items depend of libraries!!!!
-->
<Diagram>
<Libraries>
<Library Dir="block_editor/timer.die"/>
<Library Dir="block_editor/adc_single.die"/>
<Library Dir="block_editor/adc_eight.die"/>
<Library Dir="block_editor/framebuffer_line.die"/>
<Library Dir="block_editor/framebuffer_drawline.die"/>
<Library Dir="block_editor/framebuffer_put_int.die"/>
<Library Dir="block_editor/printf_int.die"/>
<Library Dir="block_editor/left_shift.die"/>
<Library Dir="block_editor/right_shift.die"/>
<Library Dir="block_editor/pwm_single.die"/>
<Library Dir="block_editor/constant.die"/>
<Library Dir="block_editor/constant_bool.die"/>
<Library Dir="block_editor/while.die"/>
</Libraries>
<Options templateDir="templates/basic" workDir="tmp" executableFile="SIE_APP" configApp="xc3sprog $FPGA_BINARY" sieWorkDir="/tmp/CG" fpgaFile="templates/basic/basic.bit" templateFile="main.cpp" makeFile="Makefile" mipsToolChainDir="/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.32/usr/bin" mipsToolChain="mipsel-openwrt-linux" sieIP="192.168.254.101"/>
<DiagramItems>
<DiagramItem x="2960" y="2380" z="500" type="FB Print Line" ID="38" color="#a0a0a4">
<diagramValues>
<diagramValue value="1" ID="9"/>
<diagramValue value="210" ID="7"/>
<diagramValue value="160" ID="5"/>
<diagramValue value="1" ID="3"/>
<diagramValue value="By Juan64Bits" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2960" y="2310" z="500" type="FB Print Line" ID="37" color="#a0a0a4">
<diagramValues>
<diagramValue value="1" ID="9"/>
<diagramValue value="200" ID="7"/>
<diagramValue value="160" ID="5"/>
<diagramValue value="1" ID="3"/>
<diagramValue value="Segundo Semestre de 2010" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2610" y="2380" z="500" type="FB Print Line" ID="36" color="#a0a0a4">
<diagramValues>
<diagramValue value="1" ID="9"/>
<diagramValue value="190" ID="7"/>
<diagramValue value="160" ID="5"/>
<diagramValue value="1" ID="3"/>
<diagramValue value="Universidad Nacional de Colombia" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2960" y="3110" z="500" type="FB Print Line" ID="35" color="#a0a0a4">
<diagramValues>
<diagramValue value="4" ID="9"/>
<diagramValue value="156" ID="7"/>
<diagramValue value="0" ID="5"/>
<diagramValue value="0" ID="3"/>
<diagramValue value="CHA [7]" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2960" y="2480" z="500" type="FB Print Line" ID="10" color="#a0a0a4">
<diagramValues>
<diagramValue value="4" ID="9"/>
<diagramValue value="16" ID="7"/>
<diagramValue value="0" ID="5"/>
<diagramValue value="0" ID="3"/>
<diagramValue value="CHA [0]" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2510" y="2500" z="500" type="Right Shift" ID="8" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2370" y="2320" z="500" type="System While" ID="5" color="#a0a0a4">
<diagramValues/>
</DiagramItem>
<DiagramItem x="2190" y="2340" z="500" type="Constant Bool" ID="1" color="#a0a0a4">
<diagramValues>
<diagramValue value="1" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2610" y="2310" z="500" type="FB Print Line" ID="2" color="#a0a0a4">
<diagramValues>
<diagramValue value="1" ID="9"/>
<diagramValue value="0" ID="7"/>
<diagramValue value="160" ID="5"/>
<diagramValue value="1" ID="3"/>
<diagramValue value="Wellcome to SIE {Executing Code...}" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2710" y="2510" z="500" type="FB Draw HLine" ID="3" color="#a0a0a4">
<diagramValues>
<diagramValue value="64" ID="1"/>
<diagramValue value="16" ID="2"/>
<diagramValue value="255" ID="7"/>
<diagramValue value="16" ID="9"/>
<diagramValue value="3" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2520" y="2480" z="500" type="FB Put Int" ID="9" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="7"/>
<diagramValue value="16" ID="3"/>
<diagramValue value="24" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2130" y="2760" z="500" type="ADC Eight" ID="7" color="#a0a0a4">
<diagramValues>
<diagramValue value="255" ID="10"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2710" y="2600" z="500" type="FB Draw HLine" ID="0" color="#a0a0a4">
<diagramValues>
<diagramValue value="64" ID="1"/>
<diagramValue value="36" ID="2"/>
<diagramValue value="255" ID="7"/>
<diagramValue value="16" ID="9"/>
<diagramValue value="3" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2710" y="2690" z="500" type="FB Draw HLine" ID="4" color="#a0a0a4">
<diagramValues>
<diagramValue value="64" ID="1"/>
<diagramValue value="56" ID="2"/>
<diagramValue value="255" ID="7"/>
<diagramValue value="16" ID="9"/>
<diagramValue value="3" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2710" y="2780" z="500" type="FB Draw HLine" ID="6" color="#a0a0a4">
<diagramValues>
<diagramValue value="64" ID="1"/>
<diagramValue value="76" ID="2"/>
<diagramValue value="255" ID="7"/>
<diagramValue value="16" ID="9"/>
<diagramValue value="3" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2710" y="2870" z="500" type="FB Draw HLine" ID="11" color="#a0a0a4">
<diagramValues>
<diagramValue value="64" ID="1"/>
<diagramValue value="96" ID="2"/>
<diagramValue value="255" ID="7"/>
<diagramValue value="16" ID="9"/>
<diagramValue value="3" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2710" y="2960" z="500" type="FB Draw HLine" ID="12" color="#a0a0a4">
<diagramValues>
<diagramValue value="64" ID="1"/>
<diagramValue value="116" ID="2"/>
<diagramValue value="255" ID="7"/>
<diagramValue value="16" ID="9"/>
<diagramValue value="3" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2710" y="3050" z="500" type="FB Draw HLine" ID="13" color="#a0a0a4">
<diagramValues>
<diagramValue value="64" ID="1"/>
<diagramValue value="136" ID="2"/>
<diagramValue value="255" ID="7"/>
<diagramValue value="16" ID="9"/>
<diagramValue value="3" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2710" y="3140" z="500" type="FB Draw HLine" ID="14" color="#a0a0a4">
<diagramValues>
<diagramValue value="64" ID="1"/>
<diagramValue value="156" ID="2"/>
<diagramValue value="255" ID="7"/>
<diagramValue value="16" ID="9"/>
<diagramValue value="3" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2520" y="2570" z="500" type="FB Put Int" ID="15" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="7"/>
<diagramValue value="16" ID="3"/>
<diagramValue value="44" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2520" y="2660" z="500" type="FB Put Int" ID="16" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="7"/>
<diagramValue value="16" ID="3"/>
<diagramValue value="64" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2520" y="2750" z="500" type="FB Put Int" ID="17" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="7"/>
<diagramValue value="16" ID="3"/>
<diagramValue value="84" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2520" y="2840" z="500" type="FB Put Int" ID="18" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="7"/>
<diagramValue value="16" ID="3"/>
<diagramValue value="104" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2520" y="2930" z="500" type="FB Put Int" ID="19" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="7"/>
<diagramValue value="16" ID="3"/>
<diagramValue value="124" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2520" y="3020" z="500" type="FB Put Int" ID="20" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="7"/>
<diagramValue value="16" ID="3"/>
<diagramValue value="144" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2520" y="3110" z="500" type="FB Put Int" ID="21" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="7"/>
<diagramValue value="16" ID="3"/>
<diagramValue value="164" ID="5"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2510" y="2590" z="500" type="Right Shift" ID="22" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2510" y="2680" z="500" type="Right Shift" ID="23" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2510" y="2770" z="500" type="Right Shift" ID="24" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2510" y="2860" z="500" type="Right Shift" ID="25" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2510" y="2950" z="500" type="Right Shift" ID="26" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2510" y="3040" z="500" type="Right Shift" ID="27" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2510" y="3130" z="500" type="Right Shift" ID="28" color="#a0a0a4">
<diagramValues>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2960" y="2570" z="500" type="FB Print Line" ID="29" color="#a0a0a4">
<diagramValues>
<diagramValue value="4" ID="9"/>
<diagramValue value="36" ID="7"/>
<diagramValue value="0" ID="5"/>
<diagramValue value="0" ID="3"/>
<diagramValue value="CHA [1]" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2960" y="2660" z="500" type="FB Print Line" ID="30" color="#a0a0a4">
<diagramValues>
<diagramValue value="4" ID="9"/>
<diagramValue value="56" ID="7"/>
<diagramValue value="0" ID="5"/>
<diagramValue value="0" ID="3"/>
<diagramValue value="CHA [2]" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2960" y="2750" z="500" type="FB Print Line" ID="31" color="#a0a0a4">
<diagramValues>
<diagramValue value="4" ID="9"/>
<diagramValue value="76" ID="7"/>
<diagramValue value="0" ID="5"/>
<diagramValue value="0" ID="3"/>
<diagramValue value="CHA [3]" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2960" y="2840" z="500" type="FB Print Line" ID="32" color="#a0a0a4">
<diagramValues>
<diagramValue value="4" ID="9"/>
<diagramValue value="96" ID="7"/>
<diagramValue value="0" ID="5"/>
<diagramValue value="0" ID="3"/>
<diagramValue value="CHA [4]" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2960" y="2930" z="500" type="FB Print Line" ID="33" color="#a0a0a4">
<diagramValues>
<diagramValue value="4" ID="9"/>
<diagramValue value="116" ID="7"/>
<diagramValue value="0" ID="5"/>
<diagramValue value="0" ID="3"/>
<diagramValue value="CHA [5]" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2960" y="3020" z="500" type="FB Print Line" ID="34" color="#a0a0a4">
<diagramValues>
<diagramValue value="4" ID="9"/>
<diagramValue value="136" ID="7"/>
<diagramValue value="0" ID="5"/>
<diagramValue value="0" ID="3"/>
<diagramValue value="CHA [6]" ID="1"/>
</diagramValues>
</DiagramItem>
</DiagramItems>
<Arrows>
<Arrow end-ID="0" end-Owner="28" start-x="110" start-y="90" start-Owner="7" ID="0" start-ID="8" end-x="-60" end-y="10" color="#000000">
<arrowCorners>
<arrowCorner x="2270" y="2850"/>
<arrowCorner x="2270" y="3140"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="1" end-Owner="21" start-x="110" start-y="90" start-Owner="7" ID="1" start-ID="8" end-x="-100" end-y="0" color="#000000">
<arrowCorners>
<arrowCorner x="2269.5" y="2849.5"/>
<arrowCorner x="2269.5" y="3109.5"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="0" end-Owner="27" start-x="110" start-y="70" start-Owner="7" ID="2" start-ID="7" end-x="-60" end-y="10" color="#000000">
<arrowCorners>
<arrowCorner x="2300" y="2830"/>
<arrowCorner x="2300" y="3050"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="1" end-Owner="20" start-x="110" start-y="70" start-Owner="7" ID="3" start-ID="7" end-x="-100" end-y="0" color="#000000">
<arrowCorners>
<arrowCorner x="2299.5" y="2829.5"/>
<arrowCorner x="2299.5" y="3019.5"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="0" end-Owner="26" start-x="110" start-y="50" start-Owner="7" ID="4" start-ID="6" end-x="-60" end-y="10" color="#000000">
<arrowCorners>
<arrowCorner x="2329.5" y="2809.5"/>
<arrowCorner x="2329.5" y="2959.5"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="1" end-Owner="19" start-x="110" start-y="50" start-Owner="7" ID="5" start-ID="6" end-x="-100" end-y="0" color="#000000">
<arrowCorners>
<arrowCorner x="2330" y="2810"/>
<arrowCorner x="2330" y="2930"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="6" end-Owner="5" start-x="100" start-y="0" start-Owner="1" ID="6" start-ID="3" end-x="-50" end-y="20" color="#000000"/>
<Arrow end-ID="3" end-Owner="3" start-x="70" start-y="10" start-Owner="8" ID="7" start-ID="1" end-x="-80" end-y="0" color="#000000"/>
<Arrow end-ID="1" end-Owner="9" start-x="110" start-y="-50" start-Owner="7" ID="8" start-ID="1" end-x="-100" end-y="0" color="#000000">
<arrowCorners>
<arrowCorner x="2300" y="2710"/>
<arrowCorner x="2299.5" y="2479.5"/>
<arrowCorner x="2360" y="2480"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="0" end-Owner="8" start-x="110" start-y="-50" start-Owner="7" ID="9" start-ID="1" end-x="-60" end-y="10" color="#000000">
<arrowCorners>
<arrowCorner x="2299.5" y="2709.5"/>
<arrowCorner x="2299.5" y="2709.5"/>
<arrowCorner x="2299.5" y="2509.5"/>
<arrowCorner x="2380" y="2510"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="3" end-Owner="0" start-x="70" start-y="10" start-Owner="22" ID="10" start-ID="1" end-x="-80" end-y="0" color="#000000"/>
<Arrow end-ID="3" end-Owner="4" start-x="70" start-y="10" start-Owner="23" ID="11" start-ID="1" end-x="-80" end-y="0" color="#000000"/>
<Arrow end-ID="3" end-Owner="6" start-x="70" start-y="10" start-Owner="24" ID="12" start-ID="1" end-x="-80" end-y="0" color="#000000"/>
<Arrow end-ID="3" end-Owner="11" start-x="70" start-y="10" start-Owner="25" ID="13" start-ID="1" end-x="-80" end-y="0" color="#000000"/>
<Arrow end-ID="3" end-Owner="12" start-x="70" start-y="10" start-Owner="26" ID="14" start-ID="1" end-x="-80" end-y="0" color="#000000"/>
<Arrow end-ID="3" end-Owner="13" start-x="70" start-y="10" start-Owner="27" ID="15" start-ID="1" end-x="-80" end-y="0" color="#000000"/>
<Arrow end-ID="3" end-Owner="14" start-x="70" start-y="10" start-Owner="28" ID="16" start-ID="1" end-x="-80" end-y="0" color="#000000"/>
<Arrow end-ID="1" end-Owner="15" start-x="110" start-y="-30" start-Owner="7" ID="17" start-ID="2" end-x="-100" end-y="0" color="#000000">
<arrowCorners>
<arrowCorner x="2329.5" y="2729.5"/>
<arrowCorner x="2329.5" y="2569.5"/>
<arrowCorner x="2380" y="2570"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="0" end-Owner="22" start-x="110" start-y="-30" start-Owner="7" ID="18" start-ID="2" end-x="-60" end-y="10" color="#000000">
<arrowCorners>
<arrowCorner x="2329.5" y="2729.5"/>
<arrowCorner x="2329.5" y="2599.5"/>
<arrowCorner x="2399.5" y="2599.5"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="1" end-Owner="16" start-x="110" start-y="-10" start-Owner="7" ID="19" start-ID="3" end-x="-100" end-y="0" color="#000000">
<arrowCorners>
<arrowCorner x="2360" y="2750"/>
<arrowCorner x="2360" y="2660"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="0" end-Owner="23" start-x="110" start-y="-10" start-Owner="7" ID="20" start-ID="3" end-x="-60" end-y="10" color="#000000">
<arrowCorners>
<arrowCorner x="2359.5" y="2749.5"/>
<arrowCorner x="2359.5" y="2689.5"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="1" end-Owner="17" start-x="110" start-y="10" start-Owner="7" ID="21" start-ID="4" end-x="-100" end-y="0" color="#000000">
<arrowCorners>
<arrowCorner x="2379.5" y="2769.5"/>
<arrowCorner x="2379.5" y="2749.5"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="0" end-Owner="24" start-x="110" start-y="10" start-Owner="7" ID="22" start-ID="4" end-x="-60" end-y="10" color="#000000">
<arrowCorners>
<arrowCorner x="2379.5" y="2769.5"/>
<arrowCorner x="2379.5" y="2779.5"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="1" end-Owner="18" start-x="110" start-y="30" start-Owner="7" ID="23" start-ID="5" end-x="-100" end-y="0" color="#000000">
<arrowCorners>
<arrowCorner x="2359.5" y="2789.5"/>
<arrowCorner x="2359.5" y="2839.5"/>
</arrowCorners>
</Arrow>
<Arrow end-ID="0" end-Owner="25" start-x="110" start-y="30" start-Owner="7" ID="24" start-ID="5" end-x="-60" end-y="10" color="#000000">
<arrowCorners>
<arrowCorner x="2359.5" y="2789.5"/>
<arrowCorner x="2359.5" y="2869.5"/>
</arrowCorners>
</Arrow>
</Arrows>
<TextItems>
<TextItem x="2070" Family="Lucida Grande" y="2260" Bold="0" PointSize="12" Text="ADC Test... Using eight channels..." Italic="0" Underline="0" Color="#000000"/>
<TextItem x="2090" Family="Times New Roman" y="2210" Bold="1" PointSize="26" Text="Basic Example:" Italic="1" Underline="0" Color="#000000"/>
</TextItems>
</Diagram>

34
Software/sie_cg/arrow.cpp Normal file → Executable file
View File

@ -42,6 +42,7 @@
#include <QtGui>
#include "arrow.h"
#include "diagramscene.h"
#include <math.h>
const qreal Pi = 3.14;
@ -52,16 +53,16 @@ Arrow::Arrow(DiagramTextItem *startItem, DiagramTextItem *endItem,
{
myStartItem = startItem;
myEndItem = endItem;
arrowSize = 10;
arrowSize = 5;
moving=0;
//setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
myColor = Qt::black;
setPen(QPen(myColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
myOwnerScene = scene;
lineItem *newLine= new lineItem(QPointF(0,0),QPointF(0,0),this);
myOwnerScene->addItem(newLine);
addLine(newLine);
//setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
}
void Arrow::removeLine(lineItem *line)
@ -260,8 +261,18 @@ void Arrow::setVisibleCorners(bool visible)
}
}
void Arrow::setSelectedLines(bool sel)
{
foreach (lineItem *line, myCLines) {
line->setSelected(sel);
}
foreach (lineItem *line, myLines) {
line->setSelected(sel);
}
}
QDomElement Arrow::toXml(QDomDocument &document,
QList<DiagramItem*> sceneItems) const
QHash<int , DiagramItem *> DiagramsID) const
{
QDomElement diagramArrow = document.createElement("Arrow");
@ -269,14 +280,14 @@ QDomElement Arrow::toXml(QDomDocument &document,
diagramArrow.setAttribute("start-x",startOffset().x());
diagramArrow.setAttribute("start-y",startOffset().y());
diagramArrow.setAttribute("start-Owner",
sceneItems.indexOf(startOwner()));
DiagramsID.key(startOwner()));
diagramArrow.setAttribute("start-ID",this->startItem()->textID());
//Set attibutes; endItem
diagramArrow.setAttribute("end-x",endOffset().x());
diagramArrow.setAttribute("end-y",endOffset().y());
diagramArrow.setAttribute("end-Owner",
sceneItems.indexOf(endOwner()));
DiagramsID.key(endOwner()));
diagramArrow.setAttribute("end-ID",this->endItem()->textID());
diagramArrow.setAttribute("color",myColor.name());
@ -322,6 +333,10 @@ void Arrow::mousePressEvent(QGraphicsSceneMouseEvent *event)
previousPos = event->scenePos();
moving=1;
}
setSelectedLines(false);
positionChanged=0;
qobject_cast<DiagramScene *>(myOwnerScene)->saveUndo();
QGraphicsPathItem::mousePressEvent(event);
}
@ -333,6 +348,12 @@ void Arrow::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
previousPos = event->scenePos();
}
moving=0;
if(!positionChanged)
qobject_cast<DiagramScene *>(myOwnerScene)->removeLastUndo();
else
qobject_cast<DiagramScene *>(myOwnerScene)->clearRedo();
QGraphicsPathItem::mouseReleaseEvent(event);
}
@ -342,6 +363,7 @@ void Arrow::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
snapToGrid(event);
previousPos = event->scenePos();
positionChanged=1;
}
QGraphicsPathItem::mouseMoveEvent(event);
}

25
Software/sie_cg/arrow.h Normal file → Executable file
View File

@ -42,12 +42,17 @@
#ifndef ARROW_H
#define ARROW_H
#include <QGraphicsLineItem>
#include <QtXml>
#include <QGraphicsLineItem>
#include <QtXml>
#include "diagramtextitem.h"
#include "lineitem.h"
#include "diagramitem.h"
class lineItem;
QT_BEGIN_NAMESPACE
class QGraphicsPolygonItem;
class QGraphicsLineItem;
@ -58,8 +63,6 @@ class QGraphicsSceneMouseEvent;
class QPainterPath;
QT_END_NAMESPACE
class lineItem;
class Arrow : public QGraphicsPathItem
{
public:
@ -82,12 +85,15 @@ public:
void removeLine(lineItem *line);
void removeLines();
bool addLine(lineItem *line);
QList<QPointF> getCorners()
{ return myCorners;}
void createCorner(QPointF cornerPos, lineItem *inLine);
void createCorner(QPointF cornerPos, int index);
void moveCorner(QPointF cornerPos, lineItem *inLine);
void setVisibleCorners(bool visible);
void setSelectedLines(bool sel);
void snapToGrid(QGraphicsSceneMouseEvent *event);
@ -104,7 +110,13 @@ public:
DiagramItem *endOwner() const
{ return myEndItem->ownerItem();}
QDomElement toXml(QDomDocument &,QList<DiagramItem*>) const;
QDomElement toXml(QDomDocument &,QHash<int , DiagramItem *>) const;
QGraphicsScene *myOwnerScene;
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
public slots:
void updatePosition();
@ -112,9 +124,6 @@ public slots:
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
private:
DiagramTextItem *myStartItem;
@ -124,11 +133,11 @@ private:
QPolygonF arrowHeadStart;
QList<lineItem *> myLines;
QList<lineItem *> myCLines;
QList<QPointF> myCorners;
QGraphicsScene *myOwnerScene;
QList<QPointF> myCorners;
qreal arrowSize;
bool moving;
QPointF previousPos;
bool positionChanged;
};
#endif

View File

@ -0,0 +1,45 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="ADC Eight">
<Polygon>
<Point x="-80" y="20"/>
<Point x="-60" y="-60"/>
<Point x="30" y="-60"/>
<Point x="30" y="100"/>
<Point x="110" y="100"/>
<Point x="110" y="-60"/>
<Point x="30" y="-60"/>
<Point x="110" y="-60"/>
<Point x="110" y="100"/>
<Point x="-60" y="100"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="0" posOffset-y="-70" editableItem="1" ID="10" text="255" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="-50" editableItem="0" ID="9" text="Clock Divisor" posOffset-x="-20"/>
<TextItem myStyleIO="10" posOffset-y="-90" editableItem="0" ID="8" text="CH7 UShort" posOffset-x="110"/>
<TextItem myStyleIO="10" posOffset-y="-70" editableItem="0" ID="7" text="CH6 UShort" posOffset-x="110"/>
<TextItem myStyleIO="10" posOffset-y="-50" editableItem="0" ID="6" text="CH5 UShort" posOffset-x="110"/>
<TextItem myStyleIO="10" posOffset-y="-30" editableItem="0" ID="5" text="CH4 UShort" posOffset-x="110"/>
<TextItem myStyleIO="10" posOffset-y="-10" editableItem="0" ID="4" text="CH3 UShort" posOffset-x="110"/>
<TextItem myStyleIO="10" posOffset-y="10" editableItem="0" ID="3" text="CH2 UShort" posOffset-x="110"/>
<TextItem myStyleIO="10" posOffset-y="30" editableItem="0" ID="2" text="CH1 UShort" posOffset-x="110"/>
<TextItem myStyleIO="10" posOffset-y="50" editableItem="0" ID="1" text="CH0 UShort" posOffset-x="110"/>
<TextItem myStyleIO="0" posOffset-y="10" editableItem="0" ID="0" text="ADC 8 Channels" posOffset-x="-20"/>
</TextItems><![CDATA[]]><![CDATA[
ADC_SPI_CLKDIV=value_10;
ADC_BUFFER_LEN=8;
ADC_MUX_CHANNELS=7;
]]><![CDATA[
JZ_REG * ADC_DATA = ADCTakeSamples(ADCBuffer,0);
unsigned int sampleData = ADC_DATA[0];
out_1 = (sampleData>>16)&0xFFFF;
out_2 = sampleData&0xFFFF;
sampleData = ADC_DATA[1];
out_3 = (sampleData>>16)&0xFFFF;
out_4 = sampleData&0xFFFF;
sampleData = ADC_DATA[2];
out_5 = (sampleData>>16)&0xFFFF;
out_6 = sampleData&0xFFFF;
sampleData = ADC_DATA[3];
out_7 = (sampleData>>16)&0xFFFF;
out_8 = sampleData&0xFFFF;
]]><![CDATA[]]></CustomItem>

36
Software/sie_cg/block_editor/adc_single.die Normal file → Executable file
View File

@ -1,23 +1,31 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="ADC Single">
<Polygon>
<Point x="-80" y="0"/>
<Point x="-80" y="-10"/>
<Point x="-60" y="-40"/>
<Point x="110" y="-40"/>
<Point x="110" y="20"/>
<Point x="60" y="20"/>
<Point x="60" y="-40"/>
<Point x="60" y="40"/>
<Point x="110" y="40"/>
<Point x="60" y="20"/>
<Point x="110" y="20"/>
<Point x="110" y="-40"/>
<Point x="60" y="-40"/>
<Point x="110" y="-40"/>
<Point x="110" y="40"/>
<Point x="-60" y="40"/>
<Point x="60" y="20"/>
<Point x="-60" y="20"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="7" posOffset-y="-20" editableItem="0" ID="7" text=" Long" posOffset-x="110"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="1" ID="9" text="255" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="0" ID="6" text="SP:" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="5" text="CH:" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="4" text="0" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="3" text="ADC Single Channel" posOffset-x="0"/>
</TextItems>
</CustomItem>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="3" text="Clock Div." posOffset-x="-30"/>
<TextItem myStyleIO="0" posOffset-y="30" editableItem="0" ID="1" text="ADC Single Channel" posOffset-x="0"/>
<TextItem myStyleIO="0" posOffset-y="10" editableItem="1" ID="0" text="0" posOffset-x="30"/>
<TextItem myStyleIO="10" posOffset-y="10" editableItem="0" ID="2" text="UShort" posOffset-x="110"/>
<TextItem myStyleIO="0" posOffset-y="10" editableItem="0" ID="5" text="Channel:" posOffset-x="-30"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="4" text="255" posOffset-x="30"/>
</TextItems><![CDATA[]]><![CDATA[
ADC_SPI_CLKDIV=value_4;
ADC_BUFFER_LEN=2;
ADC_MUX_CHANNELS=0;
]]><![CDATA[
JZ_REG * ADC_DATA = ADCTakeSamples(ADCBuffer,value_0);
out_2 = ADC_DATA[0]&0x03FF;
]]><![CDATA[]]></CustomItem>

1
Software/sie_cg/block_editor/arrow.cpp Normal file → Executable file
View File

@ -271,6 +271,7 @@ void Arrow::setVisibleCorners(bool visible)
{
foreach (lineItem *line, myCLines) {
line->setVisible(visible);
line->setZValue(2000.0);
}
if(myOwnerScene->items().indexOf(SECLine)!=-1)
{

0
Software/sie_cg/block_editor/arrow.h Normal file → Executable file
View File

25
Software/sie_cg/block_editor/constant.die Normal file → Executable file
View File

@ -1,14 +1,21 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="Constant">
<CustomItem BlockName="Constant Char">
<Polygon>
<Point x="-50" y="-10"/>
<Point x="-50" y="30"/>
<Point x="30" y="30"/>
<Point x="30" y="-10"/>
<Point x="-50" y="10"/>
<Point x="20" y="10"/>
<Point x="20" y="-10"/>
<Point x="-50" y="-10"/>
<Point x="100" y="-10"/>
<Point x="100" y="10"/>
<Point x="20" y="10"/>
<Point x="100" y="10"/>
<Point x="100" y="-10"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="1" text="1" posOffset-x="10"/>
<TextItem myStyleIO="3" posOffset-y="-20" editableItem="0" ID="15" text="OUT Integer" posOffset-x="30"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="0" text="Value" posOffset-x="-30"/>
</TextItems>
</CustomItem>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="0" text="Const" posOffset-x="-30"/>
<TextItem myStyleIO="8" posOffset-y="-0" editableItem="0" ID="2" text="OUT UChar" posOffset-x="100"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="1" text="1" posOffset-x="0"/>
</TextItems><![CDATA[]]><![CDATA[]]><![CDATA[
out_2=value_1;
]]><![CDATA[]]></CustomItem>

View File

@ -0,0 +1,21 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="Constant Bool">
<Polygon>
<Point x="-50" y="-10"/>
<Point x="-50" y="10"/>
<Point x="20" y="10"/>
<Point x="20" y="-10"/>
<Point x="-50" y="-10"/>
<Point x="100" y="-10"/>
<Point x="100" y="10"/>
<Point x="20" y="10"/>
<Point x="100" y="10"/>
<Point x="100" y="-10"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="0" text="Const" posOffset-x="-30"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="1" text="1" posOffset-x="0"/>
<TextItem myStyleIO="1" posOffset-y="-0" editableItem="0" ID="3" text="OUT Bool" posOffset-x="100"/>
</TextItems><![CDATA[]]><![CDATA[]]><![CDATA[
out_3=value_1;
]]><![CDATA[]]></CustomItem>

170
Software/sie_cg/block_editor/diagramscene.cpp Normal file → Executable file
View File

@ -62,23 +62,12 @@ DiagramScene::DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow,
myCorners=0;
TitleText = new DiagramTextItem(0,0,1,0xFFF,255,"BLOCK NAME HERE not visible",
QPointF(500,370));
QPointF(500,420));
TitleText->setZValue(1000);
addItem(TitleText);
}
void DiagramScene::editorLostFocus(DiagramTextItem *item)
{
QTextCursor cursor = item->textCursor();
cursor.clearSelection();
item->setTextCursor(cursor);
if (item->toPlainText().isEmpty()) {
removeItem(item);
item->deleteLater();
}
}
void DiagramScene::drawBackground(QPainter *p, const QRectF &r)
{
p -> save();
@ -148,7 +137,7 @@ QString DiagramScene::createPrototype()
functionPrototype += "char ";
break;
case 3:
functionPrototype += "integer ";
functionPrototype += "int ";
break;
case 4:
functionPrototype += "double ";
@ -157,10 +146,10 @@ QString DiagramScene::createPrototype()
functionPrototype += "float ";
break;
case 6:
functionPrototype += "short ";
functionPrototype += "short int ";
break;
case 7:
functionPrototype += "long ";
functionPrototype += "long int ";
break;
case 8:
functionPrototype += "unsigned char ";
@ -169,10 +158,10 @@ QString DiagramScene::createPrototype()
functionPrototype += "unsigned integer ";
break;
case 10:
functionPrototype += "unsigned short ";
functionPrototype += "unsigned short int ";
break;
case 11:
functionPrototype += "unsigned long ";
functionPrototype += "unsigned long int ";
break;
default:;
}
@ -189,34 +178,6 @@ QString DiagramScene::createPrototype()
void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
doSnapToGrid(mouseEvent);
foreach (QGraphicsItem *item, this->items(mouseEvent->scenePos())) {
if (item->type() == DiagramTextItem::Type) {
if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()<256)
{
myOwnerWindow->statusBar->showMessage(
qgraphicsitem_cast<DiagramTextItem *>(item)->toPlainText() +
tr("\t : Input/Output text label -> {ID = ") +
QString::number(qgraphicsitem_cast<DiagramTextItem *>
(item)->textID()) + tr("}"));
}
else if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()==256)
{
myOwnerWindow->statusBar->showMessage(
qgraphicsitem_cast<DiagramTextItem *>(item)->toPlainText() +
tr("\t : Text label -> {ID = ") +
QString::number(qgraphicsitem_cast<DiagramTextItem *>
(item)->textID()) + tr("}"));
}
else if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()==257)
{
myOwnerWindow->statusBar->showMessage(
qgraphicsitem_cast<DiagramTextItem *>(item)->toPlainText() +
tr("\t : Editable text label -> {ID = ") +
QString::number(qgraphicsitem_cast<DiagramTextItem *>
(item)->textID()) + tr("}"));
}
}
}
myOwnerWindow->updateProt();
QString Text;
@ -243,8 +204,6 @@ void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
if(addResult!=-1)
{
textItem->setZValue(1000.0);
connect(textItem, SIGNAL(lostFocus(DiagramTextItem*)),
this, SLOT(editorLostFocus(DiagramTextItem*)));
addItem(textItem);
textItem->setTextID(addResult);
}
@ -252,7 +211,7 @@ void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
delete(textItem);
QMessageBox::warning(0,"Full","The block can only have "
"255 text items");
"255 labels/IOs.");
}
emit textInserted(textItem);
break;
@ -301,8 +260,40 @@ void DiagramScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
QLineF newLine(line->line().p1(), mouseEvent->scenePos());
line->setLine(newLine);
}
QGraphicsScene::mouseMoveEvent(mouseEvent);
QPointF mousePos = mouseEvent->scenePos();
mousePos.setX(mousePos.x()-500);
mousePos.setY(-(mousePos.y()-500));
QGraphicsScene::mouseMoveEvent(mouseEvent);
QString barMesg= QString("X[%1] Y[%2]").arg(QString::number(mousePos.x()))
.arg(QString::number(mousePos.y()));
foreach (QGraphicsItem *item, this->items(mouseEvent->scenePos())) {
if (item->type() == DiagramTextItem::Type) {
if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()<256)
{
barMesg +=
tr(" ** Over In/Out text label with {ID = ") +
QString::number(qgraphicsitem_cast<DiagramTextItem *>
(item)->textID()) + tr("}");
}
else if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()==256)
{
barMesg +=
tr(" ** Over text label with {ID = ") +
QString::number(qgraphicsitem_cast<DiagramTextItem *>
(item)->textID()) + tr("}");
}
else if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()==257)
{
barMesg +=
tr(" ** Over editable text label with {ID = ") +
QString::number(qgraphicsitem_cast<DiagramTextItem *>
(item)->textID()) + tr("}");
}
}
}
myOwnerWindow->statusBar->showMessage(barMesg);
}
@ -351,9 +342,11 @@ QDomDocument DiagramScene::toXmlFormat()
QDomComment initialComments=document.createComment(
"File for SIE Code Generator. Custmos Blocks");
document.appendChild(initialComments);
QDomElement diagram = document.createElement("CustomItem");
diagram.setAttribute("BlockName",TitleText->toPlainText());
document.appendChild(diagram);
//Lists of items
QList<DiagramTextItem *> Items;
QList<Arrow *> Arrows;
@ -368,7 +361,8 @@ QDomDocument DiagramScene::toXmlFormat()
if(Arrows.count()>1) {printf("Something is wrong.\n"); fflush(stdout);}
//Create the XML structure
diagram.appendChild(myPolygonPath->toXml(document));
if(myPolygonPath!=0)
diagram.appendChild(myPolygonPath->toXml(document));
QDomElement element;
if(Items.count()>0)
@ -386,6 +380,26 @@ QDomDocument DiagramScene::toXmlFormat()
diagram.appendChild(textItems);
}
//Add the code as CDATA sections
//Order: Header Code, Init Code, Block Code and Extra Code.
QDomCDATASection headerCode=document.createCDATASection(
myOwnerWindow->headerTextEdit->toPlainText());
diagram.appendChild(headerCode);
QDomCDATASection initCode=document.createCDATASection(
myOwnerWindow->initTextEdit->toPlainText());
diagram.appendChild(initCode);
QDomCDATASection blockCode=document.createCDATASection(
myOwnerWindow->blockTextEdit->toPlainText());
diagram.appendChild(blockCode);
QDomCDATASection extraCode=document.createCDATASection(
myOwnerWindow->extraTextEdit->toPlainText());
diagram.appendChild(extraCode);
return(document);
}
@ -401,11 +415,39 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
TitleText->setPlainText("Please set Block Name");
else
TitleText->setPlainText(customItem.attribute("BlockName"));
TitleText->updatePosition();
int codeIdx = 0;
for (QDomNode node = customItem.firstChild() ;
!node.isNull() ;
node = node.nextSibling())
{
{
if(node.isCDATASection())
{
QDomCDATASection Code = node.toCDATASection();
switch(codeIdx)
{
case 0:
myOwnerWindow->headerTextEdit->setPlainText(Code.data());
break;
case 1:
myOwnerWindow->initTextEdit->setPlainText(Code.data());
break;
case 2:
myOwnerWindow->blockTextEdit->setPlainText(Code.data());
break;
case 3:
myOwnerWindow->extraTextEdit->setPlainText(Code.data());
break;
default:
QMessageBox::warning(0,"Parsing XML", tr("Extra CDATA found in")
+tr(" file, this section will be ignored."));
}
codeIdx++;
}
else
{
QDomElement element = node.toElement();
if(element.tagName()=="Polygon")
{
@ -446,6 +488,7 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
int myStyleIO = textItemE.attribute("myStyleIO").toInt();
int myID = textItemE.attribute("ID").toInt();
bool editableItem = textItemE.attribute("editableItem").toInt();
QPointF posOffset=
QPointF((QPointF(textItemE.attribute("posOffset-x")
@ -465,12 +508,23 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
DiagramTextItem * newTextItem =
new DiagramTextItem(0,0,1,myStyleIO,myID,itemString,posOffset);
newTextItem->setZValue(1000.0);
connect(newTextItem, SIGNAL(lostFocus(DiagramTextItem*)),
this, SLOT(editorLostFocus(DiagramTextItem*)));
addItem(newTextItem);
textItemsByID.insert(myID,newTextItem);
if(textItemsByID.find(myID)!=textItemsByID.end())
{
int result=addTextItem(newTextItem);
QMessageBox::warning(0,"ID Problems",
tr("Label with ID[")+QString::number(myID)+
tr("] already exists, this will be reasigned to [")+
QString::number(result)+
tr("] for prevent problems."));
newTextItem->setTextID(result);
}
else
textItemsByID.insert(myID,newTextItem);
}
}
}
}
myOwnerWindow->updateProt();
return 1;
@ -501,13 +555,15 @@ void DiagramScene::cleanScene()
removeItem(myPolygonPath);
delete(myPolygonPath);
}
TitleText->setPlainText("BLOCK NAME HERE (not visible)");
TitleText->setPlainText("BLOCK NAME HERE not visible");
TitleText->updatePosition();
this->addItem(TitleText);
textItemsByID.clear();
}
int DiagramScene::addTextItem(DiagramTextItem * textItem)
{
for(int i=0; i<255; i++)
for(int i=0; i<256; i++)
{
QHash<int,DiagramTextItem *>::iterator iter= textItemsByID.find(i);
if(iter==textItemsByID.end())

8
Software/sie_cg/block_editor/diagramscene.h Normal file → Executable file
View File

@ -83,11 +83,12 @@ public:
int addTextItem(DiagramTextItem * textItem);
void removeTextItem(DiagramTextItem * textItem);
Arrow *myPolygonPath;
QString createPrototype();
public slots:
void setMode(Mode mode){myMode=mode;}
void editorLostFocus(DiagramTextItem *item);
void setMode(Mode mode){myMode=mode;}
signals:
void textInserted(QGraphicsTextItem *item);
@ -108,8 +109,7 @@ private:
QString myTypeString;
bool leftButtonDown;
QPointF startPoint;
QGraphicsLineItem *line;
Arrow *myPolygonPath;
QGraphicsLineItem *line;
QFont myFont;
DiagramTextItem *textItem;
DiagramTextItem *TitleText;

0
Software/sie_cg/block_editor/diagramscene.pro Normal file → Executable file
View File

28
Software/sie_cg/block_editor/diagramscene.pro.user Normal file → Executable file
View File

@ -76,7 +76,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-mvXjaDjNgc,guid=2d86690d9bd83b6a69b540554cf6e2bd</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
@ -84,7 +84,7 @@
<value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
<value type="QString">GDM_LANG=en_US.utf8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-tlrgjl</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/juan64bits</value>
<value type="QString">LANG=en_US.utf8</value>
@ -95,17 +95,17 @@
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/juan64bits</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1257,unix/Maximus:/tmp/.ICE-unix/1257</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=7560</value>
<value type="QString">SSH_AGENT_PID=1408</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
<value type="QString">SSH_AGENT_PID=1393</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-tlrgjl/ssh</value>
<value type="QString">USER=juan64bits</value>
<value type="QString">USERNAME=juan64bits</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-UYZHqR/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1291248314.906440-791960316</value>
</valuelist>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<value type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor/diagramscene.pro</value>
@ -124,7 +124,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-mvXjaDjNgc,guid=2d86690d9bd83b6a69b540554cf6e2bd</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
@ -132,7 +132,7 @@
<value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
<value type="QString">GDM_LANG=en_US.utf8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-tlrgjl</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/juan64bits</value>
<value type="QString">LANG=en_US.utf8</value>
@ -143,17 +143,17 @@
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/juan64bits</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1257,unix/Maximus:/tmp/.ICE-unix/1257</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=7560</value>
<value type="QString">SSH_AGENT_PID=1408</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
<value type="QString">SSH_AGENT_PID=1393</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-tlrgjl/ssh</value>
<value type="QString">USER=juan64bits</value>
<value type="QString">USERNAME=juan64bits</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-UYZHqR/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1291248314.906440-791960316</value>
</valuelist>
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
<valuelist key="abstractProcess.arguments" type="QVariantList">

0
Software/sie_cg/block_editor/diagramscene.qrc Normal file → Executable file
View File

77
Software/sie_cg/block_editor/diagramtextitem.cpp Normal file → Executable file
View File

@ -56,14 +56,19 @@ DiagramTextItem::DiagramTextItem(
editableItem=editable;
setPlainText(defaultText);
posOffset=offset;
//setFlag(QGraphicsItem::ItemIsMovable,0);
if(editable)
setFlag(QGraphicsItem::ItemIsSelectable,1);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
if(myStyleIO==0xFFF)
setFlag(QGraphicsItem::ItemIsMovable,false);
else
setFlag(QGraphicsItem::ItemIsFocusable,0);
setFlag(QGraphicsItem::ItemIsMovable,true);
setFlag(QGraphicsItem::ItemIsSelectable,true);
editorOpened=0;
updatePosition();
moving=0;
}
void DiagramTextItem::updatePosition()
@ -81,22 +86,25 @@ void DiagramTextItem::updatePosition()
QVariant DiagramTextItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedHasChanged)
emit selectedChange(this);
return value;
}
void DiagramTextItem::focusOutEvent(QFocusEvent *event)
{
if(editableItem)
{
if(toPlainText()=="") setPlainText("?");
//updatePosition();
setTextInteractionFlags(Qt::NoTextInteraction);
emit lostFocus(this);
QGraphicsTextItem::focusOutEvent(event);
}
setPlainText(toPlainText().trimmed());
if(toPlainText()=="") setPlainText("?");
setTextInteractionFlags(Qt::NoTextInteraction);
if(myStyleIO!=0xFFF)
setFlag(QGraphicsItem::ItemIsMovable,true);
QTextCursor cursor = textCursor();
cursor.clearSelection();
setTextCursor(cursor);
QGraphicsTextItem::focusOutEvent(event);
editorOpened=0;
updatePosition();
}
void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
@ -105,36 +113,47 @@ void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
if (textInteractionFlags() == Qt::NoTextInteraction)
setTextInteractionFlags(Qt::TextEditorInteraction);
setSelected(1);
setFocus(Qt::MouseFocusReason);
setFlag(QGraphicsItem::ItemIsMovable,false);
editorOpened=1;
}
QGraphicsTextItem::mouseDoubleClickEvent(event);
QGraphicsTextItem::mouseDoubleClickEvent(event);
}
void DiagramTextItem::snapToGrid(QGraphicsSceneMouseEvent *event)
{
if(myStyleIO!=0xFFF)
setOffset(event->scenePos());
updatePosition();
setOffset(event->scenePos());
}
void DiagramTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
moving=1;
//snapToGrid(event);
QGraphicsTextItem::mousePressEvent(event);
if(editorOpened==0)
{
printf("StyleIO:[%x]",myStyleIO); fflush(stdout);
snapToGrid(event);
QGraphicsTextItem::mousePressEvent(event);
}
}
void DiagramTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
moving=0;
QGraphicsTextItem::mouseReleaseEvent(event);
{
if(editorOpened==0 && myStyleIO!=0xFFF)
{
snapToGrid(event);
QGraphicsTextItem::mouseReleaseEvent(event);
}
}
void DiagramTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if(moving)
snapToGrid(event);
QGraphicsTextItem::mouseMoveEvent(event);
if(editorOpened==0 && myStyleIO!=0xFFF)
{
snapToGrid(event);
QGraphicsTextItem::mouseMoveEvent(event);
updatePosition();
}
}
QDomElement DiagramTextItem::toXml(QDomDocument &document) const

2
Software/sie_cg/block_editor/diagramtextitem.h Normal file → Executable file
View File

@ -112,7 +112,7 @@ private:
int myStyleIO;
unsigned char myID;
QGraphicsScene *myOwnerScene;
bool moving;
bool editorOpened;
};
#endif

View File

@ -0,0 +1,35 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="Divider Int">
<Polygon>
<Point x="-60" y="-10"/>
<Point x="-60" y="10"/>
<Point x="20" y="10"/>
<Point x="20" y="-10"/>
<Point x="60" y="-10"/>
<Point x="60" y="10"/>
<Point x="20" y="10"/>
<Point x="60" y="10"/>
<Point x="60" y="-10"/>
<Point x="-20" y="-10"/>
<Point x="-40" y="10"/>
<Point x="-20" y="10"/>
<Point x="-20" y="10"/>
<Point x="-30" y="10"/>
<Point x="-40" y="10"/>
<Point x="-40" y="10"/>
<Point x="-20" y="-10"/>
<Point x="-40" y="-10"/>
<Point x="-40" y="-10"/>
<Point x="-20" y="-10"/>
<Point x="-20" y="-10"/>
<Point x="-20" y="-10"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="131" posOffset-y="-0" editableItem="0" ID="0" text="IN" posOffset-x="-60"/>
<TextItem myStyleIO="3" posOffset-y="-0" editableItem="0" ID="1" text="OUT" posOffset-x="60"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="2" text="1" posOffset-x="0"/>
</TextItems><![CDATA[]]><![CDATA[
]]><![CDATA[
out_1 = in_o / value_2;
]]><![CDATA[]]></CustomItem>

View File

@ -0,0 +1,64 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="FB Draw HLine">
<Polygon>
<Point x="-80" y="-70"/>
<Point x="100" y="-70"/>
<Point x="100" y="-50"/>
<Point x="-80" y="-50"/>
<Point x="-80" y="10"/>
<Point x="100" y="10"/>
<Point x="100" y="-50"/>
<Point x="100" y="10"/>
<Point x="-20" y="10"/>
<Point x="-20" y="-50"/>
<Point x="100" y="-50"/>
<Point x="100" y="-30"/>
<Point x="-20" y="-30"/>
<Point x="60" y="-30"/>
<Point x="60" y="-50"/>
<Point x="100" y="-50"/>
<Point x="100" y="-30"/>
<Point x="100" y="-10"/>
<Point x="-20" y="-10"/>
<Point x="60" y="-10"/>
<Point x="60" y="-30"/>
<Point x="100" y="-30"/>
<Point x="100" y="-10"/>
<Point x="100" y="10"/>
<Point x="100" y="-10"/>
<Point x="60" y="-10"/>
<Point x="60" y="10"/>
<Point x="-20" y="10"/>
<Point x="-80" y="10"/>
<Point x="-80" y="-10"/>
<Point x="-60" y="-10"/>
<Point x="-20" y="-10"/>
<Point x="-60" y="-10"/>
<Point x="-60" y="-30"/>
<Point x="-20" y="-30"/>
<Point x="-80" y="-30"/>
<Point x="-60" y="-30"/>
<Point x="-60" y="-30"/>
<Point x="-60" y="-50"/>
<Point x="-80" y="-50"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="11" text="Y" posOffset-x="-70"/>
<TextItem myStyleIO="0" posOffset-y="40" editableItem="0" ID="10" text="X" posOffset-x="-70"/>
<TextItem myStyleIO="0" posOffset-y="40" editableItem="1" ID="1" text="0" posOffset-x="-40"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="1" ID="2" text="0" posOffset-x="-40"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="1" ID="7" text="255" posOffset-x="80"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="4" text="Maximum" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="40" editableItem="1" ID="9" text="8" posOffset-x="80"/>
<TextItem myStyleIO="0" posOffset-y="40" editableItem="0" ID="8" text="Bar width" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="5" text="3" posOffset-x="80"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="6" text="Color Idx" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="60" editableItem="0" ID="0" text="Frame Buffer Draw HBar" posOffset-x="10"/>
<TextItem myStyleIO="138" posOffset-y="-0" editableItem="0" ID="3" text="IN UShort" posOffset-x="-80"/>
</TextItems><![CDATA[]]><![CDATA[]]><![CDATA[ if(!firstLoop) // do nothing in first loop
{
fillrect(value_1,value_2,value_1+value_7,value_2+value_9,0); //Black Rect
rect(value_1,value_2,value_1+value_7,value_2+value_9,value_5); //Extern Rect
fillrect(value_1,value_2,value_1+(in_3%(value_7+1)),value_2+value_9,value_5);
}
]]><![CDATA[]]></CustomItem>

View File

@ -0,0 +1,60 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="FB Print Line">
<Polygon>
<Point x="-140" y="-30"/>
<Point x="-140" y="30"/>
<Point x="160" y="30"/>
<Point x="160" y="-10"/>
<Point x="160" y="10"/>
<Point x="120" y="10"/>
<Point x="160" y="10"/>
<Point x="160" y="30"/>
<Point x="120" y="30"/>
<Point x="120" y="10"/>
<Point x="60" y="10"/>
<Point x="20" y="10"/>
<Point x="60" y="10"/>
<Point x="60" y="30"/>
<Point x="20" y="30"/>
<Point x="20" y="10"/>
<Point x="0" y="10"/>
<Point x="-40" y="10"/>
<Point x="0" y="10"/>
<Point x="0" y="30"/>
<Point x="-40" y="30"/>
<Point x="-40" y="10"/>
<Point x="-60" y="10"/>
<Point x="-60" y="30"/>
<Point x="-80" y="30"/>
<Point x="-80" y="10"/>
<Point x="-60" y="10"/>
<Point x="-80" y="10"/>
<Point x="-140" y="10"/>
<Point x="-140" y="30"/>
<Point x="-140" y="-10"/>
<Point x="160" y="-10"/>
<Point x="160" y="-30"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="1" ID="9" text="1" posOffset-x="140"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="0" ID="8" text="Color idx" posOffset-x="90"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="1" ID="7" text="0" posOffset-x="40"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="0" ID="6" text="Y" posOffset-x="10"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="1" ID="5" text="0" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="0" ID="4" text="X" posOffset-x="-50"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="1" ID="3" text="1" posOffset-x="-70"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="0" ID="2" text="Center" posOffset-x="-110"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="1" text="&lt;Insert Text to Show MAX 40>" posOffset-x="0"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="0" text="Frame Buffer Print Line" posOffset-x="0"/>
</TextItems><![CDATA[]]><![CDATA[
]]><![CDATA[
if(value_3)
{
put_string_center (value_5,value_7,"value_1", value_9);
}
else
{
put_string (value_5,value_7,"value_1", value_9%5);
}
]]><![CDATA[]]></CustomItem>

View File

@ -0,0 +1,53 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="FB Put Int">
<Polygon>
<Point x="-100" y="-40"/>
<Point x="100" y="-40"/>
<Point x="100" y="-20"/>
<Point x="-100" y="-20"/>
<Point x="-100" y="-40"/>
<Point x="-100" y="20"/>
<Point x="60" y="20"/>
<Point x="60" y="0"/>
<Point x="100" y="0"/>
<Point x="100" y="20"/>
<Point x="60" y="20"/>
<Point x="100" y="20"/>
<Point x="100" y="0"/>
<Point x="100" y="0"/>
<Point x="100" y="-20"/>
<Point x="100" y="-20"/>
<Point x="100" y="-20"/>
<Point x="100" y="-20"/>
<Point x="100" y="-20"/>
<Point x="100" y="-20"/>
<Point x="100" y="-20"/>
<Point x="100" y="0"/>
<Point x="60" y="0"/>
<Point x="60" y="-20"/>
<Point x="40" y="-20"/>
<Point x="40" y="0"/>
<Point x="60" y="0"/>
<Point x="0" y="0"/>
<Point x="0" y="-20"/>
<Point x="-20" y="-20"/>
<Point x="-20" y="0"/>
<Point x="0" y="0"/>
<Point x="-20" y="0"/>
<Point x="-20" y="20"/>
<Point x="-100" y="20"/>
<Point x="-100" y="20"/>
<Point x="-100" y="-20"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="7" text="0" posOffset-x="80"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="6" text="Color idx" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="30" editableItem="0" ID="0" text="Frame Buffer Print Integer" posOffset-x="0"/>
<TextItem myStyleIO="131" posOffset-y="-0" editableItem="0" ID="1" text="IN Integer" posOffset-x="-100"/>
<TextItem myStyleIO="0" posOffset-y="10" editableItem="0" ID="2" text="X" posOffset-x="-10"/>
<TextItem myStyleIO="0" posOffset-y="10" editableItem="1" ID="3" text="0" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="10" editableItem="0" ID="4" text="Y" posOffset-x="50"/>
<TextItem myStyleIO="0" posOffset-y="10" editableItem="1" ID="5" text="0" posOffset-x="80"/>
</TextItems><![CDATA[]]><![CDATA[]]><![CDATA[
put_int(value_3,value_5,in_1,value_7);
]]><![CDATA[]]></CustomItem>

48
Software/sie_cg/block_editor/left_shift.die Normal file → Executable file
View File

@ -1,18 +1,40 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="Left Shift">
<Polygon>
<Point x="-70" y="-30"/>
<Point x="-70" y="20"/>
<Point x="60" y="20"/>
<Point x="60" y="-30"/>
<Point x="-50" y="-30"/>
<Point x="-70" y="-30"/>
<Point x="-50" y="0"/>
<Point x="-50" y="20"/>
<Point x="-20" y="20"/>
<Point x="-30" y="10"/>
<Point x="-20" y="0"/>
<Point x="-20" y="0"/>
<Point x="-30" y="10"/>
<Point x="-20" y="20"/>
<Point x="-20" y="20"/>
<Point x="-10" y="20"/>
<Point x="-20" y="10"/>
<Point x="-10" y="0"/>
<Point x="0" y="0"/>
<Point x="-10" y="10"/>
<Point x="0" y="20"/>
<Point x="-10" y="20"/>
<Point x="10" y="20"/>
<Point x="50" y="20"/>
<Point x="0" y="20"/>
<Point x="-10" y="10"/>
<Point x="0" y="0"/>
<Point x="40" y="0"/>
<Point x="40" y="20"/>
<Point x="80" y="20"/>
<Point x="40" y="20"/>
<Point x="40" y="0"/>
<Point x="80" y="0"/>
<Point x="80" y="20"/>
<Point x="80" y="0"/>
<Point x="40" y="0"/>
<Point x="-20" y="0"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="131" posOffset-y="-0" editableItem="0" ID="0" text="IN" posOffset-x="-70"/>
<TextItem myStyleIO="3" posOffset-y="-0" editableItem="0" ID="1" text="OUT" posOffset-x="60"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="5" text="Bitwise Shift" posOffset-x="-10"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text="&lt;&lt;" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
</TextItems>
</CustomItem>
<TextItem myStyleIO="131" posOffset-y="-10" editableItem="0" ID="0" text="IN" posOffset-x="-50"/>
<TextItem myStyleIO="3" posOffset-y="-10" editableItem="0" ID="1" text="OUT" posOffset-x="80"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="20"/>
</TextItems><![CDATA[]]><![CDATA[]]><![CDATA[]]><![CDATA[]]></CustomItem>

0
Software/sie_cg/block_editor/lineitem.cpp Normal file → Executable file
View File

0
Software/sie_cg/block_editor/lineitem.h Normal file → Executable file
View File

0
Software/sie_cg/block_editor/main.cpp Normal file → Executable file
View File

36
Software/sie_cg/block_editor/mainwindow.cpp Normal file → Executable file
View File

@ -64,6 +64,9 @@ MainWindow::MainWindow()
headerTextEdit = new QTextEdit;
headerTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
headerTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
initTextEdit = new QTextEdit;
initTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
initTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
blockTextEdit = new QTextEdit;
blockTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
blockTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
@ -72,26 +75,36 @@ MainWindow::MainWindow()
extraTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
prototypeLabel = new QLabel;
prototypeLabel->setText("\nvoid BLOCK_NAME () {");
QFont proFont = prototypeLabel->font(); proFont.setBold(true);
prototypeLabel->setFont(proFont);
prototypeLabel->setMaximumWidth(1280);
initLabel = new QLabel;
initLabel->setText("Code For Initialization Section Here");
proFont = initLabel->font(); proFont.setItalic(true);;
initLabel->setFont(proFont);
headerLabel = new QLabel;
headerLabel->setText("Code for Header Section Here");
headerLabel->setText("Code For Header Section Here");
headerLabel->setFont(proFont);
extraLabel = new QLabel;
extraLabel->setText("}\n\nCode for Extra Section Here");
extraLabel->setText("}\n\nCode For Extra Section Here");
extraLabel->setFont(proFont);
/* Create central widget */
QGridLayout *layout = new QGridLayout;
layout->addWidget(toolBox,0,0,7,1);
layout->addWidget(toolBox,0,0,9,1);
view = new QGraphicsView(scene);
layout->addWidget(view,0,1,1,1);
layout->addWidget(headerLabel,1,1,1,1);
layout->addWidget(headerTextEdit,2,1,1,1);
layout->addWidget(prototypeLabel,3,1,1,1);
layout->addWidget(blockTextEdit,4,1,1,1);
layout->addWidget(extraLabel,5,1,1,1);
layout->addWidget(extraTextEdit,6,1,1,1);
layout->addWidget(initLabel,3,1,1,1);
layout->addWidget(initTextEdit,4,1,1,1);
layout->addWidget(prototypeLabel,5,1,1,1);
layout->addWidget(blockTextEdit,6,1,1,1);
layout->addWidget(extraLabel,7,1,1,1);
layout->addWidget(extraTextEdit,8,1,1,1);
QWidget *widget = new QWidget;
widget->setLayout(layout);
setCentralWidget(widget);
setWindowTitle(tr("SIE Code Generator (Block Editor)"));
setUnifiedTitleAndToolBarOnMac(true);
@ -110,6 +123,9 @@ void MainWindow::deleteItem()
if (item->type() == Arrow::Type) {
qgraphicsitem_cast<Arrow *>(item)->removeLines();
scene->removeItem(item);
if(qgraphicsitem_cast<Arrow *>(item)==scene->myPolygonPath)
scene->myPolygonPath=0;
delete(item);
}
//If line is deleted then is romoved from the arrow owner
@ -376,6 +392,10 @@ bool MainWindow::newDiagram(QString filePath)
{
saveIfNeeded();
scene->cleanScene();
this->headerTextEdit->clear();
this->initTextEdit->clear();
this->blockTextEdit->clear();
this->extraTextEdit->clear();
prototypeLabel->setText("\nvoid BLOCK_NAME () {");
myFilePath="";

17
Software/sie_cg/block_editor/mainwindow.h Normal file → Executable file
View File

@ -85,6 +85,15 @@ public:
QStatusBar *statusBar;
QLabel * headerLabel;
QTextEdit * headerTextEdit;
QLabel * initLabel;
QTextEdit * initTextEdit;
QLabel * prototypeLabel;
QTextEdit * blockTextEdit;
QLabel * extraLabel;
QTextEdit * extraTextEdit;
private slots:
void deleteItem();
void sceneScaleChanged(const QString &scale);
@ -131,14 +140,6 @@ private:
QButtonGroup *buttonGroup;
QLabel * headerLabel;
QTextEdit * headerTextEdit;
QLabel * prototypeLabel;
QTextEdit * blockTextEdit;
QLabel * extraLabel;
QTextEdit * extraTextEdit;
int selectedButton;
QString myFilePath;

View File

@ -0,0 +1,35 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="Multiplier Int">
<Polygon>
<Point x="-60" y="-10"/>
<Point x="-60" y="10"/>
<Point x="20" y="10"/>
<Point x="20" y="-10"/>
<Point x="60" y="-10"/>
<Point x="60" y="10"/>
<Point x="20" y="10"/>
<Point x="60" y="10"/>
<Point x="60" y="-10"/>
<Point x="-20" y="-10"/>
<Point x="-30" y="0"/>
<Point x="-20" y="10"/>
<Point x="-20" y="10"/>
<Point x="-30" y="0"/>
<Point x="-40" y="10"/>
<Point x="-40" y="10"/>
<Point x="-30" y="0"/>
<Point x="-40" y="-10"/>
<Point x="-40" y="-10"/>
<Point x="-30" y="0"/>
<Point x="-20" y="-10"/>
<Point x="-20" y="-10"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="131" posOffset-y="-0" editableItem="0" ID="0" text="IN" posOffset-x="-60"/>
<TextItem myStyleIO="3" posOffset-y="-0" editableItem="0" ID="1" text="OUT" posOffset-x="60"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="2" text="1" posOffset-x="0"/>
</TextItems><![CDATA[]]><![CDATA[
]]><![CDATA[
out_1 = in_o * value_2;
]]><![CDATA[]]></CustomItem>

View File

@ -0,0 +1,29 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="Plus Int">
<Polygon>
<Point x="-60" y="-10"/>
<Point x="-60" y="10"/>
<Point x="-30" y="10"/>
<Point x="-30" y="-10"/>
<Point x="-30" y="0"/>
<Point x="-20" y="0"/>
<Point x="-40" y="0"/>
<Point x="-40" y="0"/>
<Point x="-30" y="0"/>
<Point x="-30" y="10"/>
<Point x="60" y="10"/>
<Point x="60" y="-10"/>
<Point x="60" y="10"/>
<Point x="20" y="10"/>
<Point x="20" y="-10"/>
<Point x="60" y="-10"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="2" text="1" posOffset-x="0"/>
<TextItem myStyleIO="3" posOffset-y="10" editableItem="0" ID="1" text="OUT" posOffset-x="60"/>
<TextItem myStyleIO="131" posOffset-y="-10" editableItem="0" ID="0" text="IN" posOffset-x="-60"/>
</TextItems><![CDATA[]]><![CDATA[
]]><![CDATA[
out_1 = in_o + value_2;
]]><![CDATA[]]></CustomItem>

View File

@ -0,0 +1,24 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="Printf Int">
<Polygon>
<Point x="-60" y="-20"/>
<Point x="70" y="-20"/>
<Point x="70" y="0"/>
<Point x="70" y="0"/>
<Point x="-130" y="0"/>
<Point x="-130" y="0"/>
<Point x="-60" y="0"/>
<Point x="-60" y="-20"/>
<Point x="-130" y="-20"/>
<Point x="-130" y="0"/>
<Point x="-130" y="-20"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="131" posOffset-y="10" editableItem="0" ID="3" text="IN Integer" posOffset-x="-130"/>
<TextItem myStyleIO="0" posOffset-y="10" editableItem="1" ID="0" text="&quot;[%04X]&quot;" posOffset-x="30"/>
<TextItem myStyleIO="0" posOffset-y="10" editableItem="0" ID="1" text="printf" posOffset-x="-40"/>
</TextItems><![CDATA[]]><![CDATA[]]><![CDATA[
printf(value_0, in_3);
fflush(stdout);
]]><![CDATA[]]></CustomItem>

0
Software/sie_cg/block_editor/pwm_single.die Normal file → Executable file
View File

45
Software/sie_cg/block_editor/right_shift.die Normal file → Executable file
View File

@ -1,18 +1,39 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="Right Shift">
<Polygon>
<Point x="-70" y="-30"/>
<Point x="-70" y="20"/>
<Point x="60" y="20"/>
<Point x="60" y="-30"/>
<Point x="-50" y="-30"/>
<Point x="-70" y="-30"/>
<Point x="-60" y="0"/>
<Point x="-60" y="20"/>
<Point x="-40" y="20"/>
<Point x="-30" y="10"/>
<Point x="-40" y="0"/>
<Point x="-40" y="0"/>
<Point x="-30" y="10"/>
<Point x="-40" y="20"/>
<Point x="-40" y="20"/>
<Point x="-30" y="20"/>
<Point x="-20" y="10"/>
<Point x="-30" y="0"/>
<Point x="-20" y="0"/>
<Point x="-10" y="10"/>
<Point x="-20" y="20"/>
<Point x="-30" y="20"/>
<Point x="-20" y="20"/>
<Point x="-10" y="10"/>
<Point x="-20" y="0"/>
<Point x="30" y="0"/>
<Point x="30" y="20"/>
<Point x="-20" y="20"/>
<Point x="20" y="20"/>
<Point x="70" y="20"/>
<Point x="30" y="20"/>
<Point x="30" y="0"/>
<Point x="70" y="0"/>
<Point x="70" y="20"/>
<Point x="70" y="0"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="2" posOffset-y="-0" editableItem="0" ID="3" text="OUT" posOffset-x="60"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="5" text="Bitwise Shift" posOffset-x="-10"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text=">>" posOffset-x="-20"/>
<TextItem myStyleIO="131" posOffset-y="-0" editableItem="0" ID="2" text="IN" posOffset-x="-70"/>
<TextItem myStyleIO="131" posOffset-y="-10" editableItem="0" ID="0" text="IN" posOffset-x="-60"/>
<TextItem myStyleIO="3" posOffset-y="-10" editableItem="0" ID="1" text="OUT" posOffset-x="70"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
</TextItems>
</CustomItem>
</TextItems><![CDATA[]]><![CDATA[]]><![CDATA[
out_1 = in_0 >> value_11;]]><![CDATA[]]></CustomItem>

0
Software/sie_cg/block_editor/test_block1.die Normal file → Executable file
View File

0
Software/sie_cg/block_editor/test_block2.die Normal file → Executable file
View File

0
Software/sie_cg/block_editor/test_block3.die Normal file → Executable file
View File

57
Software/sie_cg/block_editor/test_block4.die Normal file → Executable file
View File

@ -1,29 +1,38 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="BLOCK NAME HERE (not visible)">
<CustomItem BlockName="All IOs">
<Polygon>
<Point x="-60" y="100"/>
<Point x="100" y="100"/>
<Point x="100" y="60"/>
<Point x="50" y="60"/>
<Point x="50" y="20"/>
<Point x="100" y="20"/>
<Point x="100" y="-10"/>
<Point x="100" y="-20"/>
<Point x="50" y="-20"/>
<Point x="-160" y="-40"/>
<Point x="-160" y="270"/>
<Point x="-80" y="270"/>
<Point x="-80" y="120"/>
<Point x="-20" y="270"/>
<Point x="50" y="270"/>
<Point x="50" y="-40"/>
<Point x="50" y="-60"/>
<Point x="100" y="-60"/>
<Point x="100" y="-100"/>
<Point x="-60" y="-100"/>
<Point x="-60" y="-20"/>
<Point x="-100" y="-20"/>
<Point x="-100" y="20"/>
<Point x="-60" y="20"/>
<Point x="-30" y="-40"/>
<Point x="-80" y="120"/>
<Point x="-80" y="-40"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="1" posOffset-y="-80" editableItem="0" ID="8" text="OUT Bool" posOffset-x="100"/>
<TextItem myStyleIO="1" posOffset-y="-0" editableItem="0" ID="1" text="OUT Bool" posOffset-x="100"/>
<TextItem myStyleIO="1" posOffset-y="80" editableItem="0" ID="6" text="OUT Bool" posOffset-x="100"/>
<TextItem myStyleIO="130" posOffset-y="-0" editableItem="0" ID="5" text="IN Bool" posOffset-x="-100"/>
</TextItems>
</CustomItem>
<TextItem myStyleIO="129" posOffset-y="-20" editableItem="0" ID="0" text="IN Bool" posOffset-x="-160"/>
<TextItem myStyleIO="130" posOffset-y="-40" editableItem="0" ID="1" text="IN Char" posOffset-x="-160"/>
<TextItem myStyleIO="131" posOffset-y="-60" editableItem="0" ID="2" text="IN Integer" posOffset-x="-160"/>
<TextItem myStyleIO="132" posOffset-y="-80" editableItem="0" ID="3" text="IN Double" posOffset-x="-160"/>
<TextItem myStyleIO="133" posOffset-y="-100" editableItem="0" ID="4" text="IN Float" posOffset-x="-160"/>
<TextItem myStyleIO="134" posOffset-y="-120" editableItem="0" ID="5" text="IN Short" posOffset-x="-160"/>
<TextItem myStyleIO="135" posOffset-y="-140" editableItem="0" ID="6" text="IN Long" posOffset-x="-160"/>
<TextItem myStyleIO="136" posOffset-y="-160" editableItem="0" ID="7" text="IN UChar" posOffset-x="-160"/>
<TextItem myStyleIO="137" posOffset-y="-180" editableItem="0" ID="8" text="IN UInt" posOffset-x="-160"/>
<TextItem myStyleIO="138" posOffset-y="-200" editableItem="0" ID="9" text="IN UShort" posOffset-x="-160"/>
<TextItem myStyleIO="139" posOffset-y="-220" editableItem="0" ID="10" text="IN ULong" posOffset-x="-160"/>
<TextItem myStyleIO="1" posOffset-y="-20" editableItem="0" ID="11" text="OUT Bool" posOffset-x="50"/>
<TextItem myStyleIO="2" posOffset-y="-40" editableItem="0" ID="12" text="OUT Char" posOffset-x="50"/>
<TextItem myStyleIO="3" posOffset-y="-60" editableItem="0" ID="13" text="OUT Integer" posOffset-x="50"/>
<TextItem myStyleIO="4" posOffset-y="-80" editableItem="0" ID="14" text="OUT Double" posOffset-x="50"/>
<TextItem myStyleIO="5" posOffset-y="-100" editableItem="0" ID="15" text="OUT Float" posOffset-x="50"/>
<TextItem myStyleIO="6" posOffset-y="-120" editableItem="0" ID="16" text="OUT Short" posOffset-x="50"/>
<TextItem myStyleIO="7" posOffset-y="-140" editableItem="0" ID="17" text="OUT Long" posOffset-x="50"/>
<TextItem myStyleIO="8" posOffset-y="-160" editableItem="0" ID="18" text="OUT UChar" posOffset-x="50"/>
<TextItem myStyleIO="9" posOffset-y="-180" editableItem="0" ID="19" text="OUT UInt" posOffset-x="50"/>
<TextItem myStyleIO="10" posOffset-y="-200" editableItem="0" ID="20" text="OUT UShort" posOffset-x="50"/>
<TextItem myStyleIO="11" posOffset-y="-220" editableItem="0" ID="21" text="OUT ULong" posOffset-x="50"/>
</TextItems><![CDATA[]]><![CDATA[]]><![CDATA[]]><![CDATA[]]></CustomItem>

0
Software/sie_cg/block_editor/timer.die Normal file → Executable file
View File

48
Software/sie_cg/block_editor/while.die Normal file → Executable file
View File

@ -1,29 +1,35 @@
<!--File for SIE Code Generator. Custmos Blocks-->
<CustomItem BlockName="System While">
<Polygon>
<Point x="-50" y="-30"/>
<Point x="50" y="-30"/>
<Point x="50" y="-10"/>
<Point x="-50" y="-10"/>
<Point x="-50" y="30"/>
<Point x="0" y="30"/>
<Point x="0" y="0"/>
<Point x="40" y="0"/>
<Point x="40" y="20"/>
<Point x="20" y="20"/>
<Point x="20" y="10"/>
<Point x="50" y="-10"/>
<Point x="50" y="10"/>
<Point x="-50" y="10"/>
<Point x="0" y="10"/>
<Point x="10" y="20"/>
<Point x="0" y="30"/>
<Point x="20" y="30"/>
<Point x="20" y="20"/>
<Point x="20" y="30"/>
<Point x="50" y="30"/>
<Point x="50" y="-10"/>
<Point x="50" y="30"/>
<Point x="-50" y="30"/>
<Point x="-50" y="-10"/>
<Point x="20" y="50"/>
<Point x="-10" y="50"/>
<Point x="-10" y="40"/>
<Point x="0" y="40"/>
<Point x="-20" y="20"/>
<Point x="-40" y="40"/>
<Point x="-30" y="40"/>
<Point x="-30" y="70"/>
<Point x="40" y="70"/>
<Point x="40" y="10"/>
<Point x="50" y="10"/>
<Point x="50" y="80"/>
<Point x="-50" y="80"/>
<Point x="-50" y="10"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="129" posOffset-y="-10" editableItem="0" ID="6" text="IN Bool" posOffset-x="-50"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="23" text="System While" posOffset-x="0"/>
</TextItems>
</CustomItem>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="23" text="System While" posOffset-x="0"/>
<TextItem myStyleIO="129" posOffset-y="-20" editableItem="0" ID="6" text="IN" posOffset-x="-50"/>
</TextItems><![CDATA[/* DON'T CARE */]]><![CDATA[/* DON'T CARE */]]><![CDATA[
do
{
/***![SYSTEM WHILE]***/
firstLoop=0;
}while(in_6);]]><![CDATA[/* DON'T CARE */]]></CustomItem>

45
Software/sie_cg/callapp.cpp Executable file
View File

@ -0,0 +1,45 @@
#include "callapp.h"
callApp::callApp(QString command, QWidget *parent) :
QWidget(parent)
{
myProcess = new QProcess;
myProcess->start(command);
connect(myProcess,SIGNAL(finished(int)),this,SIGNAL(appClosed()));
connect(myProcess,SIGNAL(readyReadStandardError()),this,SLOT(newStderr()));
connect(myProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(newStdout()));
}
bool callApp::isRuning()
{
if(myProcess->state()==QProcess::Running)
return 1;
else
return 0;
}
void callApp::newStderr()
{
myProcess->setReadChannel(QProcess::StandardError);
data = myProcess->readAll();
emit newData();
}
void callApp::newStdout()
{
myProcess->setReadChannel(QProcess::StandardOutput);
data = myProcess->readAll();
emit newData();
}
void callApp::deleteProcess()
{
myProcess->terminate();
myProcess->deleteLater();
}
void callApp::writeData(QString outData)
{
if(isRuning())
myProcess->write(outData.toAscii().data());
}

31
Software/sie_cg/callapp.h Executable file
View File

@ -0,0 +1,31 @@
#ifndef CALLAPP_H
#define CALLAPP_H
#include <QWidget>
#include <QtCore>
class callApp : public QWidget
{
Q_OBJECT
public:
explicit callApp(QString,QWidget *parent = 0);
QString readData()
{ return data;}
bool isRuning();
void writeData(QString);
signals:
void newData();
void appClosed();
public slots:
void newStderr();
void newStdout();
void deleteProcess();
private:
QProcess * myProcess;
QString data;
};
#endif // CALLAPP_H

0
Software/sie_cg/codedialog.cpp Normal file → Executable file
View File

0
Software/sie_cg/codedialog.h Normal file → Executable file
View File

2795
Software/sie_cg/codedialog.ui Normal file → Executable file

File diff suppressed because it is too large Load Diff

43
Software/sie_cg/diagramitem.cpp Normal file → Executable file
View File

@ -42,6 +42,7 @@
#include <QtGui>
#include "diagramitem.h"
#include "diagramscene.h"
#include "arrow.h"
#include "diagramtextitem.h"
#include "lineitem.h"
@ -109,9 +110,10 @@ DiagramItem::DiagramItem(
QString itemString=textItemE.attribute("text");
DiagramTextItem * newTextItem =
new DiagramTextItem(0,0,editableItem,this,myStyleIO,
new DiagramTextItem(0,myOwnerScene,editableItem,this,myStyleIO,
myID,itemString,posOffset);
myOwnerScene->addItem(newTextItem);
newTextItem->setZValue(zValue());
addText(newTextItem);
}
@ -121,7 +123,9 @@ DiagramItem::DiagramItem(
setPolygon(myPolygon);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
}
bool DiagramItem::setValue(unsigned char ID, QString value)
@ -158,6 +162,16 @@ bool DiagramItem::textIsIO(unsigned char ID)
return 0;
}
bool DiagramItem::existText(DiagramTextItem * text)
{
foreach(DiagramTextItem *item, textItems)
{
if(item==text)
return 1;
}
return 0;
}
unsigned char DiagramItem::existArrow(DiagramTextItem *startItem,
DiagramTextItem *endItem)
{
@ -244,19 +258,28 @@ QVariant DiagramItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (change == QGraphicsItem::ItemPositionChange) {
foreach (Arrow *arrow, arrows) {
arrow->updatePosition();
}
positionChanged=1;
}
return value;
}
void DiagramItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
void DiagramItem::updateTexts()
{
foreach (DiagramTextItem *texts, textItems) {
texts->updatePosition();
}
}
void DiagramItem::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
positionChanged=0;
qobject_cast<DiagramScene *>(myOwnerScene)->saveUndo();
QGraphicsPolygonItem::mousePressEvent(mouseEvent);
}
void DiagramItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
updateTexts();
foreach (Arrow *arrow, arrows) {
arrow->updatePosition();
}
@ -271,6 +294,12 @@ void DiagramItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
foreach (Arrow *arrow, arrows) {
arrow->updatePosition();
}
if(!positionChanged)
qobject_cast<DiagramScene *>(myOwnerScene)->removeLastUndo();
else
qobject_cast<DiagramScene *>(myOwnerScene)->clearRedo();
QGraphicsPolygonItem::mouseReleaseEvent(mouseEvent);
}

31
Software/sie_cg/diagramitem.h Normal file → Executable file
View File

@ -48,6 +48,9 @@
#include <QtXml>
#include <stdio.h>
class Arrow;
class DiagramTextItem;
QT_BEGIN_NAMESPACE
class QPixmap;
class QGraphicsItem;
@ -64,9 +67,6 @@ QT_END_NAMESPACE
class QObject;
class Arrow;
class DiagramTextItem;
class DiagramItem : public QGraphicsPolygonItem
{
public:
@ -105,11 +105,13 @@ public:
QList<DiagramTextItem *> getTextItems() const
{ return textItems;}
QList<Arrow *> getArrows() const
{ return arrows;}
unsigned char existArrow(DiagramTextItem *startItem,
DiagramTextItem *endItem);
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{QGraphicsPolygonItem::mousePressEvent(mouseEvent);}
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
@ -122,20 +124,35 @@ public:
void setColor(const QColor &color)
{ myColor=color; setBrush(color); }
int getID()
{ return myID;}
void setID(int value)
{ myID=value;}
bool existText(DiagramTextItem * text);
QGraphicsScene * getOwnerScene()
{ return myOwnerScene;}
void updateTexts();
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
QGraphicsScene *myOwnerScene;
QString myDiagramType;
int myID;
QPolygonF myPolygon;
QMenu *myContextMenu;
QList<Arrow *> arrows;
QList<DiagramTextItem *> textItems;
QGraphicsScene *myOwnerScene;
QList<DiagramTextItem *> textItems;
DiagramTextItem *textItem;
QColor myColor;
QDomElement *myDomElement;
bool positionChanged;
};
#endif

302
Software/sie_cg/diagramscene.cpp Normal file → Executable file
View File

@ -58,51 +58,84 @@ DiagramScene::DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow,
myLineColor = Qt::black;
snapToGrid=1;
myGrid=10;
drawGrid=1;
drawGrid=0;
myOwnerWindow=ownerWindow;
}
void DiagramScene::setLineColor(const QColor &color)
{
myLineColor = color;
if (isItemChange(Arrow::Type)) {
Arrow *item =
qgraphicsitem_cast<Arrow *>(selectedItems().first());
item->setColor(myLineColor);
update();
//Lists of items
QList<Arrow *> Arrows;
QList<lineItem *> lineItems;
foreach(QGraphicsItem *item, selectedItems()){
if(item->type() == lineItem::Type)
lineItems.append(qgraphicsitem_cast<lineItem *>(item));
else if(item->type() == Arrow::Type)
Arrows.append(qgraphicsitem_cast<Arrow *>(item));
}
foreach(Arrow *arrow, Arrows){
saveUndoState();
arrow->setColor(myLineColor);
}
foreach(lineItem *line, lineItems){
saveUndoState();
line->myOwner()->setColor(myLineColor);
}
update();
}
void DiagramScene::setTextColor(const QColor &color)
{
myTextColor = color;
if (isItemChange(DiagramTextItem::Type)) {
DiagramTextItem *item =
qgraphicsitem_cast<DiagramTextItem *>(selectedItems().first());
item->setDefaultTextColor(myTextColor);
//Lists of items
QList<DiagramTextItem *> textItems;
foreach(QGraphicsItem *item, selectedItems()){
if(item->type() == DiagramTextItem::Type)
textItems.append(qgraphicsitem_cast<DiagramTextItem *>(item));
}
foreach(DiagramTextItem *textItem, textItems){
if(textItem->ownerItem()==0)
{
saveUndoState();
textItem->setDefaultTextColor(myTextColor);
}
}
update();
}
void DiagramScene::setItemColor(const QColor &color)
{
myItemColor = color;
if (isItemChange(DiagramItem::Type)) {
DiagramItem *item =
qgraphicsitem_cast<DiagramItem *>(selectedItems().first());
//Lists of items
QList<DiagramItem *> items;
foreach(QGraphicsItem *item, selectedItems()){
if(item->type() == DiagramItem::Type)
items.append(qgraphicsitem_cast<DiagramItem *>(item));
}
foreach(DiagramItem *item, items){
saveUndoState();
item->setColor(myItemColor);
}
}
void DiagramScene::setFont(const QFont &font)
void DiagramScene::setFont(QFont font)
{
myFont = font;
if (isItemChange(DiagramTextItem::Type)) {
QGraphicsTextItem *item =
saveUndoState();
DiagramTextItem *item =
qgraphicsitem_cast<DiagramTextItem *>(selectedItems().first());
//At this point the selection can change so the first selected item might not be a DiagramTextItem
if (item)
item->setFont(myFont);
item->setFontt(myFont);
}
}
@ -116,16 +149,29 @@ void DiagramScene::setItemType(QString type)
myItemType = type;
}
void DiagramScene::editorLostFocus(DiagramTextItem *item)
void DiagramScene::saveUndoState()
{
QTextCursor cursor = item->textCursor();
cursor.clearSelection();
item->setTextCursor(cursor);
saveUndo();
clearRedo();
fflush(stdout);
}
void DiagramScene::saveUndo()
{
myOwnerWindow->undoList.append(toXmlFormat());
fflush(stdout);
}
if (item->toPlainText().isEmpty()) {
removeItem(item);
item->deleteLater();
}
void DiagramScene::removeLastUndo()
{
if(!myOwnerWindow->undoList.isEmpty())
myOwnerWindow->undoList.removeLast();
fflush(stdout);
}
void DiagramScene::clearRedo()
{
myOwnerWindow->redoList.clear();
fflush(stdout);
}
void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
@ -135,36 +181,55 @@ void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
if (mouseEvent->button() != Qt::LeftButton)
return;
foreach (QGraphicsItem *item, this->items(mouseEvent->scenePos())) {
if (item->type() == DiagramTextItem::Type)
{
myOwnerWindow->setFontSettings(qgraphicsitem_cast<DiagramTextItem *>
(item)->font());
}
}
DiagramItem *item;
int addResult=0;
switch (myMode) {
case InsertItem:
saveUndoState();
item = new DiagramItem(myItemMenu,myItemType,
domElementsByName.value(myItemType),0,this);
item->setColor(myItemColor);
addItem(item);
item->setPos(mouseEvent->scenePos());
domElementsByName->value(myItemType),0,this);
addResult=addDiagramItem(item);
if(addResult!=-1)
{
item->setColor(myItemColor);
item->setPos(mouseEvent->scenePos());
item->setID(addResult);
item->updateTexts();
addItem(item);
}
else
{
delete(item);
QMessageBox::warning(0,"Full","The diagram can only have "
"5000 blocks. <b>You are crasy?</b>");
}
emit itemInserted(item);
break;
case InsertLine:
line = new QGraphicsLineItem(QLineF(mouseEvent->scenePos(),
mouseEvent->scenePos()));
line->setPen(QPen(myLineColor, 2));
line->setZValue(1000.0);
addItem(line);
line->setZValue(1000.0);
snapToGrid=0;
addItem(line);
break;
case InsertText:
textItem = new DiagramTextItem();
textItem->setFont(myFont);
textItem->setTextInteractionFlags(Qt::TextEditorInteraction);
textItem->setZValue(1000.0);
connect(textItem, SIGNAL(lostFocus(DiagramTextItem*)),
this, SLOT(editorLostFocus(DiagramTextItem*)));
connect(textItem, SIGNAL(selectedChange(QGraphicsItem*)),
this, SIGNAL(itemSelected(QGraphicsItem*)));
addItem(textItem);
case InsertText:
saveUndoState();
textItem = new DiagramTextItem(0,this);
textItem->setFontt(myFont);
textItem->setZValue(1000.0);
textItem->setDefaultTextColor(myTextColor);
textItem->setPos(mouseEvent->scenePos());
addItem(textItem);
emit textInserted(textItem);
default:
;
@ -191,6 +256,18 @@ void DiagramScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
} else if (myMode == MoveItem) {
QGraphicsScene::mouseMoveEvent(mouseEvent);
}
QPointF mousePos = mouseEvent->scenePos();
QString barMesg= QString("X[%1] Y[%2]").arg(QString::number(mousePos.x()))
.arg(QString::number(mousePos.y()));
foreach (QGraphicsItem *item, items(mousePos)) {
if (item->type() == DiagramItem::Type) {
barMesg+= tr(" ** Over diagram block with ID[") +
QString::number(qgraphicsitem_cast<DiagramItem *>
(item)->getID()) + tr("]");
}
}
myOwnerWindow->statusBar->showMessage(barMesg);
}
void DiagramScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
@ -223,7 +300,7 @@ void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
DiagramTextItem *endItem_ =
qgraphicsitem_cast<DiagramTextItem *>(endItems.first());
//Real first and end item
//Real first and real end item
DiagramTextItem *startItem = startItem_;
DiagramTextItem *endItem = endItem_;
if(startItem_->styleIO()>>7)
@ -232,7 +309,7 @@ void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
endItem = startItem_;
}
//Inputs to outputs and diferent owner diagram item
//Inputs to outputs and diferent owner
if(startItem->styleIO()>0 &&
endItem->styleIO()>0 &&
(startItem->styleIO()>>7 != endItem->styleIO()>>7) &&
@ -240,6 +317,7 @@ void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
!endItem->ownerItem()->existArrow(startItem,endItem)
)
{
saveUndoState();
Arrow *arrow = new Arrow(startItem, endItem,0,this);
arrow->setColor(myLineColor);
startItem->ownerItem()->addArrow(arrow);
@ -264,6 +342,25 @@ bool DiagramScene::isItemChange(int type)
return false;
}
int DiagramScene::addDiagramItem(DiagramItem * item)
{
for(int i=0; i<5000; i++)
{
QHash<int,DiagramItem *>::iterator iter= DiagramsID.find(i);
if(iter==DiagramsID.end())
{
DiagramsID.insert(i,item);
return i;
}
}
return -1;
}
void DiagramScene::removeDiagramItem(DiagramItem * item)
{
DiagramsID.remove(DiagramsID.key(item));
}
QDomDocument DiagramScene::toXmlFormat()
{
QDomDocument document;
@ -280,15 +377,21 @@ QDomDocument DiagramScene::toXmlFormat()
//Lists of items
QList<DiagramItem *> Items;
QList<Arrow *> Arrows;
QList<DiagramTextItem *> TextItems;
foreach(QGraphicsItem *item, items())
{
if(item->type() == DiagramItem::Type)
Items.append(qgraphicsitem_cast<DiagramItem *>(item));
else if(item->type() == Arrow::Type)
Arrows.append(qgraphicsitem_cast<Arrow *>(item));
else if(item->type() == DiagramTextItem::Type)
if(qgraphicsitem_cast<DiagramTextItem *>(item)->ownerItem() == 0)
TextItems.append(qgraphicsitem_cast<DiagramTextItem *>(item));
}
//Create the XML structure
QDomElement element;
//Save libraries
if(!libraryList.isEmpty())
{
QDomElement libraries = document.createElement("Libraries");
@ -301,35 +404,67 @@ QDomDocument DiagramScene::toXmlFormat()
diagram.appendChild(libraries);
}
//Save options
QDomElement options = document.createElement("Options");
options.setAttribute("templateDir", myOwnerWindow->templateDir);
options.setAttribute("templateFile", myOwnerWindow->templateFile);
options.setAttribute("makeFile", myOwnerWindow->makeFile);
options.setAttribute("workDir", myOwnerWindow->workDir);
options.setAttribute("executableFile", myOwnerWindow->executableFile);
options.setAttribute("mipsToolChainDir", myOwnerWindow->mipsToolChainDir);
options.setAttribute("mipsToolChain", myOwnerWindow->mipsToolChain);
options.setAttribute("sieWorkDir", myOwnerWindow->sieWorkDir);
options.setAttribute("fpgaFile", myOwnerWindow->fpgaFile);
options.setAttribute("sieIP", myOwnerWindow->sieIP);
options.setAttribute("configApp", myOwnerWindow->configApp);
diagram.appendChild(options);
//Save items
if(!Items.isEmpty())
{
QDomElement diagramItems = document.createElement("DiagramItems");
foreach(DiagramItem *item, Items)
{
element = item->toXml(document);
element.setAttribute("ID",Items.indexOf(item)); //save index
element.setAttribute("ID",item->getID()); //save index
diagramItems.appendChild(element);
}
diagram.appendChild(diagramItems);
}
//Save arrows
if(!Arrows.isEmpty())
{
QDomElement arrowItems = document.createElement("Arrows");
foreach(Arrow *item, Arrows)
{
element = item->toXml(document,Items);
element = item->toXml(document,DiagramsID);
element.setAttribute("ID",Arrows.indexOf(item)); //save index
arrowItems.appendChild(element);
}
diagram.appendChild(arrowItems);
}
//Save text items
if(!TextItems.isEmpty())
{
QDomElement textItems = document.createElement("TextItems");
foreach(DiagramTextItem *item, TextItems)
{
element = item->toXml(document);
textItems.appendChild(element);
}
diagram.appendChild(textItems);
}
return(document);
}
int DiagramScene::fromXmlFormat(QDomDocument document)
{
//Read diagrams TODO: in future... add multi projects functionality
DiagramsID.clear();
//Read diagrams TODO: in future... add multi projects functionality
QDomNodeList diagrams = document.elementsByTagName("Diagram");
if(!diagrams.at(0).isElement())
return 0;
@ -344,7 +479,21 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
node = node.nextSibling())
{
QDomElement element = node.toElement();
if(element.tagName()=="Libraries")
if(element.tagName()=="Options")
{
myOwnerWindow->templateDir= element.attribute("templateDir");
myOwnerWindow->templateFile= element.attribute("templateFile");
myOwnerWindow->makeFile= element.attribute("makeFile");
myOwnerWindow->workDir= element.attribute("workDir");
myOwnerWindow->executableFile= element.attribute("executableFile");
myOwnerWindow->mipsToolChainDir= element.attribute("mipsToolChainDir");
myOwnerWindow->mipsToolChain= element.attribute("mipsToolChain");
myOwnerWindow->sieWorkDir= element.attribute("sieWorkDir");
myOwnerWindow->fpgaFile= element.attribute("fpgaFile");
myOwnerWindow->sieIP= element.attribute("sieIP");
myOwnerWindow->configApp= element.attribute("configApp");
}
else if(element.tagName()=="Libraries")
{
libraryList.clear();
for (QDomNode node = element.firstChild() ;
@ -373,7 +522,7 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
QPointF position = QPointF(diagramItem.attribute("x").toFloat(),
diagramItem.attribute("y").toFloat());
//PREVENT Segmentation faults:
if(!domElementsByName.contains(
if(!domElementsByName->contains(
diagramItem.attribute("type")))
{
QMessageBox::critical(0,"Error",QObject::tr(
@ -387,14 +536,15 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
DiagramItem *newItem=new DiagramItem(
myItemMenu,
diagramItem.attribute("type"),
domElementsByName.value(diagramItem.attribute("type")),
domElementsByName->value(diagramItem.attribute("type")),
0,this, position,
diagramItem.attribute("z").toDouble());
newItem->setColor(QColor(diagramItem.attribute("color")));
int itemID=diagramItem.attribute("ID").toInt();
newItem->setID(itemID);
addItem(newItem);
DiagramsID.insert(diagramItem.attribute("ID").toInt(),newItem);
addItem(newItem);
for (QDomNode node = diagramItem.firstChild() ;
!node.isNull() ;
node = node.nextSibling())
@ -413,8 +563,21 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
return 0;
newItem->setValue(diagramValue.attribute("ID").toInt(),
diagramValue.attribute("value"));
}
}
}
newItem->updateTexts();
if(DiagramsID.find(itemID)!=DiagramsID.end())
{
int result=addDiagramItem(newItem);
QMessageBox::warning(0,"ID Problems",
tr("Block with ID[")+QString::number(itemID)+
tr("] already exists, this will be reasigned to [")+
QString::number(result)+
tr("] for prevent problems."));
newItem->setID(result);
}
else
DiagramsID.insert(itemID,newItem);
}
}
else if(element.tagName()=="Arrows")
@ -496,6 +659,35 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
}
}
}
else if(element.tagName()=="TextItems")
{
for (QDomNode node = element.firstChild() ;
!node.isNull() ;
node = node.nextSibling())
{
//Load library directory
QDomElement textItem = node.toElement();
if(textItem.tagName()!="TextItem")
return 0;
QFont textFont;
textFont.setFamily(textItem.attribute("Family"));
textFont.setPointSize(textItem.attribute("PointSize").toInt());
textFont.setBold(textItem.attribute("Bold").toInt());
textFont.setItalic(textItem.attribute("Italic").toInt());
textFont.setUnderline(textItem.attribute("Underline").toInt());
DiagramTextItem *newText = new DiagramTextItem(0,this);
newText->setFontt(textFont);
newText->setDefaultTextColor(
QColor(textItem.attribute("Color")));
newText->setPos(QPointF(
textItem.attribute("x").toFloat(),
textItem.attribute("y").toFloat()));
newText->setPlainText(textItem.attribute("Text"));
addItem(newText);
}
}
}
return 1;
@ -530,10 +722,14 @@ void DiagramScene::cleanScene()
removeItem(item);
delete(item);
}
this->clear();
DiagramsID.clear();
}
void DiagramScene::drawBackground(QPainter *p, const QRectF &r)
{
//TODO: add a button for activate/deactivate the grid.
QGraphicsScene::drawBackground(p,r);
if(drawGrid)
{

23
Software/sie_cg/diagramscene.h Normal file → Executable file
View File

@ -49,6 +49,9 @@
#include "diagramtextitem.h"
#include "mainwindow.h"
class MainWindow;
class DiagramTextItem;
QT_BEGIN_NAMESPACE
class QGraphicsSceneMouseEvent;
class QMenu;
@ -58,7 +61,6 @@ class QFont;
class QGraphicsTextItem;
class QColor;
QT_END_NAMESPACE
class MainWindow;
class DiagramScene : public QGraphicsScene
{
@ -81,7 +83,7 @@ public:
void setLineColor(const QColor &color);
void setTextColor(const QColor &color);
void setItemColor(const QColor &color);
void setFont(const QFont &font);
void setFont(QFont font);
void setDawGrid(bool value) {drawGrid=value;}
QDomDocument toXmlFormat();
@ -95,17 +97,25 @@ public:
void setLibList(QStringList list)
{libraryList=list;}
void setDomElementsByName(QHash<QString , QDomElement*> hash)
void setDomElementsByName(QHash<QString , QDomElement*> *hash)
{domElementsByName=hash;}
void setButtonIdByName(QHash<QString , int> hash)
{buttonIdByName=hash;}
int addDiagramItem(DiagramItem * item);
void removeDiagramItem(DiagramItem * item);
MainWindow *myOwnerWindow;
void saveUndoState();
void saveUndo();
void removeLastUndo();
void clearRedo();
public slots:
void setMode(Mode mode);
void setItemType(QString type);
void editorLostFocus(DiagramTextItem *item);
signals:
void itemInserted(DiagramItem *item);
@ -137,10 +147,9 @@ private:
bool drawGrid;
short int myGrid;
QStringList libraryList;
QHash<QString , QDomElement*> domElementsByName;
QHash<QString , QDomElement*> *domElementsByName;
QHash<QString , int> buttonIdByName;
QHash<int , DiagramItem *> DiagramsID;
MainWindow *myOwnerWindow;
QHash<int , DiagramItem *> DiagramsID;
};
#endif

12
Software/sie_cg/diagramscene.pro Normal file → Executable file
View File

@ -6,7 +6,9 @@ HEADERS = mainwindow.h \
lineitem.h \
codedialog.h \
codedialog.h \
codedialog.h
codedialog.h \
optionsdialog.h \
callapp.h
SOURCES = mainwindow.cpp \
diagramitem.cpp \
main.cpp \
@ -14,7 +16,9 @@ SOURCES = mainwindow.cpp \
diagramtextitem.cpp \
diagramscene.cpp \
lineitem.cpp \
codedialog.cpp
codedialog.cpp \
optionsdialog.cpp \
callapp.cpp
RESOURCES = diagramscene.qrc
TARGET = diagrameditor
@ -34,4 +38,6 @@ QT += xml \
svg \
network
FORMS += librarydialog.ui \
codedialog.ui
codedialog.ui \
optionsdialog.ui

30
Software/sie_cg/diagramscene.pro.user Normal file → Executable file
View File

@ -76,7 +76,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-ANEmxjNrar,guid=b2cd0a27678afcae11dfdd2f4cf7f3f4</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
@ -84,11 +84,10 @@
<value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
<value type="QString">GDM_LANG=en_US.utf8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9rqYs9</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/juan64bits</value>
<value type="QString">LANG=en_US.utf8</value>
<value type="QString">LANGUAGE=</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=juan64bits</value>
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
@ -96,17 +95,17 @@
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/juan64bits</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1361,unix/Maximus:/tmp/.ICE-unix/1361</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=7560</value>
<value type="QString">SSH_AGENT_PID=1408</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
<value type="QString">SSH_AGENT_PID=1397</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-9rqYs9/ssh</value>
<value type="QString">USER=juan64bits</value>
<value type="QString">USERNAME=juan64bits</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-GWLb48/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1291318260.225592-1616873193</value>
</valuelist>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<value type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/diagramscene.pro</value>
@ -125,7 +124,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-ANEmxjNrar,guid=b2cd0a27678afcae11dfdd2f4cf7f3f4</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
@ -133,11 +132,10 @@
<value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
<value type="QString">GDM_LANG=en_US.utf8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9rqYs9</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/juan64bits</value>
<value type="QString">LANG=en_US.utf8</value>
<value type="QString">LANGUAGE=</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=juan64bits</value>
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
@ -145,17 +143,17 @@
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/juan64bits</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1361,unix/Maximus:/tmp/.ICE-unix/1361</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=7560</value>
<value type="QString">SSH_AGENT_PID=1408</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
<value type="QString">SSH_AGENT_PID=1397</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-9rqYs9/ssh</value>
<value type="QString">USER=juan64bits</value>
<value type="QString">USERNAME=juan64bits</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-GWLb48/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1291318260.225592-1616873193</value>
</valuelist>
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
<valuelist key="abstractProcess.arguments" type="QVariantList">

3
Software/sie_cg/diagramscene.qrc Normal file → Executable file
View File

@ -25,5 +25,8 @@
<file>images/zoom_in.png</file>
<file>images/zoom_out.png</file>
<file>images/cg.png</file>
<file>images/grid.png</file>
<file>images/redo.png</file>
<file>images/undo.png</file>
</qresource>
</RCC>

114
Software/sie_cg/diagramtextitem.cpp Normal file → Executable file
View File

@ -49,7 +49,9 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, QGraphicsScene *scene,
unsigned char ID, QString defaultText, QPointF offset)
: QGraphicsTextItem(parent, scene)
{
myOwnerScene = scene;
myOwnerItem = ownerItem;
//currentOwnerItem=0;
myStyleIO = styleIO;
myID=ID;
editableItem=editable;
@ -61,16 +63,17 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, QGraphicsScene *scene,
setPlainText(defaultText);
posOffset=offset;
if(editable)
if(editable && myOwnerItem==0)
{
if (myOwnerItem==0)
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setFlag(QGraphicsItem::ItemIsMovable,true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
}
else
setFlag(QGraphicsItem::ItemIsFocusable,0);
updatePosition();
setFlag(QGraphicsItem::ItemIsSelectable,true);
onlyOneUndo=1;
editorOpened=0;
updatePosition();
}
void DiagramTextItem::updatePosition()
@ -102,8 +105,8 @@ void DiagramTextItem::updatePosition()
QVariant DiagramTextItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedHasChanged)
emit selectedChange(this);
if (change == QGraphicsItem::ItemPositionChange)
positionChanged=1;
return value;
}
@ -114,49 +117,110 @@ void DiagramTextItem::focusOutEvent(QFocusEvent *event)
{
if(toPlainText()=="") setPlainText("?");
if(myOwnerItem!=0) updatePosition();
//Close editor
setTextInteractionFlags(Qt::NoTextInteraction);
emit lostFocus(this);
QTextCursor cursor = textCursor();
cursor.clearSelection();
setTextCursor(cursor);
QGraphicsTextItem::focusOutEvent(event);
//Determine undo state
if(myOwnerItem==0) setFlag(QGraphicsItem::ItemIsMovable,true);
if(toPlainText()==currentText)
qobject_cast<DiagramScene*>(myOwnerScene)->removeLastUndo();
else
qobject_cast<DiagramScene*>(myOwnerScene)->clearRedo();
onlyOneUndo=1;
editorOpened=0;
//Allow deletions when editor is closed
qobject_cast<DiagramScene *>(myOwnerScene)->myOwnerWindow
->dontDelete =0;
}
}
void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
if(editableItem)
{
if (textInteractionFlags() == Qt::NoTextInteraction)
setTextInteractionFlags(Qt::TextEditorInteraction);
QGraphicsTextItem::mouseDoubleClickEvent(event);
}
{
if(onlyOneUndo)
{
//Save current state to undo list
currentText = toPlainText();
qobject_cast<DiagramScene *>(myOwnerScene)->saveUndo();
//Open editor
if (textInteractionFlags() == Qt::NoTextInteraction)
setTextInteractionFlags(Qt::TextEditorInteraction);
setSelected(1);
setFocus(Qt::MouseFocusReason);
setFlag(QGraphicsItem::ItemIsMovable,false);
editorOpened=1;
//Prevent deletions when editor is opened
qobject_cast<DiagramScene *>(myOwnerScene)->myOwnerWindow
->dontDelete = 1;
}
doubleClicked=1;
onlyOneUndo=0;
}
}
void DiagramTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (myOwnerItem!=0)
{
setSelected(0);
myOwnerItem->mousePressEvent(event);
}
else
QGraphicsTextItem::mousePressEvent(event);
{
if (myOwnerItem!=0 && editorOpened==0)
{
setSelected(0);
myOwnerItem->mousePressEvent(event);
}
else
{
positionChanged=0;
doubleClicked=0;
qobject_cast<DiagramScene *>(myOwnerScene)->saveUndo();
QGraphicsTextItem::mousePressEvent(event);
}
}
void DiagramTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (myOwnerItem!=0)
if (myOwnerItem!=0 && editorOpened==0)
{
myOwnerItem->mouseReleaseEvent(event);
}
else
{
if(!doubleClicked)
{
if(!positionChanged)
qobject_cast<DiagramScene*>(myOwnerScene)->removeLastUndo();
else
qobject_cast<DiagramScene*>(myOwnerScene)->clearRedo();
}
QGraphicsTextItem::mouseReleaseEvent(event);
}
}
void DiagramTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (myOwnerItem!=0)
if (myOwnerItem!=0 && editorOpened==0)
{
myOwnerItem->mouseMoveEvent(event);
}
else
QGraphicsTextItem::mouseMoveEvent(event);
}
QDomElement DiagramTextItem::toXml(QDomDocument &document) const
{
QDomElement textItem = document.createElement("TextItem");
//Set attibutes; Text and Font
textItem.setAttribute("Text",toPlainText());
textItem.setAttribute("Family",myFont.family());
textItem.setAttribute("PointSize",myFont.pointSize());
textItem.setAttribute("Bold",myFont.bold());
textItem.setAttribute("Italic",myFont.italic());
textItem.setAttribute("Underline",myFont.underline());
textItem.setAttribute("Color",defaultTextColor().name());
textItem.setAttribute("x",pos().x());
textItem.setAttribute("y",pos().y());
return (textItem);
}

19
Software/sie_cg/diagramtextitem.h Normal file → Executable file
View File

@ -43,6 +43,7 @@
#define DIAGRAMTEXTITEM_H
#include <QGraphicsTextItem>
#include <QtGui>
#include <QPen>
#include "diagramitem.h"
@ -52,6 +53,7 @@ class QGraphicsItem;
class QGraphicsScene;
class QGraphicsSceneMouseEvent;
QT_END_NAMESPACE
class QFont;
class DiagramTextItem : public QGraphicsTextItem
{
@ -63,7 +65,7 @@ public:
DiagramTextItem(
QGraphicsItem *parent = 0, QGraphicsScene *scene = 0,
bool editable =1, DiagramItem *ownerItem=0, unsigned char styleIO = 0,
unsigned char ID=0, QString defaultText="<text>",
unsigned char ID=0,QString defaultText="<double click for edit text>",
QPointF offset=QPointF(0,0));
int type() const
@ -84,6 +86,11 @@ public:
bool isEditable()
{ return editableItem;}
void setFontt(QFont f)
{myFont = f; setFont(myFont);}
QDomElement toXml(QDomDocument &) const;
public slots:
void updatePosition();
@ -101,10 +108,18 @@ protected:
private:
bool editableItem;
DiagramItem *myOwnerItem;
DiagramItem *myOwnerItem;
DiagramItem *currentOwnerItem;
QGraphicsScene *myOwnerScene;
QPointF posOffset;
unsigned char myStyleIO;
unsigned char myID;
QFont myFont;
QString currentText;
bool positionChanged;
bool doubleClicked;
bool onlyOneUndo;
bool editorOpened;
};
#endif

BIN
Software/sie_cg/images/background1.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
Software/sie_cg/images/background2.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
Software/sie_cg/images/background3.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
Software/sie_cg/images/background4.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 3.9 KiB

0
Software/sie_cg/images/bold.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 274 B

0
Software/sie_cg/images/bringtofront.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 514 B

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

0
Software/sie_cg/images/delete.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

0
Software/sie_cg/images/exit.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
Software/sie_cg/images/floodfill.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 299 B

BIN
Software/sie_cg/images/grid.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

0
Software/sie_cg/images/italic.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 247 B

After

Width:  |  Height:  |  Size: 247 B

BIN
Software/sie_cg/images/linecolor.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 295 B

BIN
Software/sie_cg/images/linepointer.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 278 B

0
Software/sie_cg/images/lower1.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

0
Software/sie_cg/images/new.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

0
Software/sie_cg/images/no.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 831 B

After

Width:  |  Height:  |  Size: 831 B

0
Software/sie_cg/images/open.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

0
Software/sie_cg/images/pointer.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

0
Software/sie_cg/images/preview.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

0
Software/sie_cg/images/raise1.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

0
Software/sie_cg/images/save.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
Software/sie_cg/images/save_as.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

0
Software/sie_cg/images/sendtoback.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 430 B

After

Width:  |  Height:  |  Size: 430 B

BIN
Software/sie_cg/images/textpointer.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 753 B

After

Width:  |  Height:  |  Size: 680 B

0
Software/sie_cg/images/underline.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

0
Software/sie_cg/images/yes.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

0
Software/sie_cg/images/zoom_in.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

0
Software/sie_cg/images/zoom_out.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

136
Software/sie_cg/librarydialog.ui Normal file → Executable file
View File

@ -6,39 +6,102 @@
<rect>
<x>0</x>
<y>0</y>
<width>333</width>
<height>341</height>
<width>538</width>
<height>454</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listLib"/>
</item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="addLib">
<property name="text">
<string>&amp;Add Library</string>
</property>
</widget>
<widget class="QListWidget" name="listLib"/>
</item>
<item>
<widget class="QPushButton" name="delLib">
<property name="text">
<string>&amp;Remove library</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editLib">
<property name="text">
<string>&amp;Edit library</string>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="addLib">
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Add Library</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editLib">
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Edit library</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="delLib">
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Remove library</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="upLib">
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Up</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="downLib">
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Down</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
@ -50,14 +113,25 @@
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Library paths will be saved when you save your diagram...</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

27
Software/sie_cg/lineitem.cpp Normal file → Executable file
View File

@ -42,6 +42,7 @@
#include <QtGui>
#include "lineitem.h"
#include "diagramscene.h"
#include <math.h>
lineItem::lineItem(QPointF startPoint, QPointF endItem, Arrow *ownerArrow,
@ -49,7 +50,8 @@ lineItem::lineItem(QPointF startPoint, QPointF endItem, Arrow *ownerArrow,
: QGraphicsLineItem(parent, scene)
{
isMovable=movable;
if(isMovable) setFlag(QGraphicsItem::ItemIsMovable, true);
if(isMovable)
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -103,10 +105,21 @@ void lineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
}
}
QVariant lineItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (change == QGraphicsItem::ItemPositionChange)
positionChanged=1;
return value;
}
void lineItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
if(!isMovable)
{
qobject_cast<DiagramScene *>(myOwnerArrow->myOwnerScene)
->saveUndoState();
myOwnerArrow->createCorner(mouseEvent->pos(),this);
}
QGraphicsLineItem::mouseDoubleClickEvent(mouseEvent);
@ -114,7 +127,11 @@ void lineItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
void lineItem::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
{
positionChanged=0;
qobject_cast<DiagramScene *>(myOwnerArrow->myOwnerScene)->saveUndo();
myOwner()->setSelectedLines(false);
setSelected(true);
QGraphicsLineItem::mousePressEvent(mouseEvent);
}
@ -133,5 +150,11 @@ void lineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
updatePos();
}
if(!positionChanged)
qobject_cast<DiagramScene *>(myOwnerArrow->myOwnerScene)
->removeLastUndo();
else
qobject_cast<DiagramScene *>(myOwnerArrow->myOwnerScene)
->clearRedo();
QGraphicsLineItem::mouseReleaseEvent(mouseEvent);
}

2
Software/sie_cg/lineitem.h Normal file → Executable file
View File

@ -86,6 +86,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
QColor myColor;
@ -93,6 +94,7 @@ private:
Arrow *myOwnerArrow;
int moveItem;
bool isMovable;
bool positionChanged;
};
#endif

0
Software/sie_cg/main.cpp Normal file → Executable file
View File

55
Software/sie_cg/main.cpp2 Executable file
View File

@ -0,0 +1,55 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtGui>
#include "mainwindow.h"
int main(int argv, char *args[])
{
Q_INIT_RESOURCE(diagramscene);
QApplication app(argv, args);
MainWindow mainWindow;
mainWindow.setGeometry(100, 100, 1024, 640);
mainWindow.show();
return app.exec();
}

1179
Software/sie_cg/mainwindow.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

114
Software/sie_cg/mainwindow.h Normal file → Executable file
View File

@ -55,11 +55,16 @@
#include "arrow.h"
#include "ui_librarydialog.h"
#include "ui_codedialog.h"
#include "ui_optionsdialog.h"
#include "callapp.h"
class callApp;
class DiagramScene;
class DiagramTextItem;
class DiagramItem;
class Ui_libraryDialog;
class Ui_cgDialog;
class Ui_optionsDialog;
class callexternappT;
QT_BEGIN_NAMESPACE
@ -91,11 +96,31 @@ public:
int updateLibraries();
QStatusBar *statusBar;
void setFontSettings(QFont font);
// Options
QString templateDir;
QString templateFile;
QString makeFile;
QString workDir;
QString executableFile;
QString mipsToolChain;
QString mipsToolChainDir;
QString sieWorkDir;
QString fpgaFile;
QString sieIP;
QString configApp;
void writeSSH(QString);
//Undo-Redo
QList<QDomDocument> undoList;
QList<QDomDocument> redoList;
bool dontDelete;
private slots:
void backgroundButtonGroupClicked(QAbstractButton *button);
void buttonGroupClicked(int id);
void cgGroupClicked(int id);
void cgGroupClicked();
void deleteItem();
void pointerGroupClicked(int id);
void bringToFront();
@ -112,7 +137,6 @@ private slots:
void fillButtonTriggered();
void lineButtonTriggered();
void handleFontChange();
void itemSelected(QGraphicsItem *item);
void about();
int newDiagram(QString pathFile="");
@ -121,21 +145,52 @@ private slots:
int saveAsDiagram();
int exportDiagram();
void undoDiagram();
void redoDiagram();
void setGridState();
int libraryForm();
void addLibPath();
void delLibPath();
void editLibPath();
void downLibPath();
void upLibPath();
int optionsForm();
void editTemplateDir();
void editWorkDir();
void editToolChain();
void editFPGABinary();
int codeForm();
void executeSSH();
void finishSSH();
void readSSH();
void sendCommand();
void executeCompile();
void finishCompile();
void readCompile();
void configFPGA();
void exeOnSie();
void saveTemplates();
void killProcess();
void lcdOn();
void lcdOff();
private:
void cleanDomElementsByName();
int saveIfNeeded();
void addLibrariesButtons(QGridLayout *layout);
QDomDocument parseDocument(QString filePath);
void createLibraryDialog();
void createCgDialog();
void createOptionsDialog();
void createToolBox();
void createActions();
void createMenus();
@ -169,6 +224,9 @@ private:
QAction *sendBackAction;
QAction *aboutAction;
QAction *undoAction;
QAction *redoAction;
QMenu *fileMenu;
QMenu *itemMenu;
QMenu *preferencesMenu;
@ -195,6 +253,7 @@ private:
QToolButton *fontColorToolButton;
QToolButton *fillColorToolButton;
QToolButton *lineColorToolButton;
QToolButton *gridButton;
QAction *boldAction;
QAction *underlineAction;
QAction *italicAction;
@ -206,10 +265,57 @@ private:
Ui_libraryDialog *libUi;
QMainWindow *cgDialog;
Ui_codeDialog *cgUi;
QDialog *optionsDialog;
Ui_optionsDialog * optUi;
QStringList libraryList;
QHash<QString , QDomElement*> domElementsByName;
QHash<QString , QDomElement*> *domElementsByName;
QHash<QString , int> buttonIdByName;
static QString callexternapp(QString xexecFile, QString xexecParm);
static QString callexternapp(QString xexecFile, QString xexecParm);
void setDefaultOptions(){
templateDir = "templates/basic";
templateFile = "main.cpp";
makeFile = "Makefile";
workDir = "tmp";
executableFile = "SIE_APP";
mipsToolChainDir = "";
mipsToolChain = "mipsel-openwrt-linux";
sieWorkDir = "/tmp/CG";
fpgaFile = "templates/basic/basic.bit";
sieIP = "192.168.254.101";
configApp = "xc3sprog $FPGA_BINARY";
}
/* CG */
QString createPrototype(QList <DiagramTextItem *> &textItems,
QList <QString> &ioTypes,
QList <QString> &ioNames,
QList <QString> &valueNames,
QList <QString> &values,
QString blockNameID,
QList <DiagramTextItem *> &inputs,
QList <DiagramTextItem *> &outputs);
bool itemIsHead(DiagramItem * item);
bool itemIsEnd(DiagramItem * item);
QString getIoType(DiagramTextItem * item);
QString passItem(DiagramItem * item,
QList<DiagramItem *> &passItems,
QList<Arrow *> &passArrows,
QString &headerCode,
QString &initCode,
QString &blockCode,
QString &extraCode,
QString &mainCode,
QString &iosCode,
QString &warnings,
QString &errors);
callApp *sieSSH;
callApp *compile;
bool sshReady;
int copyFileToSie(QString filepath);
QString appDir;
};
class callexternappT : public QThread

0
Software/sie_cg/moc_librarydialog.cpp Normal file → Executable file
View File

View File

@ -0,0 +1,26 @@
#include "optionsdialog.h"
#include "ui_optionsdialog.h"
optionsDialog::optionsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::optionsDialog)
{
ui->setupUi(this);
}
optionsDialog::~optionsDialog()
{
delete ui;
}
void optionsDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}

23
Software/sie_cg/optionsdialog.h Executable file
View File

@ -0,0 +1,23 @@
#ifndef OPTIONSDIALOG_H
#define OPTIONSDIALOG_H
#include <QDialog>
namespace Ui {
class optionsDialog;
}
class optionsDialog : public QDialog {
Q_OBJECT
public:
optionsDialog(QWidget *parent = 0);
~optionsDialog();
protected:
void changeEvent(QEvent *e);
private:
Ui::optionsDialog *ui;
};
#endif // OPTIONSDIALOG_H

426
Software/sie_cg/optionsdialog.ui Executable file
View File

@ -0,0 +1,426 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>optionsDialog</class>
<widget class="QDialog" name="optionsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>547</width>
<height>577</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_11">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Template directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="templateDir">
<property name="text">
<string>templates/basic</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="templateButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Main code template</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="templateFile">
<property name="text">
<string>main.cpp</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_10">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Makefile template</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="makeFile">
<property name="text">
<string>Makefile</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Local work directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="workDir">
<property name="text">
<string>tmp</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="workButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Executable name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="executableFile">
<property name="text">
<string>SIE_APP</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>FPGA binary file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fpgaFile">
<property name="text">
<string>templates/FPGA_binarys/basic.bit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="fpgaButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="label_12">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Toolchain directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mipsToolChainDir">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="toolchainButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_8">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Toolchain base name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mipsToolChain">
<property name="text">
<string>mipsel-openwrt-linux</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>SIE work directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="sieWorkDir">
<property name="text">
<string>/tmp/CG</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>SIE USB0 ip</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="sieIP">
<property name="text">
<string>192.168.254.101</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_7">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>SIE configuration command</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="configApp">
<property name="text">
<string>xcs3prog $FPGA_BINARY</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Options will be saved when you save your diagram...</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>optionsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>optionsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,46 @@
CC = ![MIPS TOOLCHAIN]-gcc
CXX = ![MIPS TOOLCHAIN]-g++
CFLAGS = -pipe -O2 -Wall
CXXFLAGS = -pipe -O2 -Wall
INCPATH = -I.
LINK = ![MIPS TOOLCHAIN]-g++
LFLAGS = -Wl,-O1
LIBS = -L/usr/lib
AR = ![MIPS TOOLCHAIN]-ar cqs
RANLIB = ![MIPS TOOLCHAIN]-ranlib
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
MKDIR = mkdir -p
TARGET = ![SIE APP NAME]
OBJECTS = ![MAIN OBJECT] \
jz_adc_peripheral.o \
jz47xx_gpio.o \
jz47xx_mmap.o
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)
![MAIN OBJECT]: ![MAIN TEMPLATE] \
jz_adc_peripheral.h \
jz47xx_mmap.h \
jz47xx_gpio.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
jz_adc_peripheral.o: jz_adc_peripheral.cpp jz_adc_peripheral.h \
jz47xx_mmap.h \
jz47xx_gpio.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o jz_adc_peripheral.o jz_adc_peripheral.cpp
jz47xx_gpio.o: jz47xx_gpio.cpp jz47xx_gpio.h \
jz47xx_mmap.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o jz47xx_gpio.o jz47xx_gpio.cpp
jz47xx_mmap.o: jz47xx_mmap.cpp jz47xx_mmap.h \
jz47xx_gpio.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o jz47xx_mmap.o jz47xx_mmap.cpp

Binary file not shown.

View File

@ -0,0 +1,108 @@
/*
JZ47xx GPIO at userspace
Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <jz47xx_gpio.h>
#include <jz47xx_mmap.h>
#define JZ_GPIO_BASE 0x10010000
void
jz_gpio_as_output (JZ_PIO * pio, unsigned int o)
{
pio->PXFUNC = (1 << (o));
pio->PXSELC = (1 << (o));
pio->PXDIRS = (1 << (o));
}
void
jz_gpio_as_input (JZ_PIO * pio, unsigned int o)
{
pio->PXFUNC = (1 << (o));
pio->PXSELC = (1 << (o));
pio->PXDIRC = (1 << (o));
}
void
jz_gpio_set_pin (JZ_PIO * pio, unsigned int o)
{
pio->PXDATS = (1 << (o));
}
void
jz_gpio_clear_pin (JZ_PIO * pio, unsigned int o)
{
pio->PXDATC = (1 << (o));
}
void
jz_gpio_out (JZ_PIO * pio, unsigned int o, unsigned int val)
{
if (val == 0)
pio->PXDATC = (1 << (o));
else
pio->PXDATS = (1 << (o));
}
unsigned int
jz_gpio_get_pin (JZ_PIO * pio, unsigned int o)
{
return (pio->PXPIN & (1 << o)) ? 1 : 0;
}
int
jz_gpio_as_func (JZ_PIO * pio, unsigned int o, int func)
{
switch (func)
{
case 0:
pio->PXFUNS = (1 << o);
pio->PXTRGC = (1 << o);
pio->PXSELC = (1 << o);
return 1;
case 1:
pio->PXFUNS = (1 << o);
pio->PXTRGC = (1 << o);
pio->PXSELS = (1 << o);
return 1;
case 2:
pio->PXFUNS = (1 << o);
pio->PXTRGS = (1 << o);
pio->PXSELC = (1 << o);
return 1;
}
return 0;
}
JZ_PIO *
jz_gpio_map (int port)
{
JZ_PIO *pio;
pio = (JZ_PIO *) jz_mmap (JZ_GPIO_BASE);
pio = (JZ_PIO *) ((unsigned int) pio + port * 0x100);
return pio;
}

View File

@ -0,0 +1,84 @@
/*
JZ47xx GPIO at userspace
Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef __jz47xx_gpio_h__
#define __jz47xx_gpio_h__
#define JZ_GPIO_PORT_A 0
#define JZ_GPIO_PORT_B 1
#define JZ_GPIO_PORT_C 2
#define JZ_GPIO_PORT_D 3
typedef volatile unsigned int JZ_REG; /* Hardware register definition */
typedef struct _JZ_PIO
{
JZ_REG PXPIN; /* PIN Level Register */
JZ_REG Reserved0;
JZ_REG Reserved1;
JZ_REG Reserved2;
JZ_REG PXDAT; /* Port Data Register */
JZ_REG PXDATS; /* Port Data Set Register */
JZ_REG PXDATC; /* Port Data Clear Register */
JZ_REG Reserved3;
JZ_REG PXIM; /* Interrupt Mask Register */
JZ_REG PXIMS; /* Interrupt Mask Set Reg */
JZ_REG PXIMC; /* Interrupt Mask Clear Reg */
JZ_REG Reserved4;
JZ_REG PXPE; /* Pull Enable Register */
JZ_REG PXPES; /* Pull Enable Set Reg. */
JZ_REG PXPEC; /* Pull Enable Clear Reg. */
JZ_REG Reserved5;
JZ_REG PXFUN; /* Function Register */
JZ_REG PXFUNS; /* Function Set Register */
JZ_REG PXFUNC; /* Function Clear Register */
JZ_REG Reserved6;
JZ_REG PXSEL; /* Select Register */
JZ_REG PXSELS; /* Select Set Register */
JZ_REG PXSELC; /* Select Clear Register */
JZ_REG Reserved7;
JZ_REG PXDIR; /* Direction Register */
JZ_REG PXDIRS; /* Direction Set Register */
JZ_REG PXDIRC; /* Direction Clear Register */
JZ_REG Reserved8;
JZ_REG PXTRG; /* Trigger Register */
JZ_REG PXTRGS; /* Trigger Set Register */
JZ_REG PXTRGC; /* Trigger Set Register */
JZ_REG Reserved9;
JZ_REG PXFLG; /* Port Flag Register */
JZ_REG PXFLGC; /* Port Flag clear Register */
} JZ_PIO, *PJZ_PIO;
void jz_gpio_as_output (JZ_PIO * pio, unsigned int o);
void jz_gpio_as_input (JZ_PIO * pio, unsigned int o);
void jz_gpio_set_pin (JZ_PIO * pio, unsigned int o);
void jz_gpio_clear_pin (JZ_PIO * pio, unsigned int o);
void jz_gpio_out (JZ_PIO * pio, unsigned int o, unsigned int val);
unsigned int jz_gpio_get_pin (JZ_PIO * pio, unsigned int o);
int jz_gpio_as_func (JZ_PIO * pio, unsigned int o, int func);
JZ_PIO *jz_gpio_map (int port);
#endif

View File

@ -0,0 +1,53 @@
/*
* JZ47xx GPIO lines
*
* Written 2010 by Andres Calderon andres.calderon@emqbit.com
*/
#include "jz47xx_mmap.h"
unsigned int *
jz_mmap (off_t address)
{
int fd;
unsigned int *pio;
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC)) == -1)
{
fprintf (stderr, "Cannot open /dev/mem.\n");
return 0;
}
pio = (unsigned int *) mmap (0, getpagesize (), PROT_READ | PROT_WRITE, MAP_SHARED, fd, address);
if (pio == (unsigned int *) -1)
{
fprintf (stderr, "Cannot mmap.\n");
return 0;
}
return pio;
}
void
jz_cs2_init()
{
JZ_PIO *pio;
pio = jz_gpio_map (CS2_PORT);
jz_gpio_as_func (pio, CS2_PIN, 0);
virt_addr = (JZ_REG *) (jz_mmap(0x13010000) + 0x18);
if (*virt_addr != 0x0FFF7700)
{
*virt_addr = 0x0FFF7700;
printf ("ADC: Configuring CS2 8 bits and 0 WS: %08X\n", *virt_addr);
}
else
printf ("ADC: CS2, already configured: %08X\n", *virt_addr);
virt_addr = (JZ_REG *) jz_mmap (0x14000000);
}

Some files were not shown because too many files have changed in this diff Show More