text:
="0.127" layer="21"/>
<wire x1="-7.74075625" y1="3.352296875" x2="-7.48840625" y2="3.3" width="0.127" layer="21" curve="23.415751"/>
<wire x1="-7.48840625" y1="3.3" x2="7.48840625" y2="3.3" width="0.127" layer="21"/>
<wire x1="7.48840625" y1="3.3" x2="7.74075625" y2="3.352296875" width="0.127" layer="21" curve="23.415886"/>
<wire x1="7.74075625" y1="3.352296875" x2="8.76924375" y2="3.797703125" width="0.127" layer="21"/>
<wire x1="8.76924375" y1="3.797703125" x2="9.02159375" y2="3.85" width="0.127" layer="21" curve="-23.415751"/>
<wire x1="9.02159375" y1="3.85" x2="9.865" y2="3.85" width="0.127" layer="21"/>
<wire x1="9.865" y1="3.85" x2="10.5" y2="3.215" width="0.127" layer="21" curve="-90"/>
<wire x1="10.5" y1="3.215" x2="10.5" y2="-3.215" width="0.127" layer="21"/>
<wire x1="10.5" y1="-3.215" x2="9.865" y2="-3.85" width="0.127" layer="21" curve="-90"/>
<wire x1="9.865" y1="-3.85" x2="9.02159375" y2="-3.85" width="0.127" layer="21"/>
<wire x1="9.02159375" y1="-3.85" x2="8.76924375" y2="-3.797703125" width="0.127" layer="21" curve="-23.415886"/>
<wire x1="8.76924375" y1="-3.797703125" x2="7.74075625" y2="-3.352296875" width="0.127" layer="21"/>
<wire x1="7.74075625" y1="-3.352296875" x2="7.48840625" y2="-3.3" width="0.127" layer="21" curve="23.415751"/>
<wire x1="-12.065" y1="0" x2="-10.541" y2="0" width="0.127" layer="21"/>
<pad name="P$1" x="-13.5" y="0" drill="1.2" diameter="2.2"/>
<pad name="P$2" x="13.5" y="0" drill="1.2" diameter="2.2"/>
<text x="-5.08" y="3.683" size="0.889" layer="25" ratio="11">>name</text>
<text x="-5.08" y="-0.635" size="0.889" layer="27" ratio="11">>value</text>
<rectangle x1="10.541" y1="-0.254" x2="12.192" y2="0.254" layer="21"/>
<rectangle x1="-12.192" y1="-0.254" x2="-10.541" y2="0.254" layer="21"/>
</package>
<package name="R0515_20.4">
<wire x1="-5.08" y1="2.032" x2="5.08" y2="2.032" width="0.127" layer="21"/>
<wire x1="5.08" y1="2.032" x2="5.715" y2="2.413" width="0.127" layer="21"/>
<wire x1="5.715" y1="2.413" x2="7.239" y2="2.413" width="0.127" layer="21"/>
<wire x1="7.239" y1="2.413" x2="7.62" y2="2.032" width="0.127" layer="21" curve="-90"/>
<wire x1="7.62" y1="2.032" x2="7.62" y2="-2.032" width="0.127" layer="21"/>
<wire x1="7.62" y1="-2.032" x2="7.239" y2="-2.413" width="0.127" layer="21" curve="-90"/>
<wire x1="7.239" y1="-2.413" x2="5.715" y2="-2.413" width="0.127" layer="21"/>
<wire x1="5.715" y1="-2.413" x2="5.08" y2="-2.032" width="0.127" layer="21"/>
<wire x1="5.08" y1="-2.032" x2="-5.08" y2="-2.032" width="0.127" layer="21"/>
<wire x1="-5.08" y1="-2.032" x2="-5.715" y2="-2.413" width="0.127" layer="21"/>
<wire x1="-5.715" y1="-2.413" x2="-7.239" y2="-2.413" width="0.127" layer="21"/>
<wire x1="-7.239" y1="-2.413" x2="-7.62" y2="-2.032" width="0.127" layer="21" curve="-90"/>
<wire x1="-7.62" y1="-2.032" x2="-7.62" y2="2.032" width="0.127" layer="21"/>
<wire x1="-7.62" y1="2.032" x2="-7.239" y2="2.413" width="0.127" layer="21" curve="-90"/>
<wire x1="-7.239" y1="2.413" x2="-5.715" y2="2.413" width="0.127" layer="21"/>
<wire x1="-5.715" y1="2.413" x2="-5.08" y2="2.032" width="0.127" layer="21"/>
<pad name="P$1" x="-10.2362" y="0" drill="1.0414" diameter="1.905"/>
<pad name="P$2" x="10.2362" y="0" drill="1.0414" diameter="1.905"/>
<text x="-3.81" y="2.54" size="0.889" layer="25" ratio="11">>NAME</text>
<text x="-4.445" y="-0.635" size="0.889" layer="27" ratio="11">>VALUE</text>
<text x="-1.905" y="-0.635" size="0.8128" layer="33" ratio="10">>NAME</text>
<rectangle x1="-9.144" y1="-0.3175" x2="-7.62" y2="0.3175" layer="21"/>
<rectangle x1="7.62" y1="-0.3175" x2="9.144" y2="0.3175" layer="21"/>
</package>
<package name="R0824_26">
<wire x1="6.508515625" y1="-3.6068" x2="-6.508515625" y2="-3.6068" width="0.127" layer="21"/>
<wire x1="-6.508515625" y1="-3.6068" x2="-6.6952625" y2="-3.63488125" width="0.127" layer="21" curve="17.102957"/>
<wire x1="-6.6952625" y1="-3.63488125" x2="-7.8335375" y2="-3.98511875" width="0.127" layer="21"/>
<wire x1="-7.8335375" y1="-3.98511875" x2="-8.020284375" y2="-4.0132" width="0.127" layer="21" curve="-17.102969"/>
<wire x1="-8.020284375" y1="-4.0132" x2="-11.3538" y2="-4.0132" width="0.127" layer="21"/>
<wire x1="-11.3538" y1="-4.0132" x2="-11.9888" y2="-3.3782" width="0.127" layer="21" curve="-90"/>
<wire x1="-11.9888" y1="-3.3782" x2="-11.9888" y2="3.3782" width="0.127" layer="21"/>
<wire x1="-11.9888" y1="3.3782" x2="-11.3538" y2="4.0132" width="0.127" layer="21" curve="-90"/>
<wire x1="-11.3538" y1="4.0132" x2="-8.020284375" y2="4.0132" width="0.127" layer="21"/>
<wire x1="-8.020284375" y1="4.0132" x2="-7.8335375" y2="3.98511875" width="0.127" layer="21" curve="-17.102957"/>
<wire x1="-7.8335375" y1="3.98511875" x2="-6.6952625" y2="3.63488125" width="0.127" layer="21"/>
<wire x1="-6.6952625" y1="3.63488125" x2="-6.508515625" y2="3.6068" width="0.127" layer="21" curve="17.102969"/>
<wire x1="-6.508515625" y1="3.6068" x2="6.508515625" y2="3.6068" width="0.127" layer="21"/>
<wire x1="6.508515625" y1="3.6068" x2="6.6952625" y2="3.63488125" width="0.127" layer="21" curve="17.102957"/>
<wire x1="6.6952625" y1="3.63488125" x2="7.8335375" y2="3.98511875" width="0.127" layer="21"/>
<wire x1="7.8335375" y1="3.98511875" x2="8.020284375" y2="4.0132" width="0.127" layer="21" curve="-17.102969"/>
<wire x1="8.020284375" y1="4.0132" x2="11.3538" y2="4.0132" width="0.127" layer="21"/>
<wire x1="11.3538" y1="4.0132" x2="11.9888" y2="3.3782" width="0.127" layer="21" curve="-90"/>
<wire x1="11.9888" y1="3.3782" x2="11.9888" y2="-3.3782" width="0.127" layer="21"/>
<wire x1="11.9888" y1="-3.3782" x2="11.3538" y2="-4.0132" width="0.127" layer="21" curve="-90"/>
<wire x1="11.3538" y1="-4.0132" x2="8.020284375" y2="-4.0132" width="0.127" layer="21"/>
<wire x1="8.020284375" y1="-4.0132" x2="7.8335375" y2="-3.98511875" width="0.127" layer="21" curve="-17.102957"/>
<wire x1="7.8335375" y1="-3.98511875" x2="6.6952625" y2="-3.63488125" width="0.127" layer="21"/>
<wire x1="6.6952625" y1="-3.63488125" x2="6.508515625" y2="-3.6068" width="0.127" layer="21" curve="17.102969"/>
<pad name="1" x="-13.335" y="0" drill="1.27" diameter="2.2098"/>
<pad name="2" x="13.335" y="0" drill="1.27" diameter="2.2098"/>
<text x="-4.445" y="3.683" size="0.889" layer="25" ratio="11">>NAME</text>
<text x="-4.445" y="-0.254" size="0.889" layer="27" ratio="11">>VALUE</text>
</package>
<package name="R7519_60.4">
<wire x1="-38.1" y1="9.525" x2="38.1" y2="9.525" width="0.127" layer="21"/>
<wire x1="38.1" y1="9.525" x2="38.1" y2="-9.525" width="0.127" layer="21"/>
<wire x1="38.1" y1="-9.525" x2="-38.1" y2="-9.525" width="0.127" layer="21"/>
<wire x1="-38.1" y1="-9.525" x2="-38.1" y2="9.525" width="0.127" layer="21"/>
<pad name="1" x="-30.226" y="2.54" drill="1.016" diameter="2.032" shape="long" rot="R90"/>
<pad name="2" x="-30.226" y="-2.54" drill="1.016" diameter="2.032" shape="long" rot="R90"/>
<pad name="3" x="30.226" y="2.54" drill="1.016" diameter="2.032" shape="long" rot="R90"/>
<pad name="4" x="30.226" y="-2.54" drill="1.016" diameter="2.032" shape="long" rot="R90"/>
<wire x1="-30.226" y1="1.524" x2="-30.226" y2="3.556" width="1.016" layer="46"/>
<wire x1="-30.226" y1="-3.556" x2="-30.226" y2="-1.524" width="1.016" layer="46"/>
<wire x1="30.226" y1="-3.556" x2="30.226" y2="-1.524" width="1.016" layer="46"/>
<wire x1="30.226" y1="1.524" x2="30.226" y2="3.556" width="1.016" layer="46"/>
<text x="-4.445" y="10.16" size="0.889" layer="25" ratio="11">>NAME</text>
<text x="-4.445" y="-1.778" size="0.889" layer="27" ratio="11">>VALUE</text>
<rectangle x1="-38.1" y1="-9.525" x2="38.1" y2="9.525" layer="39"/>
</package>
<package name="R0402">
<wire x1="-0.4445" y1="0.762" x2="-0.3175" y2="0.889" width="0.0762" layer="21" curve="-90"/>
<wire x1="-0.3175" y1="0.889" x2="0.3175" y2="0.889" width="0.0762" layer="21"/>
<wire x1="0.3175" y1="0.889" x2="0.4445" y2="0.762" width="0.0762" layer="21" curve="-90"/>
<wire x1="0.4445" y1="0.762" x2="0.4445" y2="-0.762" width="0.0762" layer="21"/>
<wire x1="0.4445" y1="-0.762" x2="0.3175" y2="-0.889" width="0.0762" layer="21" curve="-90"/>
<wire x1="0.3175" y1="-0.889" x2="-0.3175" y2="-0.889" width="0.0762" layer="21"/>
<wire x1="-0.3175" y1="-0.889" x2="-0.4445" y2="-0.762" width="0.0762" layer="21" curve="-90"/>
<wire x1="-0.4445" y1="-0.762" x2="-0.4445" y2="0.762" width="0.0762" layer="21"/>
<smd name="1" x="0" y="0.4445" dx="0.635" dy="0.635" layer="1" roundness="50" rot="R270"/>
<smd name="2" x="0" y="-0.4445" dx="0.635" dy="0.635" layer="1" roundness="50" rot="R270"/>
<text x="0.635" y="1.27" size="0.889" layer="25" ratio="11" rot="R270">>NAME</text>
<text x="-1.524" y="1.27" size="0.889" layer="27" font="vector" ratio="11" rot="R270">>VALUE</text>
</package>
<package name="R0603">
<wire x1="0.635" y1="1.397" x2="0.635" y2="-1.397" width="0.127" layer="21"/>
<wire x1="0.635" y1="-1.397" x2="-0.635" y2="-1.397" width="0.127" layer="21"/>
<wire x1="-0.635" y1="-1.397" x2="-0.635" y2="1.397" width="0.127" layer="21"/>
<wire x1="-0.635" y1="1.397" x2="0.635" y2="1.397" width="0.127" layer="21"/>
<smd name="1" x="0" y="0.762" dx="0.889" dy="0.889" layer="1" roundness="25" rot="R270"/>
<smd name="2" x="0" y="-0.762" dx="0.889" dy="0.889" layer="1" roundness="25" rot="R270"/>
<text x="-1.016" y="-1.905" size="0.889" layer="25" ratio="11" rot="R90">>NAME</text>
<text x="0.635" y="-1.905" size="0.635" layer="27" ratio="10" rot="R90">>VALUE</text>
</package>
<package name="R0805">
<wire x1="0.889" y1="-1.651" x2="-0.889" y2="-1.651" width="0.127" layer="21"/>
<wire x1="-0.889" y1="-1.651" x2="-0.889" y2="1.651" width="0.127" layer="21"/>
<wire x1="-0.889" y1="1.651" x2="0.889" y2="1.651" width="0.127" layer="21"/>
<wire x1="0.889" y1="1.651" x2="0.889" y2="-1.651" width="0.127" layer="21"/>
<smd name="1" x="0" y="0.889" dx="1.016" dy="1.397" layer="1" roundness="25" rot="R270"/>
<smd name="2" x="0" y="-0.889" dx="1.016" dy="1.397" layer="1" roundness="25" rot="R270"/>
<text x="1.016" y="1.905" size="0.889" layer="25" font="vector" ratio="11" rot="R270">>NAME</text>
<text x="-1.905" y="1.905" size="0.889" layer="27" ratio="11" rot="R270">>VALUE</text>
</package>
<package name="R0201">
<rectangle x1="-0.3048" y1="-0.1524" x2="-0.1524" y2="0.1524" layer="51"/>
<rectangle x1="0.1524" y1="-0.1524" x2="0.3048" y2="0.1524" layer="51"/>
<smd name="1" x="-0.2794" y="0" dx="0.2794" dy="0.3175" layer="1" roundness="50"/>
<smd name="2" x="0.2794" y="0" dx="0.2794" dy="0.3175" layer="1" roundness="50"/>
<wire x1="-0.3048" y1="0.1524" x2="0.3048" y2="0.1524" width="0.01" layer="51"/>
<wire x1="0.3048" y1="0.1524" x2="0.3048" y2="-0.1524" width="0.01" layer="51"/>
<wire x1="0.3048" y1="-0.1524" x2="-0.3048" y2="-0.1524" width="0.01" layer="51"/>
<wire x1="-0.3048" y1="-0.1524" x2="-0.3048" y2="0.1524" width="0.01" layer="51"/>
<text x="-0.381" y="0.254" size="0.635" layer="25" ratio="11">>name</text>
<text x="-0.381" y="-0.635" size="0.381" layer="27" ratio="11">>value</text>
</package>
<package name="ROUND-MARK-1.0">
<circle x="0" y="0" radius="1.27" width="0" layer="29"/>
<smd name="P$1" x="0" y="0" dx="1.016" dy="1.016" layer="1" roundness="100" stop="no" cream="no"/>
<circle x="0" y="0" radius="1.016" width="0.2032" layer="1"/>
</package>
</packages>
<symbols>
<symbol name="LED">
<wire x1="-1.27" y1="-2.54" x2="-1.27" y2="2.54" width="0.254" layer="94"/>
<wire x1="-1.27" y1="2.54" x2="-1.143" y2="2.413" width="0.254" layer="94"/>
<wire x1="-1.143" y1="2.413" x2="-0.508" y2="1.778" width="0.254" layer="94"/>
<wire x1="-0.508" y1="1.778" x2="1.27" y2="0" width="0.254" layer="94"/>
<wire x1="1.27" y1="0" x2="-1.27" y2="-2.54" width="0.254" layer="94"/>
<wire x1="1.27" y1="2.54" x2="1.27" y2="-2.54" width="0.254" layer="94"/>
<wire x1="-1.143" y1="2.413" x2="0.889" y2="4.445" width="0.254" layer="94"/>
<wire x1="0.889" y1="4.445" x2="0.127" y2="4.318" width="0.254" layer="94"/>
<wire x1="0.889" y1="4.445" x2="0.762" y2="3.683" width="0.254" layer="94"/>
<wire x1="-0.508" y1="1.778" x2="1.524" y2="3.81" width="0.254" layer="94"/>
<wire x1="1.524" y1="3.81" x2="0.762" y2="3.683" width="0.254" layer="94"/>
<wire x1="1.524" y1="3.81" x2="1.397" y2="3.048" width="0.254" layer="94"/>
<text x="-7.62" y="2.54" size="1.27" layer="95" ratio="10">>NAME</text>
<text x="-7.62" y="-3.81" size="1.27" layer="96" ratio="10">>VALUE</text>
<pin name="+" x="-3.81" y="0" visible="off" length="short" direction="pas"/>
<pin name="-" x="3.81" y="0" visible="off" length="short" direction="pas" rot="R180"/>
</symbol>
<symbol name="RES-ARRAY">
<wire x1="-1.27" y1="0.508" x2="1.27" y2="0.508" width="0.254" layer="94"/>
<wire x1="1.27" y1="0.508" x2="1.27" y2="-0.508" width="0.254" layer="94"/>
<wire x1="1.27" y1="-0.508" x2="-1.27" y2="-0.508" width="0.254" layer="94"/>
<wire x1="-1.27" y1="-0.508" x2="-1.27" y2="0.508" width="0.254" layer="94"/>
<text x="-3.81" y="1.27" size="1.27" layer="95" ratio="10">>NAME</text>
<text x="-3.81" y="-2.54" size="1.27" layer="96" ratio="10">>VALUE</text>
<pin name="1" x="-3.81" y="0" visible="off" length="short" direction="pas" swaplevel="1"/>
<pin name="2" x="3.81" y="0" visible="off" length="short" direction="pas" swaplevel="1" rot="R180"/>
</symbol>
<symbol name="MARK-1.0">
<circle x="0" y="0" radius="0.635" width="0.1524" layer="94"/>
<text x="-1.27" y="1.27" size="1.27" layer="95" ratio="10">>NAME</text>
</symbol>
</symbols>
<devicesets>
<deviceset name="LED" prefix="D" uservalue="yes">
<gates>
<gate name="LED" symbol="LED" x="0" y="0" swaplevel="1"/>
</gates>
<devices>
<device name="-3MM" package="LED2-2.54-D3.0MM">
<connects>
<connect gate="LED" pin="+" pad="A"/>
<connect gate="LED" pin="-" pad="K"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="'0603'" package="LED-0603">
<connects>
<connect gate="LED" pin="+" pad="+"/>
<connect gate="LED" pin="-" pad="-"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="'0805'" package="LED-0805">
<connects>
<connect gate="LED" pin="+" pad="+"/>
<connect gate="LED" pin="-" pad="-"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="'5MM'" package="LED2-2.54-D5.0MM">
<connects>
<connect gate="LED" pin="+" pad="+"/>
<connect gate="LED" pin="-" pad="-"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="'LEFT'" package="LED-SIDE-VIEW-0603-LEFT">
<connects>
<connect gate="LED" pin="+" pad="1"/>
<connect gate="LED" pin="-" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="'RIGHT'" package="LED-SIDE-VIEW-0603-RIGHT">
<connects>
<connect gate="LED" pin="+" pad="1"/>
<connect gate="LED" pin="-" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="'1206'" package="LED-1206">
<connects>
<connect gate="LED" pin="+" pad="+"/>
<connect gate="LED" pin="-" pad="-"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="'3528'" package="LED-3528">
<connects>
<connect gate="LED" pin="+" pad="1"/>
<connect gate="LED" pin="-" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="'0402'" package="LED-0402">
<connects>
<connect gate="LED" pin="+" pad="+"/>
<connect gate="LED" pin="-" pad="-"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="'8MM'" package="LED2-SMD-D8.0MM">
<connects>
<connect gate="LED" pin="+" pad="+"/>
<connect gate="LED" pin="-" pad="-"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="" package="LED-2P-2.2-6MM">
<connects>
<connect gate="LED" pin="+" pad="+"/>
<connect gate="LED" pin="-" pad="-"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
<deviceset name="RES" prefix="R" uservalue="yes">
<gates>
<gate name="R" symbol="RES-ARRAY" x="0" y="0" swaplevel="1"/>
</gates>
<devices>
<device name="-0204/5" package="R0204_5">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0204/7" package="R0204_7">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0207/10" package="R0207_10">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0207/12" package="R0207_12">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0207/7" package="R0207_7">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0309/10" package="R0309_10">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0309/12" package="R0309_12">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0309/15" package="R0309_15">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0309/20" package="R0309_20">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-1206" package="R1206">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-2512" package="R2512">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0821/27-5W" package="R0821_27">
<connects>
<connect gate="R" pin="1" pad="P$1"/>
<connect gate="R" pin="2" pad="P$2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0515" package="R0515_20.4">
<connects>
<connect gate="R" pin="1" pad="P$1"/>
<connect gate="R" pin="2" pad="P$2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0824/26-5W" package="R0824_26">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-7519" package="R7519_60.4">
<connects>
<connect gate="R" pin="1" pad="1 2"/>
<connect gate="R" pin="2" pad="3 4"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0402" package="R0402">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0603" package="R0603">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0805" package="R0805">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="-0201" package="R0201">
<connects>
<connect gate="R" pin="1" pad="1"/>
<connect gate="R" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
<deviceset name="MARK-1.0" prefix="P" uservalue="yes">
<gates>
<gate name="G$1" symbol="MARK-1.0" x="0" y="0"/>
</gates>
<devices>
<device name="'ANNULAR'" package="ROUND-MARK-1.0">
<technologies>
<technology name="">
<attribute name="PARTNO" value="DNP"/>
</technology>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
</libraries>
<attributes>
</attributes>
<variantdefs>
</variantdefs>
<classes>
<class number="0" name="default" width="0" drill="0">
</class>
</classes>
<parts>
<part name="J1" library="Connector-new" deviceset="HEADER-15P" device="'2.54'"/>
<part name="J2" library="Connector-new" deviceset="HEADER-15P" device="'2.54'"/>
<part name="A0" library="Connector-new" deviceset="GROVE-CONNECTOR-DIP" device="-2.0" value="DIP GROVE"/>
<part name="U$1" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="I2C" library="Connector-new" deviceset="GROVE-CONNECTOR-DIP" device="-2.0" value="DIP GROVE"/>
<part name="U$2" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="I2C_" library="Connector-new" deviceset="GROVE-CONNECTOR-DIP" device="-2.0" value="DIP GROVE"/>
<part name="U$3" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="D3" library="Connector-new" deviceset="GROVE-CONNECTOR-DIP" device="-2.0" value="DIP GROVE"/>
<part name="U$5" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="D8" library="Connector-new" deviceset="GROVE-CONNECTOR-DIP" device="-2.0" value="DIP GROVE"/>
<part name="U$6" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="D5" library="Connector-new" deviceset="GROVE-CONNECTOR-DIP" device="-2.0" value="DIP GROVE"/>
<part name="U$8" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="D6" library="Connector-new" deviceset="GROVE-CONNECTOR-DIP" device="-2.0" value="DIP GROVE"/>
<part name="U$9" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="D7" library="Connector-new" deviceset="GROVE-CONNECTOR-DIP" device="-2.0" value="DIP GROVE"/>
<part name="U$10" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="UART0" library="Connector-new" deviceset="GROVE-CONNECTOR-DIP" device="-2.0" value="DIP GROVE"/>
<part name="U$11" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="J13" library="Connector-new" deviceset="HEADER-15P" device="'2.54'"/>
<part name="J14" library="Connector-new" deviceset="HEADER-15P" device="'2.54'"/>
<part name="PWR" library="Discrete-new" deviceset="LED" device="'0603'" value="GREEN"/>
<part name="R1" library="Discrete-new" deviceset="RES" device="-0603" value="1k"/>
<part name="U$4" library="Power or GND " deviceset="GND_POWER" device=""/>
<part name="P3" library="Discrete-new" deviceset="MARK-1.0" device="'ANNULAR'"/>
<part name="P4" library="Discrete-new" deviceset="MARK-1.0" device="'ANNULAR'"/>
<part name="P7" library="Discrete-new" deviceset="MARK-1.0" device="'ANNULAR'"/>
<part name="P8" library="Discrete-new" deviceset="MARK-1.0" device="'ANNULAR'"/>
</parts>
<sheets>
<sheet>
<plain>
<text x="190.5" y="11.43" size="1.778" layer="97" ratio="10">Xiangnan Qu</text>
<text x="223.52" y="11.43" size="1.778" layer="97" ratio="10">Bruce Qin</text>
<text x="215.9" y="88.9" size="1.778" layer="97" ratio="10">UART</text>
<text x="207.01" y="105.41" size="1.27" layer="97" ratio="10">TX0</text>
<text x="207.01" y="107.95" size="1.27" layer="97" ratio="10">RX0</text>
<text x="176.53" y="88.9" size="1.778" layer="97" ratio="10">I2C</text>
<text x="135.89" y="88.9" size="1.778" layer="97" ratio="10">ANALOG</text>
<text x="175.26" y="121.92" size="1.778" layer="97" ratio="10">DIGITAL</text>
</plain>
<instances>
<instance part="J1" gate="G$1" x="58.42" y="120.65" smashed="yes">
<attribute name="VALUE" x="57.15" y="142.24" size="1.27" layer="96" ratio="10"/>
<attribute name="NAME" x="57.15" y="144.78" size="1.27" layer="95" ratio="10"/>
</instance>
<instance part="J2" gate="G$1" x="68.58" y="120.65" smashed="yes" rot="MR0">
<attribute name="VALUE" x="69.85" y="142.24" size="1.27" layer="96" ratio="10" rot="MR0"/>
<attribute name="NAME" x="67.31" y="144.78" size="1.27" layer="95" ratio="10"/>
</instance>
<instance part="A0" gate="G$1" x="139.7" y="104.14"/>
<instance part="U$1" gate="G$1" x="130.81" y="97.79"/>
<instance part="I2C" gate="G$1" x="168.91" y="104.14"/>
<instance part="U$2" gate="G$1" x="160.02" y="97.79"/>
<instance part="I2C_" gate="G$1" x="190.5" y="104.14"/>
<instance part="U$3" gate="G$1" x="181.61" y="97.79"/>
<instance part="D3" gate="G$1" x="138.43" y="137.16"/>
<instance part="U$5" gate="G$1" x="129.54" y="130.81"/>
<instance part="D8" gate="G$1" x="222.25" y="137.16"/>
<instance part="U$6" gate="G$1" x="213.36" y="130.81"/>
<instance part="D5" gate="G$1" x="160.02" y="137.16"/>
<instance part="U$8" gate="G$1" x="151.13" y="130.81"/>
<instance part="D6" gate="G$1" x="181.61" y="137.16"/>
<instance part="U$9" gate="G$1" x="172.72" y="130.81"/>
<instance part="D7" gate="G$1" x="201.93" y="137.16"/>
<instance part="U$10" gate="G$1" x="193.04" y="130.81"/>
<instance part="UART0" gate="G$1" x="223.52" y="104.14"/>
<instance part="U$11" gate="G$1" x="214.63" y="97.79"/>
<instance part="J13" gate="G$1" x="58.42" y="120.65" smashed="yes">
<attribute name="VALUE" x="57.15" y="142.24" size="1.27" layer="96" ratio="10"/>
<attribute name="NAME" x="57.15" y="142.24" size="1.27" layer="95" ratio="10"/>
</instance>
<instance part="J14" gate="G$1" x="68.58" y="120.65" smashed="yes" rot="MR0">
<attribute name="VALUE" x="69.85" y="142.24" size="1.27" layer="96" ratio="10" rot="MR0"/>
<attribute name="NAME" x="67.31" y="142.24" size="1.27" layer="95" ratio="10"/>
</instance>
<instance part="PWR" gate="LED" x="74.93" y="36.83" rot="R270"/>
<instance part="R1" gate="R" x="74.93" y="45.72" rot="R270"/>
<instance part="U$4" gate="G$1" x="74.93" y="30.48"/>
<instance part="P3" gate="G$1" x="120.65" y="69.85"/>
<instance part="P4" gate="G$1" x="123.19" y="69.85"/>
<instance part="P7" gate="G$1" x="120.65" y="66.04"/>
<instance part="P8" gate="G$1" x="123.19" y="66.04"/>
</instances>
<busses>
</busses>
<nets>
<net name="RSV" class="0">
<segment>
<wire x1="50.8" y1="135.89" x2="31.75" y2="135.89" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="2"/>
<label x="33.02" y="135.89" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="2"/>
<junction x="50.8" y="135.89"/>
</segment>
</net>
<net name="SD3" class="0">
<segment>
<wire x1="50.8" y1="130.81" x2="31.75" y2="130.81" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="4"/>
<label x="33.02" y="130.81" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="4"/>
<junction x="50.8" y="130.81"/>
</segment>
</net>
<net name="SD1" class="0">
<segment>
<wire x1="50.8" y1="125.73" x2="31.75" y2="125.73" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="6"/>
<label x="33.02" y="125.73" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="6"/>
<junction x="50.8" y="125.73"/>
</segment>
</net>
<net name="SD0" class="0">
<segment>
<wire x1="50.8" y1="120.65" x2="31.75" y2="120.65" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="8"/>
<label x="33.02" y="120.65" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="8"/>
<junction x="50.8" y="120.65"/>
</segment>
</net>
<net name="GND" class="0">
<segment>
<wire x1="50.8" y1="115.57" x2="31.75" y2="115.57" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="10"/>
<label x="33.02" y="115.57" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="10"/>
<junction x="50.8" y="115.57"/>
</segment>
<segment>
<wire x1="50.8" y1="105.41" x2="31.75" y2="105.41" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="14"/>
<label x="33.02" y="105.41" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="14"/>
<junction x="50.8" y="105.41"/>
</segment>
<segment>
<wire x1="95.25" y1="105.41" x2="76.2" y2="105.41" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="14"/>
<label x="80.01" y="105.41" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="14"/>
<junction x="76.2" y="105.41"/>
</segment>
<segment>
<wire x1="95.25" y1="123.19" x2="76.2" y2="123.19" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="7"/>
<label x="80.01" y="123.19" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="7"/>
<junction x="76.2" y="123.19"/>
</segment>
<segment>
<pinref part="A0" gate="G$1" pin="4"/>
<wire x1="135.89" y1="100.33" x2="130.81" y2="100.33" width="0.1524" layer="91"/>
<pinref part="U$1" gate="G$1" pin="GND"/>
<wire x1="130.81" y1="97.79" x2="130.81" y2="100.33" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="I2C" gate="G$1" pin="4"/>
<wire x1="165.1" y1="100.33" x2="160.02" y2="100.33" width="0.1524" layer="91"/>
<pinref part="U$2" gate="G$1" pin="GND"/>
<wire x1="160.02" y1="97.79" x2="160.02" y2="100.33" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="I2C_" gate="G$1" pin="4"/>
<wire x1="186.69" y1="100.33" x2="181.61" y2="100.33" width="0.1524" layer="91"/>
<pinref part="U$3" gate="G$1" pin="GND"/>
<wire x1="181.61" y1="97.79" x2="181.61" y2="100.33" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="D3" gate="G$1" pin="4"/>
<wire x1="134.62" y1="133.35" x2="129.54" y2="133.35" width="0.1524" layer="91"/>
<pinref part="U$5" gate="G$1" pin="GND"/>
<wire x1="129.54" y1="130.81" x2="129.54" y2="133.35" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="D8" gate="G$1" pin="4"/>
<wire x1="218.44" y1="133.35" x2="213.36" y2="133.35" width="0.1524" layer="91"/>
<pinref part="U$6" gate="G$1" pin="GND"/>
<wire x1="213.36" y1="130.81" x2="213.36" y2="133.35" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="D5" gate="G$1" pin="4"/>
<wire x1="156.21" y1="133.35" x2="151.13" y2="133.35" width="0.1524" layer="91"/>
<pinref part="U$8" gate="G$1" pin="GND"/>
<wire x1="151.13" y1="130.81" x2="151.13" y2="133.35" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="D6" gate="G$1" pin="4"/>
<wire x1="177.8" y1="133.35" x2="172.72" y2="133.35" width="0.1524" layer="91"/>
<pinref part="U$9" gate="G$1" pin="GND"/>
<wire x1="172.72" y1="130.81" x2="172.72" y2="133.35" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="D7" gate="G$1" pin="4"/>
<wire x1="198.12" y1="133.35" x2="193.04" y2="133.35" width="0.1524" layer="91"/>
<pinref part="U$10" gate="G$1" pin="GND"/>
<wire x1="193.04" y1="130.81" x2="193.04" y2="133.35" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="UART0" gate="G$1" pin="4"/>
<wire x1="219.71" y1="100.33" x2="214.63" y2="100.33" width="0.1524" layer="91"/>
<pinref part="U$11" gate="G$1" pin="GND"/>
<wire x1="214.63" y1="97.79" x2="214.63" y2="100.33" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="PWR" gate="LED" pin="-"/>
<pinref part="U$4" gate="G$1" pin="GND"/>
<wire x1="74.93" y1="30.48" x2="74.93" y2="33.02" width="0.1524" layer="91"/>
</segment>
</net>
<net name="EN" class="0">
<segment>
<wire x1="50.8" y1="110.49" x2="31.75" y2="110.49" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="12"/>
<label x="33.02" y="110.49" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="12"/>
<junction x="50.8" y="110.49"/>
</segment>
</net>
<net name="VIN" class="0">
<segment>
<wire x1="50.8" y1="102.87" x2="31.75" y2="102.87" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="15"/>
<label x="33.02" y="102.87" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="15"/>
<junction x="50.8" y="102.87"/>
</segment>
</net>
<net name="D0" class="0">
<segment>
<wire x1="95.25" y1="138.43" x2="76.2" y2="138.43" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="1"/>
<label x="80.01" y="138.43" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="1"/>
<junction x="76.2" y="138.43"/>
</segment>
</net>
<net name="D2" class="0">
<segment>
<wire x1="95.25" y1="133.35" x2="76.2" y2="133.35" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="3"/>
<label x="80.01" y="133.35" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="3"/>
<junction x="76.2" y="133.35"/>
</segment>
<segment>
<pinref part="I2C" gate="G$1" pin="2"/>
<wire x1="165.1" y1="105.41" x2="160.02" y2="105.41" width="0.1524" layer="91"/>
<label x="160.02" y="105.41" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="I2C_" gate="G$1" pin="2"/>
<wire x1="186.69" y1="105.41" x2="181.61" y2="105.41" width="0.1524" layer="91"/>
<label x="181.61" y="105.41" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="D4" class="0">
<segment>
<wire x1="95.25" y1="128.27" x2="76.2" y2="128.27" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="5"/>
<label x="80.01" y="128.27" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="5"/>
<junction x="76.2" y="128.27"/>
</segment>
<segment>
<pinref part="D8" gate="G$1" pin="2"/>
<wire x1="218.44" y1="138.43" x2="213.36" y2="138.43" width="0.1524" layer="91"/>
<label x="213.36" y="138.43" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="D6" class="0">
<segment>
<wire x1="95.25" y1="118.11" x2="76.2" y2="118.11" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="9"/>
<label x="80.01" y="118.11" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="9"/>
<junction x="76.2" y="118.11"/>
</segment>
<segment>
<pinref part="D5" gate="G$1" pin="2"/>
<wire x1="156.21" y1="138.43" x2="151.13" y2="138.43" width="0.1524" layer="91"/>
<label x="151.13" y="138.43" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="D6" gate="G$1" pin="1"/>
<wire x1="177.8" y1="140.97" x2="172.72" y2="140.97" width="0.1524" layer="91"/>
<label x="172.72" y="140.97" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="D8" class="0">
<segment>
<wire x1="95.25" y1="113.03" x2="76.2" y2="113.03" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="11"/>
<label x="80.01" y="113.03" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="11"/>
<junction x="76.2" y="113.03"/>
</segment>
<segment>
<pinref part="D7" gate="G$1" pin="2"/>
<wire x1="198.12" y1="138.43" x2="193.04" y2="138.43" width="0.1524" layer="91"/>
<label x="193.04" y="138.43" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="D8" gate="G$1" pin="1"/>
<wire x1="218.44" y1="140.97" x2="213.36" y2="140.97" width="0.1524" layer="91"/>
<label x="213.36" y="140.97" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="D10" class="0">
<segment>
<wire x1="95.25" y1="107.95" x2="76.2" y2="107.95" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="13"/>
<label x="80.01" y="107.95" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="13"/>
<junction x="76.2" y="107.95"/>
</segment>
<segment>
<pinref part="UART0" gate="G$1" pin="2"/>
<wire x1="219.71" y1="105.41" x2="207.01" y2="105.41" width="0.1524" layer="91"/>
<label x="214.63" y="105.41" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="A0" class="0">
<segment>
<pinref part="J1" gate="G$1" pin="1"/>
<wire x1="50.8" y1="138.43" x2="31.75" y2="138.43" width="0.1524" layer="91"/>
<label x="33.02" y="138.43" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="1"/>
<junction x="50.8" y="138.43"/>
</segment>
<segment>
<pinref part="A0" gate="G$1" pin="1"/>
<wire x1="135.89" y1="107.95" x2="130.81" y2="107.95" width="0.1524" layer="91"/>
<label x="130.81" y="107.95" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="RSVV" class="0">
<segment>
<wire x1="50.8" y1="133.35" x2="31.75" y2="133.35" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="3"/>
<label x="33.02" y="133.35" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="3"/>
<junction x="50.8" y="133.35"/>
</segment>
</net>
<net name="SD2" class="0">
<segment>
<wire x1="50.8" y1="128.27" x2="31.75" y2="128.27" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="5"/>
<label x="33.02" y="128.27" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="5"/>
<junction x="50.8" y="128.27"/>
</segment>
</net>
<net name="CMD" class="0">
<segment>
<wire x1="50.8" y1="123.19" x2="31.75" y2="123.19" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="7"/>
<label x="33.02" y="123.19" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="7"/>
<junction x="50.8" y="123.19"/>
</segment>
</net>
<net name="CLK" class="0">
<segment>
<wire x1="50.8" y1="118.11" x2="31.75" y2="118.11" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="9"/>
<label x="33.02" y="118.11" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="9"/>
<junction x="50.8" y="118.11"/>
</segment>
</net>
<net name="3V3" class="0">
<segment>
<wire x1="50.8" y1="113.03" x2="31.75" y2="113.03" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="11"/>
<label x="33.02" y="113.03" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="11"/>
<junction x="50.8" y="113.03"/>
</segment>
<segment>
<wire x1="95.25" y1="102.87" x2="76.2" y2="102.87" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="15"/>
<label x="80.01" y="102.87" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="15"/>
<junction x="76.2" y="102.87"/>
</segment>
<segment>
<wire x1="95.25" y1="125.73" x2="76.2" y2="125.73" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="6"/>
<label x="80.01" y="125.73" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="6"/>
<junction x="76.2" y="125.73"/>
</segment>
<segment>
<pinref part="A0" gate="G$1" pin="3"/>
<wire x1="135.89" y1="102.87" x2="130.81" y2="102.87" width="0.1524" layer="91"/>
<label x="130.81" y="102.87" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="I2C" gate="G$1" pin="3"/>
<wire x1="165.1" y1="102.87" x2="160.02" y2="102.87" width="0.1524" layer="91"/>
<label x="160.02" y="102.87" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="I2C_" gate="G$1" pin="3"/>
<wire x1="186.69" y1="102.87" x2="181.61" y2="102.87" width="0.1524" layer="91"/>
<label x="181.61" y="102.87" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="D3" gate="G$1" pin="3"/>
<wire x1="134.62" y1="135.89" x2="129.54" y2="135.89" width="0.1524" layer="91"/>
<label x="129.54" y="135.89" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="D8" gate="G$1" pin="3"/>
<wire x1="218.44" y1="135.89" x2="213.36" y2="135.89" width="0.1524" layer="91"/>
<label x="213.36" y="135.89" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="D5" gate="G$1" pin="3"/>
<wire x1="156.21" y1="135.89" x2="151.13" y2="135.89" width="0.1524" layer="91"/>
<label x="151.13" y="135.89" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="D6" gate="G$1" pin="3"/>
<wire x1="177.8" y1="135.89" x2="172.72" y2="135.89" width="0.1524" layer="91"/>
<label x="172.72" y="135.89" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="D7" gate="G$1" pin="3"/>
<wire x1="198.12" y1="135.89" x2="193.04" y2="135.89" width="0.1524" layer="91"/>
<label x="193.04" y="135.89" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="UART0" gate="G$1" pin="3"/>
<wire x1="219.71" y1="102.87" x2="214.63" y2="102.87" width="0.1524" layer="91"/>
<label x="214.63" y="102.87" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="R1" gate="R" pin="1"/>
<wire x1="74.93" y1="49.53" x2="74.93" y2="52.07" width="0.1524" layer="91"/>
<label x="73.66" y="52.07" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="RST" class="0">
<segment>
<wire x1="50.8" y1="107.95" x2="31.75" y2="107.95" width="0.1524" layer="91"/>
<pinref part="J1" gate="G$1" pin="13"/>
<label x="33.02" y="107.95" size="1.27" layer="95" ratio="10"/>
<pinref part="J13" gate="G$1" pin="13"/>
<junction x="50.8" y="107.95"/>
</segment>
</net>
<net name="D9" class="0">
<segment>
<wire x1="95.25" y1="110.49" x2="76.2" y2="110.49" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="12"/>
<label x="80.01" y="110.49" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="12"/>
<junction x="76.2" y="110.49"/>
</segment>
<segment>
<pinref part="UART0" gate="G$1" pin="1"/>
<wire x1="219.71" y1="107.95" x2="207.01" y2="107.95" width="0.1524" layer="91"/>
<label x="214.63" y="107.95" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="D7" class="0">
<segment>
<wire x1="95.25" y1="115.57" x2="76.2" y2="115.57" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="10"/>
<label x="80.01" y="115.57" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="10"/>
<junction x="76.2" y="115.57"/>
</segment>
<segment>
<pinref part="D6" gate="G$1" pin="2"/>
<wire x1="177.8" y1="138.43" x2="172.72" y2="138.43" width="0.1524" layer="91"/>
<label x="172.72" y="138.43" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="D7" gate="G$1" pin="1"/>
<wire x1="198.12" y1="140.97" x2="193.04" y2="140.97" width="0.1524" layer="91"/>
<label x="193.04" y="140.97" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="D5" class="0">
<segment>
<wire x1="95.25" y1="120.65" x2="76.2" y2="120.65" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="8"/>
<label x="80.01" y="120.65" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="8"/>
<junction x="76.2" y="120.65"/>
</segment>
<segment>
<pinref part="D5" gate="G$1" pin="1"/>
<wire x1="156.21" y1="140.97" x2="151.13" y2="140.97" width="0.1524" layer="91"/>
<label x="151.13" y="140.97" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="D3" gate="G$1" pin="2"/>
<wire x1="134.62" y1="138.43" x2="129.54" y2="138.43" width="0.1524" layer="91"/>
<label x="129.54" y="138.43" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="D3" class="0">
<segment>
<wire x1="95.25" y1="130.81" x2="76.2" y2="130.81" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="4"/>
<label x="80.01" y="130.81" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="4"/>
<junction x="76.2" y="130.81"/>
</segment>
<segment>
<pinref part="D3" gate="G$1" pin="1"/>
<wire x1="134.62" y1="140.97" x2="129.54" y2="140.97" width="0.1524" layer="91"/>
<label x="129.54" y="140.97" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="D1" class="0">
<segment>
<wire x1="95.25" y1="135.89" x2="76.2" y2="135.89" width="0.1524" layer="91"/>
<pinref part="J2" gate="G$1" pin="2"/>
<label x="80.01" y="135.89" size="1.27" layer="95" ratio="10"/>
<pinref part="J14" gate="G$1" pin="2"/>
<junction x="76.2" y="135.89"/>
</segment>
<segment>
<pinref part="I2C" gate="G$1" pin="1"/>
<wire x1="165.1" y1="107.95" x2="160.02" y2="107.95" width="0.1524" layer="91"/>
<label x="160.02" y="107.95" size="1.27" layer="95" ratio="10"/>
</segment>
<segment>
<pinref part="I2C_" gate="G$1" pin="1"/>
<wire x1="186.69" y1="107.95" x2="181.61" y2="107.95" width="0.1524" layer="91"/>
<label x="181.61" y="107.95" size="1.27" layer="95" ratio="10"/>
</segment>
</net>
<net name="N$1" class="0">
<segment>
<pinref part="PWR" gate="LED" pin="+"/>
<pinref part="R1" gate="R" pin="2"/>
<wire x1="74.93" y1="40.64" x2="74.93" y2="41.91" width="0.1524" layer="91"/>
</segment>
</net>
</nets>
</sheet>
</sheets>
</schematic>
</drawing>
</eagle>

license: MIT

license_type: permissive

branch_name: refs/heads/master


text:
// Code generated by MockGen. DO NOT EDIT.
// Source: ./statefactory/statefactory.go

// Package mock_statefactory is a generated GoMock package.
package mock_statefactory

import (
	gomock "github.com/golang/mock/gomock"
	trx "github.com/iotexproject/iotex-core/blockchain/trx"
	common "github.com/iotexproject/iotex-core/common"
	iotxaddress "github.com/iotexproject/iotex-core/iotxaddress"
	statefactory "github.com/iotexproject/iotex-core/statefactory"
	big "math/big"
	reflect "reflect"
)

// MockStateFactory is a mock of StateFactory interface
type MockStateFactory struct {
	ctrl     *gomock.Controller
	recorder *MockStateFactoryMockRecorder
}

// MockStateFactoryMockRecorder is the mock recorder for MockStateFactory
type MockStateFactoryMockRecorder struct {
	mock *MockStateFactory
}

// NewMockStateFactory creates a new mock instance
func NewMockStateFactory(ctrl *gomock.Controller) *MockStateFactory {
	mock := &MockStateFactory{ctrl: ctrl}
	mock.recorder = &MockStateFactoryMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockStateFactory) EXPECT() *MockStateFactoryMockRecorder {
	return m.recorder
}

// CreateState mocks base method
func (m *MockStateFactory) CreateState(arg0 *iotxaddress.Address) (*statefactory.State, error) {
	ret := m.ctrl.Call(m, "CreateState", arg0)
	ret0, _ := ret[0].(*statefactory.State)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// CreateState indicates an expected call of CreateState
func (mr *MockStateFactoryMockRecorder) CreateState(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateState", reflect.TypeOf((*MockStateFactory)(nil).CreateState), arg0)
}

// Balance mocks base method
func (m *MockStateFactory) Balance(arg0 *iotxaddress.Address) (*big.Int, error) {
	ret := m.ctrl.Call(m, "Balance", arg0)
	ret0, _ := ret[0].(*big.Int)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Balance indicates an expected call of Balance
func (mr *MockStateFactoryMockRecorder) Balance(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Balance", reflect.TypeOf((*MockStateFactory)(nil).Balance), arg0)
}

// UpdateStatesWithTransfer mocks base method
func (m *MockStateFactory) UpdateStatesWithTransfer(arg0 []*trx.Tx) error {
	ret := m.ctrl.Call(m, "UpdateStatesWithTransfer", arg0)
	ret0, _ := ret[0].(error)
	return ret0
}

// UpdateStatesWithTransfer indicates an expected call of UpdateStatesWithTransfer
func (mr *MockStateFactoryMockRecorder) UpdateStatesWithTransfer(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStatesWithTransfer", reflect.TypeOf((*MockStateFactory)(nil).UpdateStatesWithTransfer), arg0)
}

// SetNonce mocks base method
func (m *MockStateFactory) SetNonce(arg0 *iotxaddress.Address, arg1 uint64) error {
	ret := m.ctrl.Call(m, "SetNonce", arg0, arg1)
	ret0, _ := ret[0].(error)
	return ret0
}

// SetNonce indicates an expected call of SetNonce
func (mr *MockStateFactoryMockRecorder) SetNonce(arg0, arg1 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNonce", reflect.TypeOf((*MockStateFactory)(nil).SetNonce), arg0, arg1)
}

// Nonce mocks base method
func (m *MockStateFactory) Nonce(arg0 *iotxaddress.Address) (uint64, error) {
	ret := m.ctrl.Call(m, "Nonce", arg0)
	ret0, _ := ret[0].(uint64)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Nonce indicates an expected call of Nonce
func (mr *MockStateFactoryMockRecorder) Nonce(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nonce", reflect.TypeOf((*MockStateFactory)(nil).Nonce), arg0)
}

// RootHash mocks base method
func (m *MockStateFactory) RootHash() common.Hash32B {
	ret := m.ctrl.Call(m, "RootHash")
	ret0, _ := ret[0].(common.Hash32B)
	return ret0
}

// RootHash indicates an expected call of RootHash
func (mr *MockStateFactoryMockRecorder) RootHash() *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RootHash", reflect.TypeOf((*MockStateFactory)(nil).RootHash))
}

extension: go


text:
// eslint-disable-next-line no-shadow
export enum MemberRoleEnum {
  MEMBER = "MEMBER",
  ADMIN = "ADMIN",
  SUPER_ADMIN = "SUPER_ADMIN",
}

// eslint-disable-next-line no-shadow
export enum OrderStatusEnum {
  PENDING = "PENDING",
  HANDLING = "HANDLING",
  DONE = "DONE",
  CANCELED = "CANCELED",
}

// eslint-disable-next-line no-shadow
export enum CampusEnum {
  XIANLIN = "XIANLIN",
  GULOU = "GULOU",
}

// eslint-disable-next-line no-shadow
export enum AnnouncementType {
  INTERNAL = "INTERNAL",
  EXTERNAL = "EXTERNAL",
}

// eslint-disable-next-line no-shadow
export enum MemberGroupEnum {
  GEEK = "GEEK",
  OP = "OP",
  WEB = "WEB",
}

const enumPairs: { [enumName: string]: string } = {
  GULOU: "鼓楼",
  XIANLIN: "仙林",
  PENDING: "等待处理",
  HANDLING: "正在处理",
  DONE: "已完成",
  CANCELED: "已取消",
  MEMBER: "普通成员",
  ADMIN: "管理员",
  SUPER_ADMIN: "超级管理员",
  GEEK: "geek",
  OP: "op",
  WEB: "web",
};

export function parseEnumValue(enumValue: string, fallback: string = "?") {
  return enumPairs[enumValue] || fallback;
}

export function parseRoleAuthLevel(roleEnumValue: string) {
  switch (roleEnumValue) {
    case "MEMBER":
      return 16;
    case "ADMIN":
      return 32;
    case "SUPER_ADMIN":
      return 64;
    default:
      return 0;
  }
}

repository: pyfile/MakeItxiaGreatAgain

repo_name: pyfile/MakeItxiaGreatAgain

extension: ts


text:
require ${PN}.inc

PR = "r1"

SRC_URI = "http://sources.openembedded.org/opie-1.2.4-split_noncore_styles_theme.tar.bz2;name=split_noncore_styles_theme \
	http://sources.openembedded.org/opie-1.2.4-split_plugins_styles.tar.bz2;name=split_plugins_styles"
SRC_URI[split_noncore_styles_theme.md5sum] = "18ef3df6c95b6fff9ca63256310fb290"
SRC_URI[split_noncore_styles_theme.sha256sum] = "0647bc50c9a50aa247050975cf9345493419d17c6f0c2198099e487a443fa0e4"
SRC_URI[split_plugins_styles.md5sum] = "5200474f10033be0e64d04ebc42abfb6"
SRC_URI[split_plugins_styles.sha256sum] = "e78d9ac7f1aa83903ff3d871c2588f0b18b3851be45fae41350daf264c7e12a4"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty

branch_name: HEAD

extension: bb


text:
@article{kalzkompetenzentwicklung,
 author = {Kalz, Marco and Specht, Marcus and Klamma, Ralf and Chatti, Mohamed Amine and Koper, Rob},
 title = {Kompetenzentwicklung in Lernnetzwerken für das lebenslange Lernen Zusammenfassung}
}

repository: mkalz/mkalz-academic

repo_name: mkalz/mkalz-academic

extension: bib


text:
package generator

import (
	"context"
	"fmt"
	"math/rand"
	"time"
)

const maxWaitTimeSec = 3

type Service struct {
	label string
	logs  chan Message
}

type Message struct {
	Label   string
	Text    string
	EventAt time.Time
}

func New(label string) *Service {
	return &Service{
		label: label,
		logs:  make(chan Message, 1),
	}
}

func (svc *Service) GenerateLogs(ctx context.Context) error {
	for {
		secs := rand.Intn(maxWaitTimeSec)
		m := genMsg(time.Duration(secs) * time.Second)
		select {
		case <-ctx.Done():
			return ctx.Err()
		case svc.logs <- Message{
			Label:   svc.label,
			Text:    m,
			EventAt: time.Now().UTC(),
		}:
			println(svc.label, m)
		}
	}
}

func (svc *Service) Logs() chan Message {
	return svc.logs
}

func genMsg(waitTime time.Duration) string {
	time.Sleep(waitTime)
	return fmt.Sprintf("worker's wait time: %s", waitTime)
}

repository: GolubAlexander/grpc-logs

repo_name: GolubAlexander/grpc-logs


text:
// @author Robin Verlangen
// Discovery service used to detect cluster

package main

// Imports
import (
	"bytes"
	"crypto/hmac"
	"crypto/sha256"
	"encoding/hex"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"net"
	"net/http"
	"strconv"
	"strings"
	"sync"
	"time"
)

// Discovery constants
const PING_TIMEOUT = 10 * time.Second      // Timeout for a ping to a node
const PING_INTERVAL = 30 * time.Second     // Interval at which pings occur
const DISCONNECT_TIMEOUT = 1 * time.Minute // Beyond this period a node will not be replicated / shown as warning, pings will continue
const REMOVE_TIMEOUT = 30 * time.Minute    // Beyond this period a node will be removed from the disveroy list

// Node (entity in the Dispenso cluster)
type Node struct {
	DiscoveryService *DiscoveryService // Discovery service reference
	Host             string            // Fully qualified hostname
	Addr             string            // IP address of this node
	Port             int               // Port on which Dispenso runs
	InstanceId       string            // Instance id (unique per startup)
	IsSeed           bool              // Is this node a seed?

	// @todo Send meta data every once in a while
	metaReceived bool         // Did we receive metadata?
	mux          sync.RWMutex // Locking mechanism
	lastSeen     time.Time    // Time last seen
	connected    bool         // Is this node connected to the cluster?
}

// Full name
func (n *Node) FullName() string {
	return fmt.Sprintf("%s:%d", n.Host, n.Port)
}

// Full url
func (n *Node) FullUrl(service string) string {
	return fmt.Sprintf("http://%s/%s", n.FullName(), service)
}

// Redo metadata exchange
func (n *Node) ResetMetaExchanged() bool {
	n.mux.Lock()
	n.metaReceived = false
	n.mux.Unlock()
	return true
}

// Disconnect node
func (n *Node) Disconnect() bool {
	n.mux.Lock()
	n.connected = false
	n.mux.Unlock()
	log.Println(fmt.Sprintf("WARN: Disconnected %s"), n.FullName())
	return true
}

// Fetch node metadata
func (n *Node) FetchMeta() bool {
	// Fetch data
	var data map[string]string = getEmptyMetaMsg("fetch_meta")
	b := msgToJson(data)
	bodyStr, err := n.sendData("discovery", b)
	if err != nil {
		log.Println(fmt.Sprintf("ERR: Failed to request node metadata %s"), err)
		return false
	}
	body := []byte(bodyStr)

	// Parse json
	var f interface{}
	err = json.Unmarshal(body, &f)
	if err != nil {
		log.Println(fmt.Sprintf("ERR: Failed to parse node metadata %s"), err)
		return false
	}
	m := f.(map[string]interface{})
	log.Println(fmt.Sprintf("DEBUG: %s", m["time"]))

	// Meta received
	n.mux.Lock()
	n.metaReceived = true
	n.connected = true
	log.Println(fmt.Sprintf("INFO: Detected %s @ %s", n.FullName(), n.Addr))
	n.mux.Unlock()

	// Exchange meta
	n.ExchangeMeta()

	return true
}

// Get metadata basis
func getEmptyMetaMsg(t string) map[string]string {
	var data map[string]string = make(map[string]string)
	data["ts"] = fmt.Sprintf("%d", time.Now().UnixNano())
	data["msg_id"] = getUuid()
	data["type"] = t
	data["sender"] = hostname
	data["sender_port"] = fmt.Sprintf("%d", serverPort)
	return data
}

// Message to json
func msgToJson(data map[string]string) []byte {
	// To JSON
	b, err := json.Marshal(data)
	if err != nil {
		log.Println(fmt.Sprintf("ERR: Failed to format json"))
		return []byte("{}")
	}
	return b
}

// Notify leave
func (n *Node) NotifyLeave() bool {
	if debug {
		log.Println(fmt.Sprintf("DEBUG: Sending leave notification to %s", n.FullName()))
	}

	// Metadata
	var data map[string]string = getEmptyMetaMsg("node_leave")

	// Send data
	b := msgToJson(data)
	_, err := n.sendData("meta", b)
	if err != nil {
		return false
	}

	return true
}

// Exchange node metadata
func (n *Node) ExchangeMeta() bool {
	if debug {
		log.Println(fmt.Sprintf("DEBUG: Exchanging metadata with %s", n.FullName()))
	}

	// List nodes
	var nodeStrs []string = make([]string, 0)
	for _, node := range n.DiscoveryService.Nodes {
		if node == nil || len(node.Host) == 0 {
			continue
		}
		nodeStrs = append(nodeStrs, fmt.Sprintf("%s:%d", node.Host, node.Port))
	}

	// Assemble payload
	var data map[string]string = getEmptyMetaMsg("fetch_meta")
	data["nodes"] = strings.Join(nodeStrs, ",")
	b := msgToJson(data)

	// Send data
	_, err := n.sendData("discovery", b)
	if err != nil {
		return false
	}

	return true
}

// Send data
func (n *Node) sendData(endpoint string, b []byte) (string, error) {
	// Debug post
	if trace && b != nil && len(b) > 0 {
		log.Println(fmt.Sprintf("TRACE: Post data %s", b))
	}

	// Client
	httpclient := &http.Client{}

	// Calculate message digest
	mac := hmac.New(sha256.New, secretKey)
	mac.Write(b)
	signature := mac.Sum(nil)

	// Execute request
	req, reqErr := http.NewRequest("POST", n.FullUrl(endpoint), bytes.NewBufferString(fmt.Sprintf("%s", b)))
	req.Header.Set("User-Agent", "Dispenso")
	headerSig := fmt.Sprintf("sha256=%s", hex.EncodeToString(signature))
	req.Header.Set("X-Message-Digest", headerSig)
	if trace {
		log.Println(fmt.Sprintf("DEBUG: Message digest header: %s", headerSig))
	}
	if reqErr != nil {
		return "", newErr(fmt.Sprintf("Failed request: %s", reqErr))
	}

	// Parse response
	resp, respErr := httpclient.Do(req)
	if respErr != nil {
		return "", newErr(fmt.Sprintf("Failed request: %s", respErr))
	}
	if resp.Body != nil {
		defer resp.Body.Close()
	}

	// Read response
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "", newErr(fmt.Sprintf("Failed to read response: %s", err))
	}
	respStr := fmt.Sprintf("%s", body)

	// Debug response
	if trace {
		log.Println(fmt.Sprintf("TRACE: Response data %s", respStr))
	}
	return respStr, nil
}

// Ping a node
func (n *Node) Ping() bool {
	// Knock on the door
	conn, err := net.DialTimeout("tcp", n.FullName(), PING_TIMEOUT)
	if err != nil {
		return false
	}
	conn.Close()

	// Last seen
	n.mux.Lock()
	n.lastSeen = time.Now().UTC()
	n.mux.Unlock()

	// Try to fetch metadata
	n.mux.RLock()
	if n.metaReceived == false {
		go func() {
			n.FetchMeta()
		}()
	}
	n.mux.RUnlock()

	// Store last ping in cluster
	mutation := getEmptyMetaMsg("data_mutation")
	mutation["k"] = fmt.Sprintf("ping~%s", n.FullName())
	mutation["v"] = fmt.Sprintf("%d", n.lastSeen)
	n.sendData("data", msgToJson(mutation))

	// OK
	return true
}

// Message (payload transmitted between nodes containing instructions)
type Message struct {
	Type    MessageType // Type of message
	Payload string      // JSON payload
}

// Message types, enum-like datastructure, use "MessageType" as wrapper
type MessageType struct {
	code messageType
}
type messageType int

const (
	discoveryPing     messageType = iota + 1 // Initial discovery ping
	disocveryResponse                        // Discovery response
	discoveryMeta                            // Metadata beyond initial discovery
	configuration                            // Used to update configuration in the cluster
	taskRequest                              // New task submission
	taskApproval                             // Approve task
	taskReject                               // Reject task
	taskExecution                            // After being approved a task execution will be sent to the nodes
)

// Discovery service
type DiscoveryService struct {
	Nodes []*Node // List of nodes

	mux sync.RWMutex // Locking mechanism
}

// Create discovery service
func NewDiscoveryService() *DiscoveryService {
	return &DiscoveryService{}
}

// Create node
func (d *DiscoveryService) NewNode(host string, port int, addr string) *Node {
	return &Node{
		DiscoveryService: d,
		Host:             host,
		Port:             port,
		Addr:             addr,
	}
}

// Get seed nodes
func (d *DiscoveryService) GetLiveSeedNodes() []*Node {
	var list []*Node = make([]*Node, 0)
	// Iterate
	for _, node := range d.Nodes {
		// Skip ourselves in the replication process
		if node.Addr == ipAddr && node.Port == serverPort {
			if trace {
				log.Println(fmt.Sprintf("DEBUG: Ignore local seed %s:%d", ipAddr, serverPort))
			}
			continue
		}

		// Skip nodes that are not connected
		if node.connected == false {
			if trace {
				log.Println(fmt.Sprintf("DEBUG: Ignore local seed %s:%d as connection is lost", ipAddr, serverPort))
			}
			continue
		}

		list = append(list, node)
	}
	return list
}

// Add node
func (d *DiscoveryService) AddNode(n *Node) bool {
	// Ensure we have a host
	if len(n.Host) == 0 {
		return false
	}

	// Look for duplicates
	d.mux.RLock()
	for _, node := range d.Nodes {
		if (node.Host == n.Host && node.Port == n.Port) || (node.Addr == n.Addr && node.Port == n.Port) {
			// Match found
			d.mux.RUnlock()
			return false
		}
	}
	d.mux.RUnlock()

	// Append
	d.mux.Lock()
	d.Nodes = append(d.Nodes, n)
	d.mux.Unlock()
	return true
}

// Find node (based on human input)
func (d *DiscoveryService) FindNode(input string) *Node {
	// Validate non-empty
	input = strings.TrimSpace(input)
	if len(input) == 0 {
		return nil
	}

	// Split input on colon (are we looking for a specific port maybe?)
	inputSplit := strings.Split(input, ":")
	var port int = defaultPort
	if len(inputSplit) == 2 {
		var err error
		port, err = strconv.Atoi(inputSplit[1])
		if err != nil {
			port = defaultPort
		}
	}
	if debug {
		log.Println(fmt.Sprintf("DEBUG: Finding node with ip/host %s on port %d", inputSplit[0], port))
	}

	// Iterate nodes
	for _, node := range d.Nodes {
		// Check hostname/ip
		if node.Addr != inputSplit[0] && node.Host != inputSplit[0] {
			continue
		}
		// Check port
		if node.Port != port {
			continue
		}
		// Found match
		return node
	}

	// @todo
	return nil
}

// Remove node
func (d *DiscoveryService) RemoveNode(n *Node) bool {
	var i int = -1
	for in, node := range d.Nodes {
		if node == n {
			i = in
			break
		}
	}

	// Found?
	if i == -1 {
		log.Println(fmt.Sprintf("ERROR: Failed to remove host %s", n.FullName()))
		return false
	}

	// Remove
	d.mux.Lock()
	d.Nodes[i] = d.Nodes[len(d.Nodes)-1]
	d.Nodes = d.Nodes[0 : len(d.Nodes)-1]
	log.Println(fmt.Sprintf("INFO: Removed host %s", n.FullName()))
	d.mux.Unlock()

	return true
}

// Set seeds
func (d *DiscoveryService) SetSeeds(seeds []string) error {
	// Add all seeds
	for _, seed := range seeds {
		// Simple seed validation
		split := strings.Split(seed, ":")
		var port int = defaultPort
		if len(split) > 2 {
			log.Println(fmt.Sprintf("ERROR: Seed %s host:port format invalid", seed))
			continue
		} else if len(split) == 1 {
			// Default port
			if split[0] == hostname {
				// Localhost, use port defined
				port = serverPort
			}
		} else {
			// User port
			var err error
			port, err = strconv.Atoi(split[1])
			if err != nil {
				log.Println(fmt.Sprintf("ERROR: Seed %s port format invalid", seed))
				continue
			}
		}

		// Add node
		n := d.NewNode(split[0], port, getPulicIp(split[0]))
		n.IsSeed = true
		d.AddNode(n)
	}
	return nil
}

// Notify cluster of new node
func (d *DiscoveryService) NotifyJoin() bool {
	for _, node := range d.Nodes {
		if !node.ExchangeMeta() {
			// @todo Keep track of errors and add exponential backoff
			log.Println(fmt.Sprintf("WARN: Failed to exchange metadata %s", node.FullName()))
		}
	}
	return true
}

// Notify leave
func (d *DiscoveryService) NotifyLeave() bool {
	for _, node := range d.Nodes {
		if !node.NotifyLeave() {
			// @todo Keep track of errors and add exponential backoff
			log.Println(fmt.Sprintf("WARN: Failed to notify leave metadata %s", node.FullName()))
		}
	}
	return true
}

// Ping nodes
func (d *DiscoveryService) PingNodes() bool {
	for _, node := range d.Nodes {
		if !node.Ping() {
			// @todo Keep track of errors and add exponential backoff
			node.ResetMetaExchanged()
			if time.Since(node.lastSeen) < DISCONNECT_TIMEOUT {
				log.Println(fmt.Sprintf("WARN: Failed to detect %s", node.FullName()))
			} else {
				// Disconnect
				node.mux.RLock()
				if node.connected {
					node.Disconnect()
				}
				node.mux.RUnlock()
			}
		}
	}
	return true
}

// Run discovery service
func (d *DiscoveryService) Start() bool {
	go func() {
		log.Println("INFO: Starting discovery")

		// Iterate nodes
		ticker := time.NewTicker(PING_INTERVAL)
		d.PingNodes()
		for {
			select {
			case <-ticker.C:
				// Discover nodes
				d.PingNodes()
			case <-shutdown:
				ticker.Stop()
				return
			}
		}

		// @todo Run every once in a while, and remove shutdown

		//shutdown <- true
	}()
	return true
}

repository: BartoszK/indispenso

repo_name: BartoszK/indispenso


text:
#include "GenScene.h"

#include <Engine/Engine.h>

#include <Basic/Image.h>
#include <Basic/Math.h>
#include <Basic/ShapeMesh/CubeMesh.h>

#include <ROOT_PATH.h>

using namespace Ubpa;

using namespace std;

Ptr<SObj> GenBox() {
	auto sobj_Box = SObj::New(nullptr, "Cornell Box");

	// wall
	const int wallNum = 5;
	Ptr<SObj> sobj_walls[wallNum] = {
		SObj::New(sobj_Box, "wall ceil"),
		SObj::New(sobj_Box, "wall down"),
		SObj::New(sobj_Box, "wall left"),
		SObj::New(sobj_Box, "wall right"),
		SObj::New(sobj_Box, "wall back")
	};

	Ubpa::pointf3 posArr[wallNum] = {
		Ubpa::pointf3(0, 1.5f, 0),
		Ubpa::pointf3(0, 0, 0),
		Ubpa::pointf3(-1, 0.75f, 0),
		Ubpa::pointf3(1, 0.75f, 0),
		Ubpa::pointf3(0, 0.75f, -1),
	};

	Ubpa::vecf3 axisArr[wallNum] = {
		Ubpa::vecf3(0, 0, 1),
		Ubpa::vecf3(0, 1, 0),
		Ubpa::vecf3(0, 0, 1),
		Ubpa::vecf3(0, 0, 1),
		Ubpa::vecf3(1, 0, 0),
	};

	float degreeArr[wallNum] = {
		180,
		0,
		-90,
		90,
		90,
	};

	Ubpa::scalef3 scaleArr[wallNum] = {
		Ubpa::scalef3(2, 1, 2),
		Ubpa::scalef3(2, 1, 2),
		Ubpa::scalef3(1.5f, 1, 2),
		Ubpa::scalef3(1.5f, 1, 2),
		Ubpa::scalef3(2, 1, 1.5f),
	};

	Ubpa::rgbf colorArr[wallNum] = {
		Ubpa::rgbf(0.6f),
		Ubpa::rgbf(0.6f),
		Ubpa::rgbf(0.6f, 0.2f, 0.2f),
		Ubpa::rgbf(0.2f, 0.2f, 0.6f),
		Ubpa::rgbf(0.6f),
	};

	for (int i = 0; i < wallNum; i++) {
		auto bsdfDiffuse = BSDF_Diffuse::New(colorArr[i]);
		auto materialDiffuse = CmptMaterial::New(sobj_walls[i], bsdfDiffuse);

		auto plane = Plane::New();
		auto geo = CmptGeometry::New(sobj_walls[i], plane);

		auto transform = CmptTransform::New(sobj_walls[i]);
		transform->SetPosition(posArr[i]);
		transform->SetRotation(axisArr[i], degreeArr[i]);
		transform->SetScale(scaleArr[i]);
	}

	// light
	auto sobj_AreaLight = SObj::New(sobj_Box, "area light");
	auto areaLight = AreaLight::New(Ubpa::rgbf(1.f), 15, 0.8f, 0.6f);
	auto light = CmptLight::New(sobj_AreaLight, areaLight);
	auto lightTransform = CmptTransform::New(sobj_AreaLight);
	lightTransform->SetPosition(Ubpa::pointf3(0, 1.49f, 0));
	lightTransform->SetScale(Ubpa::scalef3(0.8f, 1.0f, 0.6f));
	auto lightPlane = Plane::New();
	auto lightGeo = CmptGeometry::New(sobj_AreaLight, lightPlane);
	auto bsdfEmission = BSDF_Emission::New(Ubpa::rgbf(2.f));
	auto materailEmission = CmptMaterial::New(sobj_AreaLight, bsdfEmission);

	return sobj_Box;
}

Ptr<SObj> GenGound() {
	auto sobj_ground = SObj::New(nullptr, "ground");
	auto material = CmptMaterial::New(sobj_ground, BSDF_Diffuse::New());
	auto plane = CmptGeometry::New(sobj_ground, Plane::New());
	auto transform = CmptTransform::New(sobj_ground);
	transform->SetScale(Ubpa::scalef3(100, 1, 100));
	return sobj_ground;
}

Ptr<Scene> GenScene00() {
	auto sobj_Root = SObj::New(nullptr, "root");
	auto sobj_Camera = SObj::New(sobj_Root, "camera");
	auto sobj_MirrorSphere = SObj::New(sobj_Root, "mirror sphere");
	auto sobj_GlassSphere = SObj::New(sobj_Root, "glass sphere");
	auto sobj_AreaLight = SObj::New(sobj_Root, "area light");
	const int wallNum = 5;
	Ptr<SObj> sobj_walls[wallNum] = {
		SObj::New(sobj_Root, "wall ceil"),
		SObj::New(sobj_Root, "wall down"),
		SObj::New(sobj_Root, "wall left"),
		SObj::New(sobj_Root, "wall right"),
		SObj::New(sobj_Root, "wall back")
	};

	// camera
	auto camera = CmptCamera::New(sobj_Camera, 50.0f);
	auto cameraTransform = CmptTransform::New(sobj_Camera);
	cameraTransform->SetPosition(Ubpa::pointf3(0, 0.75f, 2.4f));

	// light
	auto areaLight = AreaLight::New(Ubpa::rgbf(1.f), 15, 0.8f, 0.6f);
	auto light = CmptLight::New(sobj_AreaLight, areaLight);
	auto lightTransform = CmptTransform::New(sobj_AreaLight);
	lightTransform->SetPosition(Ubpa::pointf3(0, 1.49f, 0));
	lightTransform->SetScale(Ubpa::scalef3(0.8f, 1.0f, 0.6f));
	auto lightPlane = Plane::New();
	auto lightGeo = CmptGeometry::New(sobj_AreaLight, lightPlane);
	auto bsdfEmission = BSDF_Emission::New(Ubpa::rgbf(2.f));
	auto materailEmission = CmptMaterial::New(sobj_AreaLight, bsdfEmission);

	// mirror sphere
	auto bsdfMirror = BSDF_Mirror::New();
	auto materialMirror = CmptMaterial::New(sobj_MirrorSphere, bsdfMirror);

	auto mirrorSphereTransform = CmptTransform::New(sobj_MirrorSphere);
	mirrorSphereTransform->SetPosition(Ubpa::pointf3(-0.4f, 0.3f, -0.3f));
	mirrorSphereTransform->SetScale(Ubpa::scalef3(0.3f));

	auto geoMetalSphere = CmptGeometry::New(sobj_MirrorSphere, Sphere::New());

	// glass sphere
	auto bsdfGlass = BSDF_Glass::New(1.45f);
	auto materialGlass = CmptMaterial::New(sobj_GlassSphere, bsdfGlass);

	auto glassSphereTransform = CmptTransform::New(sobj_GlassSphere);
	glassSphereTransform->SetPosition(Ubpa::pointf3(0.4f, 0.3f, 0.3f));
	glassSphereTransform->SetScale(Ubpa::scalef3(0.3f));

	auto geoGlassSphere = CmptGeometry::New(sobj_GlassSphere, Sphere::New());

	// mesh . cube
	auto sobj_Cube = SObj::New(sobj_Root, "cube");
	CubeMesh cube;
	auto cubeMesh = TriMesh::New(cube.GetTriNum(), cube.GetVertexNum(),
		cube.GetIndexArr(), cube.GetPosArr(), cube.GetNormalArr(), cube.GetTexCoordsArr());
	auto cubeG = CmptGeometry::New(sobj_Cube, cubeMesh);
	auto blueGlass = BSDF_Glass::New(1.5f, Ubpa::rgbf(0.f, 0.794f, 0.916f));
	auto materialCube = CmptMaterial::New(sobj_Cube, blueGlass);
	auto cubeTransform = CmptTransform::New(sobj_Cube);
	cubeTransform->SetScale(Ubpa::scalef3(0.2f));
	cubeTransform->SetPosition(Ubpa::pointf3(0, 0.15f, 0));

	sobj_Root->AddChild(GenBox());

	auto scene = Scene::New(sobj_Root, "scene 00");
	return scene;
}

Ptr<Scene> GenScene01() {
	auto sobjRoot = SObj::New(nullptr, "root");
	auto sobj0 = SObj::New(sobjRoot, "sobj0");
	auto sobj1 = SObj::New(sobjRoot, "sobj1");

	auto camera = CmptCamera::New(sobjRoot);

	auto sphere0Transform = CmptTransform::New(sobj0, Ubpa::pointf3(0,0,-2), Ubpa::scalef3(0.5f));
	auto sphere0 = Sphere::New();
	auto sphere1Transform = CmptTransform::New(sobj0, Ubpa::pointf3(0, -100, -2), Ubpa::scalef3(99.5f));
	auto sphere1 = Sphere::New();

	auto g0 = CmptGeometry::New(sobj0, sphere0);
	auto g1 = CmptGeometry::New(sobj1, sphere1);

	auto pink = BSDF_Diffuse::New(Ubpa::rgbf(1.0f, 0.686f, 0.788f));
	auto gray = BSDF_Diffuse::New(Ubpa::rgbf(0.8f));

	auto material0 = CmptMaterial::New(sobj0, pink);
	auto material1 = CmptMaterial::New(sobj1, gray);

	auto scene = Scene::New(sobjRoot, "scene 01");
	return scene;
}

Ptr<Scene> GenScene02() {
	auto sobjRoot = SObj::New(nullptr, "root");
	auto sobj0 = SObj::New(sobjRoot, "sobj0");
	auto sobj1 = SObj::New(sobjRoot, "sobj1");

	auto camera = CmptCamera::New(sobjRoot);

	auto sphere0Transform = CmptTransform::New(sobj0, Ubpa::pointf3(0, 0, -2), Ubpa::scalef3(0.5f));
	auto sphere0 = Sphere::New();
	auto sphere1Transform = CmptTransform::New(sobj0, Ubpa::pointf3(0, -100, -2), Ubpa::scalef3(99.5f));
	auto sphere1 = Sphere::New();

	auto g0 = CmptGeometry::New(sobj0, sphere0);
	auto g1 = CmptGeometry::New(sobj1, sphere1);

	auto white = BSDF_Mirror::New(Ubpa::rgbf(1.0f));
	auto pink = BSDF_Diffuse::New(Ubpa::rgbf(1.0f, 0.686f, 0.788f));

	auto material0 = CmptMaterial::New(sobj0, white);
	auto material1 = CmptMaterial::New(sobj1, pink);

	auto scene = Scene::New(sobjRoot, "scene 02");
	return scene;
}

Ptr<Scene> GenScene03(){
	auto sobjRoot = SObj::New(nullptr, "root");
	auto sobj0 = SObj::New(sobjRoot, "sobj0");
	auto sobj1 = SObj::New(sobjRoot, "sobj1");

	auto camera = CmptCamera::New(sobjRoot);

	auto sphere0Transform = CmptTransform::New(sobj0, Ubpa::pointf3(0, 0, -2), Ubpa::scalef3(0.5f));
	auto sphere0 = Sphere::New();
	auto sphere1Transform = CmptTransform::New(sobj0, Ubpa::pointf3(0, -100, -2), Ubpa::scalef3(99.5f));
	auto sphere1 = Sphere::New();

	auto g0 = CmptGeometry::New(sobj0, sphere0);
	auto g1 = CmptGeometry::New(sobj1, sphere1);

	auto glass = BSDF_Glass::New(1.5f);
	auto pink = BSDF_Diffuse::New(Ubpa::rgbf(1.0f, 0.686f, 0.788f));

	auto material0 = CmptMaterial::New(sobj0, glass);
	auto material1 = CmptMaterial::New(sobj1, pink);

	auto scene = Scene::New(sobjRoot, "scene 03");
	return scene;
}

Ptr<Scene> GenScene04() {
	auto sobjRoot = SObj::New(nullptr, "root");
	auto sobj_camera = SObj::New(sobjRoot, "camera");
	auto sobj_sphere = SObj::New(sobjRoot, "sobj_sphere");
	auto sobj_ground = SObj::New(sobjRoot, "sobj_ground");

	auto cameraTransform = CmptTransform::New(sobj_camera);
	cameraTransform->SetPosition(Ubpa::pointf3(0, 0, 3));
	auto camera = CmptCamera::New(sobj_camera);

	auto sphere0Transform = CmptTransform::New(sobj_sphere, Ubpa::pointf3(0, 0, 0), Ubpa::scalef3(1, 0.5,0.5), Ubpa::vecf3(0,1,0), Ubpa::to_radian(45.f));
	auto sphere0 = Sphere::New();
	auto sphere1Transform = CmptTransform::New(sobj_ground, Ubpa::pointf3(0, -100, 0), Ubpa::scalef3(99.5f));
	auto sphere1 = Sphere::New();

	auto g0 = CmptGeometry::New(sobj_sphere, sphere0);
	auto g1 = CmptGeometry::New(sobj_ground, sphere1);

	auto glass = BSDF_Glass::New(1.2f);
	auto pink = BSDF_Diffuse::New(Ubpa::rgbf(1.0f, 0.686f, 0.788f));

	auto material0 = CmptMaterial::New(sobj_sphere, glass);
	auto material1 = CmptMaterial::New(sobj_ground, pink);

	auto scene = Scene::New(sobjRoot, "scene 04");
	return scene;
}

Ptr<Scene> GenScene05() {
	auto sobjRoot = SObj::New(nullptr, "root");
	auto sobj_camera = SObj::New(sobjRoot, "camera");
	auto sobj_sphere = SObj::New(sobjRoot, "sobj_sphere");
	auto sobj_ground = SObj::New(sobjRoot, "sobj_ground");

	auto cameraTransform = CmptTransform::New(sobj_camera);
	cameraTransform->SetPosition(Ubpa::pointf3(0, 0.1f, 3));
	auto camera = CmptCamera::New(sobj_camera);

	auto sphereTransform = CmptTransform::New(sobj_sphere, Ubpa::pointf3(0, 0, -2), Ubpa::scalef3(0.5f), Ubpa::vecf3(0,1,0), Ubpa::to_radian(30.f));
	auto sphere = Sphere::New();
	auto plane = Plane::New();

	auto planeTransform = CmptTransform::New(sobj_ground);
	planeTransform->SetScale(Ubpa::scalef3(10.0f, 1.f, 10.0f));

	auto g0 = CmptGeometry::New(sobj_sphere, sphere);
	auto g1 = CmptGeometry::New(sobj_ground, plane);

	auto glass = BSDF_Glass::New(1.2f);
	auto pink = BSDF_Diffuse::New(Ubpa::rgbf(1.0f, 0.686f, 0.788f));

	auto material0 = CmptMaterial::New(sobj_sphere, glass);
	auto material1 = CmptMaterial::New(sobj_ground, pink);

	auto scene = Scene::New(sobjRoot, "scene05");
	return scene;
}

Ptr<Scene> GenScene06() {
	auto sobjRoot = SObj::New(nullptr, "root");
	auto sobj_camera = SObj::New(sobjRoot, "camera");
	auto sobj_skySphere = SObj::New(sobjRoot, "sobj_skySphere");
	auto sobj_sphere = SObj::New(sobjRoot, "sobj_sphere");
	auto sobj_light = SObj::New(sobjRoot, "sobj_light");
	auto sobj_ground = SObj::New(sobjRoot, "sobj_ground");

	auto cameraTransform = CmptTransform::New(sobj_camera);
	cameraTransform->SetPosition(Ubpa::pointf3(0, 0.5f, 3));
	auto camera = CmptCamera::New(sobj_camera);

	auto skySphereTransform = CmptTransform::New(sobj_sphere, Ubpa::pointf3(0.f), Ubpa::scalef3(4.f));
	auto skySphere = Sphere::New();
	auto sphereTransform = CmptTransform::New(sobj_sphere, Ubpa::pointf3(0.f), Ubpa::scalef3(0.5f));
	auto sphere = Sphere::New();
	auto plane = Plane::New();
	auto lightPlane = Plane::New();
	auto areaLight = AreaLight::New(Ubpa::rgbf(1.f), 10);

	auto planeTransform = CmptTransform::New(sobj_ground);
	planeTransform->SetScale(Ubpa::scalef3(100.0f, 1.f, 100.0f));
	planeTransform->SetPosition(Ubpa::pointf3(0, -1, 0));

	auto lightTransform = CmptTransform::New(sobj_light);
	lightTransform->SetPosition(Ubpa::pointf3(0, 2.f, 0));

	auto light = CmptLight::New(sobj_light, areaLight);

	auto g0 = CmptGeometry::New(sobj_skySphere, skySphere);
	auto g1 = CmptGeometry::New(sobj_ground, plane);
	auto g2 = CmptGeometry::New(sobj_sphere, sphere);
	auto g3 = CmptGeometry::New(sobj_light, lightPlane);

	auto sky = BSDF_Diffuse::New(Ubpa::rgbf(0.f));
	auto glass = BSDF_Glass::New(1.5f);
	auto pink = BSDF_Diffuse::New(Ubpa::rgbf(1.0f, 0.686f, 0.788f));
	auto emission = BSDF_Emission::New(Ubpa::rgbf(1.f));

	auto material0 = CmptMaterial::New(sobj_skySphere, sky);
	auto material1 = CmptMaterial::New(sobj_ground, pink);
	auto material2 = CmptMaterial::New(sobj_sphere, glass);
	auto material3 = CmptMaterial::New(sobj_light, emission);

	auto scene = Scene::New(sobjRoot, "scene 06");
	return scene;
}

Ptr<Scene> GenScene07() {
	auto sobjRoot = SObj::New(nullptr, "root");

	auto sobj_Camera = SObj::New(sobjRoot, "camera");
	auto camera = CmptCamera::New(sobj_Camera, 20.0f);
	auto cameraTransform = CmptTransform::New(sobj_Camera);
	cameraTransform->look_at(Ubpa::pointf3(13, 2, 3), Ubpa::pointf3(0.f));

	auto balls = SObj::New(sobjRoot, "balls");
	for (int a = -11, id = 0; a < 11; a++) {
		for (int b = -11; b < 11; b++, id++) {
			auto ball = SObj::New(balls, "ball " + to_string(id));
			Ubpa::pointf3 center(a + 0.9*Math::Rand_F(), 0.2, b + 0.9*Math::Rand_F());
			CmptTransform::New(ball, center, Ubpa::scalef3(0.2f));

			CmptGeometry::New(ball, Sphere::New());

			Ptr<BSDF> bsdf;
			float choose_mat = Math::Rand_F();
			if (choose_mat < 0.8) {  // diffuse
				Ubpa::rgbf color(Math::Rand_F()*Math::Rand_F(), Math::Rand_F()*Math::Rand_F(), Math::Rand_F()*Math::Rand_F());
				bsdf = BSDF_Diffuse::New(color);
			}
			else if (choose_mat < 0.95) { // metal
				Ubpa::rgbf color(0.5f*(1 + Math::Rand_F()), 0.5f*(1 + Math::Rand_F()), 0.5f*(1 + Math::Rand_F()));
				bsdf = BSDF_Mirror::New(color);
			}
			else {  // glass
				bsdf = BSDF_Glass::New(1.2f + Math::Rand_F()*0.5f);
			}

			CmptMaterial::New(ball, bsdf);
		}
	}

	Ubpa::pointf3 center[6] = {
		Ubpa::pointf3(0, -1000, 0),
		Ubpa::pointf3(6, 1, 0),
		Ubpa::pointf3(2, 1, 0),
		Ubpa::pointf3(2, 1, 0),
		Ubpa::pointf3(-2, 1, 0),
		Ubpa::pointf3(-6, 1, 0),
	};
	float radius[6] = { 1000.f,1.f,1.f,-0.8f,1.f,1.f };
	Ptr<BSDF> bsdf[6] = {
		BSDF_Diffuse::New(Ubpa::rgbf(0.5f)),
		BSDF_Mirror::New(Ubpa::rgbf(0.7f, 0.6f, 0.5f)),
		BSDF_Glass::New(1.5f),
		BSDF_Glass::New(1.5f),
		BSDF_Diffuse::New(Ubpa::rgbf(0.4f,0.2f,0.1f)),
		BSDF_Glass::New(2.5f),
	};
	for (int i = 0; i < 6; i++) {
		auto sobj = SObj::New(sobjRoot, "sphere" + to_string(i));
		CmptTransform::New(sobj, center[i], Ubpa::scalef3(radius[i]));
		CmptGeometry::New(sobj, Sphere::New());
		CmptMaterial::New(sobj, bsdf[i]);
	}

	return Scene::New(sobjRoot, "scene 07");
}

Ptr<Scene> GenScene08() {
	auto sobj_Root = SObj::New(nullptr, "root");

	// camera
	auto sobj_Camera = SObj::New(sobj_Root, "camera");
	auto camera = CmptCamera::New(sobj_Camera, 50.0f);
	auto cameraTransform = CmptTransform::New(sobj_Camera);
	cameraTransform->SetPosition(Ubpa::pointf3(0, 0.75f, 2.4f));

	// light
	auto sobj_AreaLight = SObj::New(sobj_Root, "area light");
	auto areaLight = AreaLight::New(Ubpa::rgbf(1.f), 15, 0.8f, 0.6f);
	auto light = CmptLight::New(sobj_AreaLight, areaLight);
	auto lightTransform = CmptTransform::New(sobj_AreaLight);
	lightTransform->SetPosition(Ubpa::pointf3(0, 1.49f, 0));
	lightTransform->SetScale(Ubpa::scalef3(0.8f, 1.0f, 0.6f));
	auto lightPlane = Plane::New();
	auto lightGeo = CmptGeometry::New(sobj_AreaLight, lightPlane);
	auto bsdfEmission = BSDF_Emission::New(Ubpa::rgbf(2.f));
	auto materailEmission = CmptMaterial::New(sobj_AreaLight, bsdfEmission);

	// wall

	const int wallNum = 5;
	Ptr<SObj> sobj_walls[wallNum] = {
		SObj::New(sobj_Root, "wall ceil"),
		SObj::New(sobj_Root, "wall down"),
		SObj::New(sobj_Root, "wall left"),
		SObj::New(sobj_Root, "wall right"),
		SObj::New(sobj_Root, "wall back")
	};

	Ubpa::pointf3 posArr[wallNum] = {
		Ubpa::pointf3(0, 1.5f, 0),
		Ubpa::pointf3(0, 0, 0),
		Ubpa::pointf3(-1, 0.75f, 0),
		Ubpa::pointf3(1, 0.75f, 0),
		Ubpa::pointf3(0, 0.75f, -1),
	};

	Ubpa::vecf3 axisArr[wallNum] = {
		Ubpa::vecf3(0, 1, 0),
		Ubpa::vecf3(0, 1, 0),
		Ubpa::vecf3(0, 0, 1),
		Ubpa::vecf3(0, 0, 1),
		Ubpa::vecf3(1, 0, 0),
	};

	float degreeArr[wallNum] = {
		0,
		0,
		90,
		90,
		90,
	};

	Ubpa::scalef3 scaleArr[wallNum] = {
		Ubpa::scalef3(2, 1, 2),
		Ubpa::scalef3(2, 1, 2),
		Ubpa::scalef3(1.5f, 1, 2),
		Ubpa::scalef3(1.5f, 1, 2),
		Ubpa::scalef3(2, 1, 1.5f),
	};

	Ubpa::rgbf colorArr[wallNum] = {
		Ubpa::rgbf(0.6f),
		Ubpa::rgbf(0.6f),
		Ubpa::rgbf(0.6f, 0.2f, 0.2f),
		Ubpa::rgbf(0.2f, 0.2f, 0.6f),
		Ubpa::rgbf(0.6f),
	};

	for (int i = 0; i < wallNum; i++) {
		auto bsdfDiffuse = BSDF_Diffuse::New(colorArr[i]);
		auto materialDiffuse = CmptMaterial::New(sobj_walls[i], bsdfDiffuse);

		auto plane = Plane::New();
		auto geo = CmptGeometry::New(sobj_walls[i], plane);

		auto transform = CmptTransform::New(sobj_walls[i], posArr[i], scaleArr[i], axisArr[i], Ubpa::to_radian(degreeArr[i]));
	}

	// cook torrance sphere
	auto sobj_CTSphere = SObj::New(sobj_Root, "cook torrance sphere");

	auto bsdfCookTorrance = BSDF_CookTorrance::New(10.f, 0.4f, Ubpa::rgbf(0.1f), Ubpa::rgbf(1.0f,0.3f,0.5f));
	auto materialCookTorrance = CmptMaterial::New(sobj_CTSphere, bsdfCookTorrance);

	auto CTSphereTransform = CmptTransform::New(sobj_CTSphere);
	CTSphereTransform->SetPosition(Ubpa::pointf3(0, 0.3f, 0));
	CTSphereTransform->SetScale(Ubpa::scalef3(0.3f));

	auto geoCTSphere = CmptGeometry::New(sobj_CTSphere, Sphere::New());

	// sky sphere
	auto sobj_skySphere = SObj::New(sobj_Root, "sky");
	auto skyTsfm = CmptTransform::New(sobj_skySphere, Ubpa::pointf3(0.f), Ubpa::scalef3(100.f));
	auto geoSky = CmptGeometry::New(sobj_skySphere, Sphere::New());
	auto dark = BSDF_Diffuse::New(Ubpa::rgbf(0.f));
	auto materialSky = CmptMaterial::New(sobj_skySphere, dark);

	return Scene::New(sobj_Root, "scene 08");
}

Ptr<Scene> GenScene09() {
	auto sobj_Root = SObj::New(nullptr, "root");

	// metal workflow sphere
	auto sobj_MWSphere = SObj::New(sobj_Root, "metal workflow sphere");

	Ubpa::rgbf gold(1.00, 0.71, 0.29);
	auto bsdfGold = BSDF_MetalWorkflow::New(gold, 0.2f);
	auto materialGold = CmptMaterial::New(sobj_MWSphere, bsdfGold);

	auto MWSphereTransform = CmptTransform::New(sobj_MWSphere);
	MWSphereTransform->SetPosition(Ubpa::pointf3(0, 0.3f, 0));
	MWSphereTransform->SetScale(Ubpa::scalef3(0.3f));

	auto geoMWSphere = CmptGeometry::New(sobj_MWSphere, Sphere::New());

	// cornell box
	auto box = GenBox();
	auto boxTransform = CmptTransform::New(box);
	sobj_Root->AddChild(box);

	// ground
	//auto ground = GenGound();
	//ground->SetParent(sobj_Root);

	// plane

	// camera
	auto sobj_Camera = SObj::New(sobj_Root, "camera");
	auto camera = CmptCamera::New(sobj_Camera, 50.0f);
	auto cameraTransform = CmptTransform::New(sobj_Camera);
	cameraTransform->SetPosition(Ubpa::pointf3(0, 0.75f, 2.4f));

	// sky sphere
	auto sobj_skySphere = SObj::New(sobj_Root, "sky");
	auto skyTsfm = CmptTransform::New(sobj_skySphere, Ubpa::pointf3(0.f), Ubpa::scalef3(100.f));
	auto geoSky = CmptGeometry::New(sobj_skySphere, Sphere::New());
	auto dark = BSDF_Diffuse::New(Ubpa::rgbf(0.f));
	auto materialSky = CmptMaterial::New(sobj_skySphere, dark);

	return Scene::New(sobj_Root, "scene 09");
}

Ptr<Scene> GenScene10() {
	auto sobj_Root = SObj::New(nullptr, "root");

	// rusted iron workflow sphere
	auto sobj_IronSphere = SObj::New(sobj_Root, "rusted iron sphere");

	auto bsdfIron = BSDF_MetalWorkflow::New(Ubpa::rgbf(1.f));
	bsdfIron->albedoTexture = Image::New((ROOT_PATH+"data/textures/pbr/rusted_iron/albedo.png").c_str());
	bsdfIron->metallicTexture = Image::New((ROOT_PATH + "data/textures/pbr/rusted_iron/metallic.png").c_str());
	bsdfIron->roughnessTexture = Image::New((ROOT_PATH + "data/textures/pbr/rusted_iron/roughness.png").c_str());
	bsdfIron->aoTexture = Image::New((ROOT_PATH + "data/textures/pbr/rusted_iron/ao.png").c_str());
	bsdfIron->normalTexture = Image::New((ROOT_PATH + "data/textures/pbr/rusted_iron/normal.png").c_str());
	auto materialIron = CmptMaterial::New(sobj_IronSphere, bsdfIron);

	auto MWSphereTransform = CmptTransform::New(sobj_IronSphere, Ubpa::pointf3(0, 0.3f, 0), Ubpa::scalef3(0.3f));
	MWSphereTransform->Rotate(Ubpa::vecf3(0, 1, 0), 90.f);
	MWSphereTransform->Rotate(Ubpa::vecf3(1, 0, 0), 180.f);

	auto geoMWSphere = CmptGeometry::New(sobj_IronSphere, Sphere::New());

	// cornell box
	auto box = GenBox();
	auto boxTransform = CmptTransform::New(box);
	sobj_Root->AddChild(box);

	// ground
	//auto ground = GenGound();
	//ground->SetParent(sobj_Root);

	// plane

	// camera
	auto sobj_Camera = SObj::New(sobj_Root, "camera");
	auto camera = CmptCamera::New(sobj_Camera, 50.0f);
	auto cameraTransform = CmptTransform::New(sobj_Camera, Ubpa::pointf3(0, 0.5f, 0.8f));
	cameraTransform->SetPosition(Ubpa::pointf3(0, 0.5f, 0.8f));
	cameraTransform->Rotate(Ubpa::vecf3(1, 0, 0), -15.f);

	// sky sphere
	auto sobj_skySphere = SObj::New(sobj_Root, "sky");
	auto skyTsfm = CmptTransform::New(sobj_skySphere, Ubpa::pointf3(0.f), Ubpa::scalef3(100.f));
	auto geoSky = CmptGeometry::New(sobj_skySphere, Sphere::New());
	auto dark = BSDF_Diffuse::New(Ubpa::rgbf(0.f));
	auto materialSky = CmptMaterial::New(sobj_skySphere, dark);

	return Scene::New(sobj_Root, "scene 10");
}

Ptr<Scene> GenScene11() {
	auto sobjRoot = SObj::New(nullptr, "root");
	vector<Ubpa::pointf3> positions = {
		Ubpa::pointf3(0, 0, 0), // v0
		Ubpa::pointf3(0, 0, 1), // v1
		Ubpa::pointf3(1, 0, 1), // v2
		Ubpa::pointf3(1, 0, 0), // v3
		Ubpa::pointf3(0, 1, 0), // v4
		Ubpa::pointf3(0, 1, 1), // v5
		Ubpa::pointf3(1, 1, 1), // v6
		Ubpa::pointf3(1, 1, 0), // v7
	};
	vector<unsigned> indice = {
		0, 2, 1,
		0, 3, 2,

		0, 5, 4,
		0, 1, 5,

		1, 6, 5,
		1, 2, 6,

		2, 7, 6,
		2, 3, 7,

		3, 4, 7,
		3, 0, 4,

		4, 6, 7,
		4, 5, 6
	};

	auto meshObj = SObj::New(sobjRoot, "mesh");
	auto mesh = TriMesh::New(indice, positions);
	meshObj->AddComponent<CmptGeometry>(mesh);
	meshObj->AddComponent<CmptTransform>();
	meshObj->AddComponent<CmptMaterial>(BSDF_Frostbite::New());

	auto lightObj = SObj::New(sobjRoot, "light");
	lightObj->AddComponent<CmptLight>(InfiniteAreaLight::New(Image::New(ROOT_PATH+"data/textures/newport_loft.hdr")));
	auto ball = SObj::Load(ROOT_PATH + "data/objects/Balls.obj");
	if(ball)
		sobjRoot->AddChild(ball);
	else {
		cout << "WARNING::GenScene11:" << endl
			<< "\t" << "load fail: data/objects/Balls.obj" << endl;
	}

	return Scene::New(sobjRoot);
}

Ptr<Scene> Ubpa::GenScene(int n) {
	const int num = 12;
	Ptr<Scene>(*f[num])() = {
		&GenScene00,
		&GenScene01,
		&GenScene02,
		&GenScene03,
		&GenScene04,
		&GenScene05,
		&GenScene06,
		&GenScene07,
		&GenScene08,
		&GenScene09,
		&GenScene10,
		&GenScene11,
	};

	if (n < num)
		return f[n]();
	else
		return nullptr;
}

repository: Ubpa/RenderLab

repo_name: Ubpa/RenderLab

gha_license_id: MIT

extension: cpp