text:
1488" y1="54.07638125" x2="19.1488" y2="53.9994375" width="0.1524" layer="1"/>
<wire x1="20.09141875" y1="55.019" x2="19.1488" y2="54.07638125" width="0.1524" layer="1"/>
<wire x1="17.551028125" y1="52.679971875" x2="17.551028125" y2="52.095028125" width="0.1524" layer="1"/>
<wire x1="17.551028125" y1="52.095028125" x2="17.018" y2="51.562" width="0.1524" layer="1"/>
</signal>
<signal name="N$20">
<contactref element="U3" pad="4"/>
<contactref element="U1" pad="15"/>
<wire x1="15.01065625" y1="49.7586" x2="8.73186875" y2="49.7586" width="0.1524" layer="1"/>
<wire x1="8.73186875" y1="49.7586" x2="7.7724" y2="50.71806875" width="0.1524" layer="1"/>
<wire x1="7.7724" y1="57.3786" x2="7.7724" y2="50.71806875" width="0.1524" layer="1"/>
<wire x1="7.7724" y1="57.3786" x2="6.35" y2="58.801" width="0.1524" layer="1"/>
<via x="16.764" y="52.324" extent="1-16" drill="0.35"/>
<wire x1="16.764" y1="52.324" x2="16.764" y2="51.562" width="0.1524" layer="16"/>
<wire x1="16.764" y1="51.562" x2="16.129" y2="50.927" width="0.1524" layer="16"/>
<via x="16.129" y="50.927" extent="1-16" drill="0.35"/>
<wire x1="16.129" y1="50.927" x2="16.129" y2="50.87694375" width="0.1524" layer="1"/>
<wire x1="16.129" y1="50.87694375" x2="15.01065625" y2="49.7586" width="0.1524" layer="1"/>
<wire x1="19.00125625" y1="54.6382" x2="18.844" y2="54.48094375" width="0.1524" layer="1"/>
<wire x1="19.2795625" y1="54.6382" x2="19.00125625" y2="54.6382" width="0.1524" layer="1"/>
<wire x1="20.9931" y1="55.519" x2="20.1603625" y2="55.519" width="0.1524" layer="1"/>
<wire x1="20.1603625" y1="55.519" x2="19.2795625" y2="54.6382" width="0.1524" layer="1"/>
<wire x1="18.844" y1="54.12569375" x2="18.51830625" y2="53.8" width="0.1524" layer="1"/>
<wire x1="18.51830625" y1="53.8" x2="18.24" y2="53.8" width="0.1524" layer="1"/>
<wire x1="18.24" y1="53.8" x2="16.764" y2="52.324" width="0.1524" layer="1"/>
<wire x1="18.844" y1="54.48094375" x2="18.844" y2="54.12569375" width="0.1524" layer="1"/>
</signal>
<signal name="N$22">
<contactref element="R23" pad="1"/>
<contactref element="R28" pad="2"/>
<contactref element="U1" pad="33"/>
<wire x1="30.381" y1="55.019" x2="30.48" y2="55.118" width="0.1524" layer="1"/>
<wire x1="30.381" y1="55.019" x2="28.2829" y2="55.019" width="0.1524" layer="1"/>
<wire x1="30.48" y1="55.118" x2="30.48" y2="55.372" width="0.1524" layer="1"/>
<wire x1="30.48" y1="55.372" x2="32.004" y2="56.896" width="0.1524" layer="1"/>
<via x="32.004" y="56.896" extent="1-16" drill="0.35"/>
<wire x1="32.004" y1="58.0263" x2="32.004" y2="56.896" width="0.1524" layer="16"/>
<wire x1="32.004" y1="58.0263" x2="32.0167" y2="58.039" width="0.1524" layer="16"/>
<wire x1="32.004" y1="56.896" x2="32.131" y2="57.023" width="0.1524" layer="16"/>
<wire x1="32.131" y1="57.023" x2="34.29" y2="57.023" width="0.1524" layer="16"/>
<wire x1="34.29" y1="57.023" x2="34.544" y2="57.023" width="0.1524" layer="16"/>
<wire x1="33.8328" y1="69.596" x2="33.8328" y2="73.53225625" width="0.1524" layer="16"/>
<wire x1="33.8328" y1="73.53225625" x2="32.89505625" y2="74.47" width="0.1524" layer="16"/>
<wire x1="32.89505625" y1="74.47" x2="31.321" y2="74.47" width="0.1524" layer="16"/>
<wire x1="31.321" y1="74.47" x2="30.988" y2="74.803" width="0.1524" layer="16"/>
<via x="30.988" y="74.803" extent="1-16" drill="0.35"/>
<wire x1="30.988" y1="74.803" x2="30.734" y2="75.057" width="0.1524" layer="1"/>
<wire x1="30.734" y1="75.057" x2="30.734" y2="75.9206" width="0.1524" layer="1"/>
<wire x1="34.544" y1="57.023" x2="36.576" y2="57.023" width="0.1524" layer="16"/>
<wire x1="36.576" y1="57.023" x2="37.0078" y2="57.5818" width="0.1524" layer="16"/>
<wire x1="37.0078" y1="57.5818" x2="37.0078" y2="66.294" width="0.1524" layer="16"/>
<wire x1="37.0078" y1="66.294" x2="33.8328" y2="69.596" width="0.1524" layer="16"/>
</signal>
<signal name="N$24">
<contactref element="R24" pad="1"/>
<contactref element="R27" pad="2"/>
<contactref element="U1" pad="34"/>
<wire x1="28.2829" y1="55.519" x2="29.738" y2="55.519" width="0.1524" layer="1"/>
<wire x1="29.738" y1="55.519" x2="33.528" y2="59.309" width="0.1524" layer="1"/>
<via x="33.528" y="59.309" extent="1-16" drill="0.35"/>
<wire x1="33.2867" y1="59.309" x2="33.528" y2="59.309" width="0.1524" layer="16"/>
<wire x1="33.2867" y1="59.309" x2="32.0167" y2="60.579" width="0.1524" layer="16"/>
<wire x1="33.528" y1="69.469" x2="33.528" y2="73.406" width="0.1524" layer="16"/>
<wire x1="33.528" y1="73.406" x2="33.02" y2="73.914" width="0.1524" layer="16"/>
<wire x1="33.02" y1="73.914" x2="30.353" y2="73.914" width="0.1524" layer="16"/>
<via x="30.353" y="73.914" extent="1-16" drill="0.35"/>
<wire x1="30.353" y1="73.914" x2="29.337" y2="74.93" width="0.1524" layer="1"/>
<wire x1="29.337" y1="74.93" x2="29.337" y2="75.9206" width="0.1524" layer="1"/>
<wire x1="33.528" y1="59.309" x2="36.322" y2="59.309" width="0.1524" layer="16"/>
<wire x1="36.322" y1="59.309" x2="36.703" y2="59.817" width="0.1524" layer="16"/>
<wire x1="36.703" y1="59.817" x2="36.703" y2="66.167" width="0.1524" layer="16"/>
<wire x1="36.703" y1="66.167" x2="33.528" y2="69.469" width="0.1524" layer="16"/>
</signal>
<signal name="N$38">
<contactref element="R26" pad="1"/>
<contactref element="C2" pad="2"/>
<contactref element="J6" pad="1"/>
<wire x1="26.543" y1="77.2414" x2="26.543" y2="80.1243" width="0.1524" layer="1"/>
<wire x1="26.543" y1="80.1243" x2="26.543" y2="80.01" width="0.1524" layer="1"/>
<wire x1="26.543" y1="80.01" x2="27.178" y2="79.375" width="0.1524" layer="1"/>
<via x="27.178" y="79.375" extent="1-16" drill="0.35"/>
<wire x1="27.178" y1="79.375" x2="27.178" y2="78.994" width="0.1524" layer="16"/>
<wire x1="27.178" y1="78.994" x2="26.797" y2="78.613" width="0.1524" layer="16"/>
<wire x1="16.335" y1="79.14469375" x2="16.335" y2="79.296" width="0.1524" layer="16"/>
<wire x1="16.335" y1="79.296" x2="14.986" y2="80.645" width="0.1524" layer="16"/>
<wire x1="26.797" y1="78.613" x2="16.86669375" y2="78.613" width="0.1524" layer="16"/>
<wire x1="16.86669375" y1="78.613" x2="16.335" y2="79.14469375" width="0.1524" layer="16"/>
<wire x1="14.986" y1="80.645" x2="14.53453125" y2="80.645" width="0.1524" layer="16"/>
<wire x1="14.53453125" y1="80.645" x2="14.43293125" y2="80.5434" width="0.1524" layer="16"/>
<wire x1="5.88706875" y1="80.5434" x2="5.2324" y2="81.19806875" width="0.1524" layer="16"/>
<wire x1="5.2324" y1="81.19806875" x2="5.2324" y2="81.3816" width="0.1524" layer="16"/>
<wire x1="5.2324" y1="81.3816" x2="4.953" y2="81.661" width="0.1524" layer="16"/>
<wire x1="14.43293125" y1="80.5434" x2="5.88706875" y2="80.5434" width="0.1524" layer="16"/>
<wire x1="4.953" y1="81.661" x2="4.953" y2="86.233" width="0.1524" layer="16"/>
<wire x1="4.953" y1="86.233" x2="5.588" y2="86.868" width="0.1524" layer="16"/>
<wire x1="5.588" y1="86.868" x2="5.588" y2="95.377" width="0.1524" layer="16"/>
<wire x1="5.588" y1="95.377" x2="5.334" y2="95.631" width="0.1524" layer="16"/>
</signal>
<signal name="N$40">
<contactref element="R25" pad="1"/>
<contactref element="C3" pad="2"/>
<contactref element="J6" pad="2"/>
<wire x1="27.94" y1="77.2414" x2="27.94" y2="80.1243" width="0.1524" layer="1"/>
<wire x1="27.94" y1="80.1243" x2="27.94" y2="79.883" width="0.1524" layer="1"/>
<wire x1="27.94" y1="79.883" x2="28.575" y2="79.248" width="0.1524" layer="1"/>
<via x="28.575" y="79.248" extent="1-16" drill="0.35"/>
<wire x1="16.0302" y1="79.0184375" x2="16.0302" y2="79.16974375" width="0.1524" layer="16"/>
<wire x1="26.92325625" y1="78.3082" x2="16.7404375" y2="78.3082" width="0.1524" layer="16"/>
<wire x1="16.7404375" y1="78.3082" x2="16.0302" y2="79.0184375" width="0.1524" layer="16"/>
<wire x1="28.575" y1="79.248" x2="27.86305625" y2="79.248" width="0.1524" layer="16"/>
<wire x1="27.86305625" y1="79.248" x2="26.92325625" y2="78.3082" width="0.1524" layer="16"/>
<wire x1="14.960971875" y1="80.238971875" x2="14.559559375" y2="80.238971875" width="0.1524" layer="16"/>
<wire x1="14.559559375" y1="80.238971875" x2="14.5591875" y2="80.2386" width="0.1524" layer="16"/>
<wire x1="4.9276" y1="81.0718125" x2="4.9276" y2="81.1784" width="0.1524" layer="16"/>
<wire x1="4.9276" y1="81.1784" x2="4.572" y2="81.534" width="0.1524" layer="16"/>
<wire x1="14.5591875" y1="80.2386" x2="5.7608125" y2="80.2386" width="0.1524" layer="16"/>
<wire x1="5.7608125" y1="80.2386" x2="4.9276" y2="81.0718125" width="0.1524" layer="16"/>
<wire x1="4.572" y1="81.534" x2="4.572" y2="86.76466875" width="0.1524" layer="16"/>
<wire x1="4.572" y1="86.76466875" x2="5.15874375" y2="87.3514125" width="0.1524" layer="16"/>
<wire x1="5.15874375" y1="87.3514125" x2="5.15874375" y2="93.26625625" width="0.1524" layer="16"/>
<wire x1="5.15874375" y1="93.26625625" x2="2.794" y2="95.631" width="0.1524" layer="16"/>
<wire x1="16.0302" y1="79.16974375" x2="14.960971875" y2="80.238971875" width="0.1524" layer="16"/>
</signal>
<signal name="N$42">
<contactref element="R28" pad="1"/>
<contactref element="C16" pad="2"/>
<contactref element="U$1" pad="2"/>
<wire x1="30.734" y1="77.2414" x2="30.734" y2="80.1243" width="0.1524" layer="1"/>
<wire x1="30.734" y1="80.1243" x2="30.7467" y2="80.1243" width="0.1524" layer="1"/>
<wire x1="30.7467" y1="80.1243" x2="31.496" y2="79.375" width="0.1524" layer="1"/>
<via x="31.496" y="79.375" extent="1-16" drill="0.35"/>
<wire x1="16.61418125" y1="78.0034" x2="16.51258125" y2="78.105" width="0.1524" layer="16"/>
<wire x1="16.51258125" y1="78.105" x2="15.367" y2="78.105" width="0.1524" layer="16"/>
<wire x1="31.496" y1="79.375" x2="30.88530625" y2="79.375" width="0.1524" layer="16"/>
<wire x1="30.88530625" y1="79.375" x2="29.51370625" y2="78.0034" width="0.1524" layer="16"/>
<wire x1="29.51370625" y1="78.0034" x2="16.61418125" y2="78.0034" width="0.1524" layer="16"/>
<via x="15.367" y="78.105" extent="1-16" drill="0.35"/>
<wire x1="15.367" y1="78.105" x2="15.367" y2="85.852" width="0.1524" layer="1"/>
<wire x1="15.367" y1="85.852" x2="13.081" y2="88.138" width="0.1524" layer="1"/>
<wire x1="13.081" y1="88.138" x2="13.081" y2="89.408" width="0.1524" layer="1"/>
</signal>
<signal name="N$44">
<contactref element="R27" pad="1"/>
<contactref element="C17" pad="2"/>
<contactref element="U$1" pad="1"/>
<wire x1="29.337" y1="77.2414" x2="29.337" y2="80.1243" width="0.1524" layer="1"/>
<wire x1="29.337" y1="80.1243" x2="29.337" y2="79.883" width="0.1524" layer="1"/>
<wire x1="29.337" y1="79.883" x2="29.972" y2="79.248" width="0.1524" layer="1"/>
<via x="29.972" y="79.248" extent="1-16" drill="0.35"/>
<wire x1="29.972" y1="79.248" x2="29.972" y2="80.518" width="0.1524" layer="16"/>
<wire x1="29.972" y1="80.518" x2="28.575" y2="81.915" width="0.1524" layer="16"/>
<via x="28.575" y="81.915" extent="1-16" drill="0.35"/>
<wire x1="28.575" y1="81.915" x2="23.114" y2="81.915" width="0.1524" layer="1"/>
<wire x1="23.114" y1="81.915" x2="15.621" y2="89.408" width="0.1524" layer="1"/>
</signal>
<signal name="N$6">
<contactref element="R30" pad="1"/>
<contactref element="C18" pad="2"/>
<contactref element="J7" pad="1"/>
<wire x1="32.258" y1="77.2414" x2="32.258" y2="80.1243" width="0.1524" layer="1"/>
<wire x1="32.258" y1="80.1243" x2="32.2707" y2="80.1243" width="0.1524" layer="1"/>
<wire x1="32.2707" y1="80.1243" x2="33.02" y2="79.375" width="0.1524" layer="1"/>
<via x="33.02" y="79.375" extent="1-16" drill="0.35"/>
<wire x1="33.02" y1="79.375" x2="33.02" y2="81.788" width="0.1524" layer="16"/>
<wire x1="33.02" y1="81.788" x2="33.782" y2="82.55" width="0.1524" layer="16"/>
<wire x1="33.782" y1="82.55" x2="33.782" y2="91.567" width="0.1524" layer="16"/>
<wire x1="33.782" y1="91.567" x2="33.909" y2="91.694" width="0.1524" layer="16"/>
<via x="33.909" y="91.694" extent="1-16" drill="0.35"/>
<wire x1="33.909" y1="91.694" x2="33.33053125" y2="91.694" width="0.1524" layer="1"/>
<wire x1="33.33053125" y1="91.694" x2="32.84793125" y2="92.1766" width="0.1524" layer="1"/>
<wire x1="17.44725" y1="93.1934125" x2="17.44725" y2="94.0045875" width="0.1524" layer="1"/>
<wire x1="18.3370625" y1="92.1766" x2="17.44725" y2="93.1934125" width="0.1524" layer="1"/>
<wire x1="19.431" y1="95.7343375" x2="19.431" y2="96.139" width="0.1524" layer="1"/>
<wire x1="17.44725" y1="94.0045875" x2="19.431" y2="95.7343375" width="0.1524" layer="1"/>
<wire x1="32.84793125" y1="92.1766" x2="18.3370625" y2="92.1766" width="0.1524" layer="1"/>
</signal>
<signal name="N$16">
<contactref element="R29" pad="1"/>
<contactref element="C19" pad="2"/>
<contactref element="J7" pad="2"/>
<wire x1="33.782" y1="77.2414" x2="33.782" y2="80.1243" width="0.1524" layer="1"/>
<wire x1="33.782" y1="80.1243" x2="34.6583" y2="80.1243" width="0.1524" layer="1"/>
<wire x1="34.6583" y1="80.1243" x2="34.671" y2="80.137" width="0.1524" layer="1"/>
<via x="34.671" y="80.137" extent="1-16" drill="0.35"/>
<wire x1="34.671" y1="80.137" x2="34.671" y2="92.329" width="0.1524" layer="16"/>
<wire x1="34.671" y1="92.329" x2="34.544" y2="92.456" width="0.1524" layer="16"/>
<via x="34.544" y="92.456" extent="1-16" drill="0.35"/>
<wire x1="34.544" y1="92.456" x2="32.9995875" y2="92.456" width="0.1524" layer="1"/>
<wire x1="32.9995875" y1="92.456" x2="32.9741875" y2="92.4814" width="0.1524" layer="1"/>
<wire x1="21.33490625" y1="92.4814" x2="21.08370625" y2="92.7326" width="0.1524" layer="1"/>
<wire x1="20.2974" y1="92.7326" x2="19.431" y2="93.599" width="0.1524" layer="1"/>
<wire x1="21.08370625" y1="92.7326" x2="20.2974" y2="92.7326" width="0.1524" layer="1"/>
<wire x1="32.9741875" y1="92.4814" x2="21.33490625" y2="92.4814" width="0.1524" layer="1"/>
</signal>
<signal name="N$43">
<contactref element="R25" pad="2"/>
<contactref element="U1" pad="31"/>
<contactref element="R33" pad="2"/>
<wire x1="29.845" y1="50.4317" x2="30.353" y2="50.9397" width="0.1524" layer="16"/>
<wire x1="30.353" y1="50.9397" x2="30.353" y2="53.34" width="0.1524" layer="16"/>
<via x="30.353" y="53.34" extent="1-16" drill="0.35"/>
<wire x1="29.801" y1="54.019" x2="30.353" y2="53.34" width="0.1524" layer="1"/>
<wire x1="29.801" y1="54.019" x2="28.2829" y2="54.019" width="0.1524" layer="1"/>
<wire x1="30.353" y1="53.34" x2="31.448" y2="54.435" width="0.1524" layer="1"/>
<wire x1="31.448" y1="54.435" x2="31.448" y2="54.71330625" width="0.1524" layer="1"/>
<wire x1="31.448" y1="54.71330625" x2="34.7698" y2="58.03510625" width="0.1524" layer="1"/>
<wire x1="34.7698" y1="64.6185625" x2="33.3248" y2="66.0635625" width="0.1524" layer="1"/>
<wire x1="27.94" y1="75.2583625" x2="27.94" y2="75.9206" width="0.1524" layer="1"/>
<wire x1="33.3248" y1="69.8735625" x2="27.94" y2="75.2583625" width="0.1524" layer="1"/>
<wire x1="34.7698" y1="58.03510625" x2="34.7698" y2="64.6185625" width="0.1524" layer="1"/>
<wire x1="33.3248" y1="66.0635625" x2="33.3248" y2="69.8735625" width="0.1524" layer="1"/>
</signal>
<signal name="N$45">
<contactref element="R26" pad="2"/>
<contactref element="U1" pad="32"/>
<contactref element="R34" pad="2"/>
<wire x1="30.353" y1="54.12630625" x2="30.353" y2="54.356" width="0.1524" layer="16"/>
<wire x1="29.797" y1="53.57030625" x2="30.353" y2="54.12630625" width="0.1524" layer="16"/>
<wire x1="27.94" y1="50.4317" x2="29.797" y2="52.2887" width="0.1524" layer="16"/>
<wire x1="29.797" y1="52.2887" x2="29.797" y2="53.57030625" width="0.1524" layer="16"/>
<via x="30.353" y="54.356" extent="1-16" drill="0.35"/>
<wire x1="30.19" y1="54.519" x2="30.353" y2="54.356" width="0.1524" layer="1"/>
<wire x1="30.19" y1="54.519" x2="28.2829" y2="54.519" width="0.1524" layer="1"/>
<wire x1="33.02" y1="65.93730625" x2="33.02" y2="69.215" width="0.1524" layer="1"/>
<wire x1="34.465" y1="64.49230625" x2="33.02" y2="65.93730625" width="0.1524" layer="1"/>
<wire x1="30.353" y1="54.356" x2="34.465" y2="58.468" width="0.1524" layer="1"/>
<wire x1="34.465" y1="58.468" x2="34.465" y2="64.49230625" width="0.1524" layer="1"/>
<wire x1="27.988" y1="74.77930625" x2="27.66230625" y2="75.105" width="0.1524" layer="1"/>
<wire x1="33.02" y1="69.215" x2="27.988" y2="74.247" width="0.1524" layer="1"/>
<wire x1="27.988" y1="74.247" x2="27.988" y2="74.77930625" width="0.1524" layer="1"/>
<wire x1="27.66230625" y1="75.105" x2="27.3586" y2="75.105" width="0.1524" layer="1"/>
<wire x1="27.3586" y1="75.105" x2="26.543" y2="75.9206" width="0.1524" layer="1"/>
</signal>
<signal name="N$33">
<contactref element="R31" pad="1"/>
<contactref element="R30" pad="2"/>
<contactref element="U1" pad="30"/>
<wire x1="29.797" y1="53.10969375" x2="30.12269375" y2="52.784" width="0.1524" layer="1"/>
<wire x1="30.12269375" y1="52.784" x2="30.58330625" y2="52.784" width="0.1524" layer="1"/>
<wire x1="30.58330625" y1="52.784" x2="30.909" y2="53.10969375" width="0.1524" layer="1"/>
<wire x1="30.909" y1="53.10969375" x2="31.544" y2="53.896" width="0.1524" layer="1"/>
<wire x1="31.544" y1="53.896" x2="32.004" y2="54.483" width="0.1524" layer="1"/>
<wire x1="28.2829" y1="53.519" x2="29.464253125" y2="53.519" width="0.1524" layer="1"/>
<wire x1="29.464253125" y1="53.519" x2="29.797" y2="53.10969375" width="0.1524" layer="1"/>
<via x="32.004" y="54.483" extent="1-16" drill="0.35"/>
<wire x1="32.004" y1="54.483" x2="32.0167" y2="55.0037" width="0.1524" layer="16"/>
<wire x1="32.0167" y1="55.0037" x2="32.0167" y2="55.626" width="0.1524" layer="16"/>
<wire x1="33.655" y1="66.16441875" x2="33.655" y2="70.104" width="0.1524" layer="1"/>
<wire x1="35.0746" y1="64.74481875" x2="33.655" y2="66.16441875" width="0.1524" layer="1"/>
<wire x1="32.004" y1="54.483" x2="34.4805" y2="56.9595" width="0.1524" layer="1"/>
<wire x1="34.4805" y1="56.9595" x2="35.0746" y2="57.5536" width="0.1524" layer="1"/>
<wire x1="35.0746" y1="57.5536" x2="35.0746" y2="64.74481875" width="0.1524" layer="1"/>
<wire x1="33.655" y1="70.104" x2="32.258" y2="71.501" width="0.1524" layer="1"/>
<wire x1="32.258" y1="71.501" x2="32.258" y2="75.9206" width="0.1524" layer="1"/>
</signal>
<signal name="N$39">
<contactref element="R32" pad="1"/>
<contactref element="R29" pad="2"/>
<contactref element="U1" pad="29"/>
<wire x1="28.2829" y1="53.019" x2="28.4146" y2="52.8873" width="0.1524" layer="1"/>
<wire x1="28.4146" y1="52.8873" x2="29.2411875" y2="52.8873" width="0.1524" layer="1"/>
<wire x1="30.0584875" y1="52.07" x2="31.75" y2="52.07" width="0.1524" layer="1"/>
<wire x1="29.2411875" y1="52.8873" x2="30.0584875" y2="52.07" width="0.1524" layer="1"/>
<via x="31.75" y="52.07" extent="1-16" drill="0.35"/>
<wire x1="31.75" y1="52.07" x2="32.0167" y2="52.3367" width="0.1524" layer="16"/>
<wire x1="32.0167" y1="52.3367" x2="32.0167" y2="53.213" width="0.1524" layer="16"/>
<wire x1="35.3794" y1="64.871075" x2="33.9598" y2="66.290675" width="0.1524" layer="1"/>
<wire x1="31.75" y1="52.07" x2="35.3794" y2="55.6994" width="0.1524" layer="1"/>
<wire x1="35.3794" y1="55.6994" x2="35.3794" y2="64.871075" width="0.1524" layer="1"/>
<wire x1="33.9598" y1="70.23025625" x2="33.782" y2="70.40805625" width="0.1524" layer="1"/>
<wire x1="33.782" y1="70.40805625" x2="33.782" y2="75.9206" width="0.1524" layer="1"/>
<wire x1="33.9598" y1="66.290675" x2="33.9598" y2="70.23025625" width="0.1524" layer="1"/>
</signal>
<signal name="N$61">
<contactref element="J14" pad="8"/>
<contactref element="U$2" pad="P$26"/>
<wire x1="42.418" y1="35.56" x2="44.704" y2="33.274" width="0.1524" layer="1"/>
<via x="44.704" y="33.274" extent="1-16" drill="0.35"/>
<wire x1="48.3616" y1="29.3624" x2="48.514" y2="29.21" width="0.1524" layer="16"/>
<wire x1="46.78106875" y1="29.3624" x2="48.3616" y2="29.3624" width="0.1524" layer="16"/>
<wire x1="44.704" y1="33.274" x2="44.704" y2="31.43946875" width="0.1524" layer="16"/>
<wire x1="44.704" y1="31.43946875" x2="46.78106875" y2="29.3624" width="0.1524" layer="16"/>
<wire x1="48.514" y1="29.21" x2="50.546" y2="29.21" width="0.1524" layer="16"/>
<wire x1="50.546" y1="29.21" x2="51.054" y2="28.702" width="0.1524" layer="16"/>
<wire x1="51.054" y1="28.702" x2="51.054" y2="13.97" width="0.1524" layer="16"/>
<wire x1="51.054" y1="13.97" x2="49.784" y2="12.7" width="0.1524" layer="16"/>
</signal>
<signal name="N$66">
<contactref element="J14" pad="7"/>
<contactref element="U$2" pad="P$22"/>
<wire x1="42.418" y1="33.02" x2="42.418" y2="32.512" width="0.1524" layer="16"/>
<wire x1="42.418" y1="32.512" x2="43.688" y2="31.242" width="0.1524" layer="16"/>
<wire x1="48.3616" y1="19.2024" x2="49.784" y2="17.78" width="0.1524" layer="16"/>
<wire x1="46.78106875" y1="19.2024" x2="48.3616" y2="19.2024" width="0.1524" layer="16"/>
<wire x1="43.688" y1="31.242" x2="43.688" y2="22.29546875" width="0.1524" layer="16"/>
<wire x1="43.688" y1="22.29546875" x2="46.78106875" y2="19.2024" width="0.1524" layer="16"/>
</signal>
<signal name="N$86">
<contactref element="J14" pad="6"/>
<contactref element="U$2" pad="P$3"/>
<wire x1="42.418" y1="30.48" x2="44.196" y2="31.43946875" width="0.1524" layer="1"/>
<wire x1="45.3136" y1="38.7096" x2="47.244" y2="40.64" width="0.1524" layer="1"/>
<wire x1="44.196" y1="31.43946875" x2="45.3136" y2="32.55706875" width="0.1524" layer="1"/>
<wire x1="45.3136" y1="32.55706875" x2="45.3136" y2="38.7096" width="0.1524" layer="1"/>
</signal>
<signal name="N$87">
<contactref element="J14" pad="5"/>
<contactref element="U$2" pad="P$5"/>
<wire x1="42.418" y1="27.94" x2="44.704" y2="27.94" width="0.1524" layer="1"/>
<wire x1="44.704" y1="27.94" x2="45.72" y2="28.956" width="0.1524" layer="1"/>
<wire x1="45.72" y1="28.956" x2="45.72" y2="36.576" width="0.1524" layer="1"/>
<wire x1="45.72" y1="36.576" x2="47.244" y2="38.1" width="0.1524" layer="1"/>
</signal>
<signal name="N$88">
<contactref element="J14" pad="4"/>
<contactref element="U$2" pad="P$16"/>
<wire x1="42.418" y1="25.4" x2="44.704" y2="25.4" width="0.1524" layer="1"/>
<wire x1="44.704" y1="25.4" x2="45.974" y2="26.67" width="0.1524" layer="1"/>
<via x="45.974" y="26.67" extent="1-16" drill="0.35"/>
<wire x1="45.974" y1="26.67" x2="48.514" y2="26.67" width="0.1524" layer="16"/>
<wire x1="48.514" y1="26.67" x2="49.784" y2="25.4" width="0.1524" layer="16"/>
</signal>
<signal name="N$89">
<contactref element="U$2" pad="P$15"/>
<contactref element="J14" pad="3"/>
<wire x1="42.418" y1="22.86" x2="44.704" y2="22.86" width="0.1524" layer="1"/>
<wire x1="44.704" y1="22.86" x2="47.244" y2="25.4" width="0.1524" layer="1"/>
</signal>
<signal name="N$90">
<contactref element="J14" pad="1"/>
<contactref element="U$2" pad="P$2"/>
<contactref element="U$2" pad="P$4"/>
<wire x1="42.418" y1="17.78" x2="44.704" y2="17.78" width="0.1524" layer="1"/>
<wire x1="44.704" y1="17.78" x2="45.72" y2="18.796" width="0.1524" layer="1"/>
<wire x1="45.72" y1="18.796" x2="46.67946875" y2="18.796" width="0.1524" layer="1"/>
<wire x1="46.67946875" y1="18.796" x2="46.78106875" y2="18.8976" width="0.1524" layer="1"/>
<wire x1="46.78106875" y1="18.8976" x2="47.5996" y2="18.8976" width="0.1524" layer="1"/>
<wire x1="47.5996" y1="18.8976" x2="48.514" y2="19.812" width="0.1524" layer="1"/>
<wire x1="48.514" y1="19.812" x2="48.514" y2="39.37" width="0.1524" layer="1"/>
<wire x1="48.514" y1="39.37" x2="49.784" y2="40.64" width="0.1524" layer="1"/>
<wire x1="49.784" y1="40.64" x2="49.784" y2="43.18" width="0.1524" layer="1"/>
</signal>
<signal name="GNDA">
<contactref element="J14" pad="2"/>
<contactref element="U$2" pad="P$25"/>
<contactref element="U$2" pad="P$20"/>
<contactref element="U$2" pad="P$14"/>
<contactref element="U$2" pad="P$9"/>
<contactref element="U$2" pad="P$6"/>
<contactref element="U$3" pad="4"/>
<polygon width="0.254" layer="1">
<vertex x="40.64" y="10.922"/>
<vertex x="55.753" y="10.922"/>
<vertex x="55.753" y="52.324"/>
<vertex x="40.64" y="52.324"/>
</polygon>
<polygon width="0.254" layer="16">
<vertex x="40.64" y="10.922"/>
<vertex x="55.753" y="10.668"/>
<vertex x="55.753" y="52.324"/>
<vertex x="40.64" y="52.324"/>
</polygon>
</signal>
<signal name="N$91">
<contactref element="U$3" pad="1"/>
<contactref element="U$2" pad="P$8"/>
<wire x1="50.038" y1="46.99" x2="50.038" y2="44.50653125" width="0.1524" layer="16"/>
<wire x1="50.038" y1="44.50653125" x2="50.9016" y2="43.64293125" width="0.1524" layer="16"/>
<wire x1="50.9016" y1="43.64293125" x2="50.9016" y2="36.6776" width="0.1524" layer="16"/>
<wire x1="50.9016" y1="36.6776" x2="49.784" y2="35.56" width="0.1524" layer="16"/>
</signal>
<signal name="N$92">
<contactref element="U$3" pad="2"/>
<contactref element="U$2" pad="P$10"/>
<wire x1="48.3616" y1="43.64293125" x2="48.3616" y2="42.71706875" width="0.1524" layer="16"/>
<wire x1="48.3616" y1="42.71706875" x2="48.288265625" y2="42.643734375" width="0.1524" layer="16"/>
<wire x1="47.498" y1="46.99" x2="47.498" y2="44.50653125" width="0.1524" layer="16"/>
<wire x1="47.498" y1="44.50653125" x2="48.3616" y2="43.64293125" width="0.1524" layer="16"/>
<wire x1="48.288265625" y1="42.643734375" x2="48.288265625" y2="41.176265625" width="0.1524" layer="16"/>
<wire x1="48.288265625" y1="41.176265625" x2="48.3616" y2="41.10293125" width="0.1524" layer="16"/>
<wire x1="48.3616" y1="34.4424" x2="49.784" y2="33.02" width="0.1524" layer="16"/>
<wire x1="48.3616" y1="41.10293125" x2="48.3616" y2="34.4424" width="0.1524" layer="16"/>
</signal>
<signal name="N$93">
<contactref element="U$2" pad="P$1"/>
<contactref element="U$2" pad="P$17"/>
<contactref element="J14" pad="9"/>
<contactref element="U$3" pad="3"/>
<wire x1="42.418" y1="38.354" x2="42.418" y2="38.1" width="0.1524" layer="1"/>
<wire x1="42.418" y1="38.354" x2="47.244" y2="43.18" width="0.1524" layer="1"/>
<wire x1="47.244" y1="43.18" x2="47.244" y2="44.704" width="0.1524" layer="1"/>
<wire x1="47.244" y1="44.704" x2="44.958" y2="46.99" width="0.1524" layer="1"/>
<wire x1="42.418" y1="38.1" x2="43.434" y2="38.1" width="0.1524" layer="1"/>
<wire x1="43.434" y1="38.1" x2="44.196" y2="37.338" width="0.1524" layer="1"/>
<via x="44.196" y="37.338" extent="1-16" drill="0.35"/>
<wire x1="44.196" y1="25.908" x2="47.244" y2="22.86" width="0.1524" layer="16"/>
<wire x1="44.196" y1="37.338" x2="44.196" y2="33.55230625" width="0.1524" layer="16"/>
<wire x1="44.196" y1="33.55230625" x2="44.148" y2="33.50430625" width="0.1524" layer="16"/>
<wire x1="44.148" y1="33.50430625" x2="44.148" y2="33.04369375" width="0.1524" layer="16"/>
<wire x1="44.148" y1="33.04369375" x2="44.196" y2="32.99569375" width="0.1524" layer="16"/>
<wire x1="44.196" y1="32.99569375" x2="44.196" y2="25.908" width="0.1524" layer="16"/>
</signal>
</signals>
</board>
</drawing>
</eagle>


text:
namespace HareDu.Model
{
    public interface Listener
    {
        string Node { get; }

        string Protocol { get; }

        string IPAddress { get; }

        string Port { get; }

        SocketOptions SocketOptions { get; }
    }
}

license_type: permissive

branch_name: refs/heads/master

gha_language: C#

extension: cs


text:
import { Hitable, HitRecord } from './hitable'
import { Vector3 } from '../egmath/vector3'
import { Ray } from './ray'
import { Lambertian } from './lambertian'

export class HitableList extends Hitable {
  list: Array<Hitable>
  listSize: number
  name: string
  constructor(l: Array<Hitable>, n: number) {
    super()
    this.name = 'HitableList'
    this.list = l
    this.listSize = n
  }

  hit(r: Ray, tMin: number, tMax: number, rec: HitRecord): boolean {
    let tmpRec = new HitRecord(
      0,
      new Vector3(0, 0, 0),
      new Vector3(0, 0, 0),
      new Lambertian(new Vector3(0, 0, 0))
    )
    let hitAnything = false
    let closestSoFar = tMax
    for (let i = 0; i < this.listSize; i++) {
      if (this.list[i].hit(r, tMin, closestSoFar, tmpRec)) {
        hitAnything = true
        closestSoFar = tmpRec.t
        rec.t = tmpRec.t
        rec.p = tmpRec.p
        rec.normal = tmpRec.normal
        rec.material = tmpRec.material
      }
    }
    return hitAnything
  }
}

license: MIT

repository: RaymondMcGuire/wwipt

repo_name: RaymondMcGuire/wwipt

gha_license_id: MIT

gha_language: TypeScript

extension: ts


text:
using System;
using System.IO;
using Newtonsoft.Json.Linq;

namespace LoveSeat.Interfaces
{
    public interface IDocumentDatabase
    {
        /// <summary>
        /// Creates a document using the json provided.
        /// No validation or smarts attempted here by design for simplicities sake
        /// </summary>
        /// <param name="id">Id of Document</param>
        /// <param name="jsonForDocument"></param>
        /// <returns>The status from CouchDb as a JObject</returns>
        CouchResponseObject CreateDocument(string id, string jsonForDocument);

        CouchResponseObject CreateDocument<T>(T item) where T : class, IBaseObject;

        /// <summary>
        /// Creates a document when you intend for Couch to generate the id for you.
        /// </summary>
        /// <param name="jsonForDocument">Json for creating the document</param>
        /// <returns>Returns the status from Couchdb as a JObject</returns>
        CouchResponseObject CreateDocument(string jsonForDocument);

        CouchResponseObject DeleteDocument(string id, string rev, bool soft=true);

        /// <summary>
        /// Returns null if document is not found
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Document GetDocument(string id);

        Document<T> GetDocument<T>(string id) where T: class;
        /// <summary>
        /// Adds an attachment to a document.  If revision is not specified then the most recent will be fetched and used.  Warning: if you need document update conflicts to occur please use the method that specifies the revision
        /// </summary>
        /// <param name="id">id of the couch Document</param>
        /// <param name="attachment">byte[] of of the attachment.  Use File.ReadAllBytes()</param>
        /// <param name="contentType">Content Type must be specifed</param>
        CouchResponseObject AddAttachment(string id, byte[] attachment, string filename, string contentType);

        /// <summary>
        /// Adds an attachment to the documnet.  Rev must be specified on this signature.  If you want to attach no matter what then use the method without the rev param
        /// </summary>
        /// <param name="id">id of the couch Document</param>
        /// <param name="rev">revision _rev of the Couch Document</param>
        /// <param name="attachment">byte[] of of the attachment.  Use File.ReadAllBytes()</param>
        /// <param name="filename">filename of the attachment</param>
        /// <param name="contentType">Content Type must be specifed</param>
        /// <returns></returns>
        CouchResponseObject AddAttachment(string id, string rev, byte[] attachment, string filename, string contentType);

        Stream GetAttachmentStream(Document doc, string attachmentName);
        Stream GetAttachmentStream(string docId, string rev, string attachmentName);
        Stream GetAttachmentStream(string docId, string attachmentName);
        CouchResponseObject DeleteAttachment(string id, string rev, string attachmentName);
        CouchResponseObject DeleteAttachment(string id, string attachmentName);
        CouchResponseObject SaveDocument(Document document);
        BulkDocumentResponses SaveDocuments(Documents docs, bool all_or_nothing);

        /// <summary>
        /// Gets the results of a view with no view parameters.  Use the overload to pass parameters
        /// </summary>
        /// <param name="viewName">The name of the view</param>
        /// <param name="designDoc">The design doc on which the view resides</param>
        /// <returns></returns>
        ViewResult<T> View<T>(string viewName, string designDoc) where T:class;

        /// <summary>
        /// Gets the results of the view using any and all parameters
        /// </summary>
        /// <param name="viewName">The name of the view</param>
        /// <param name="options">Options such as startkey etc.</param>
        /// <param name="designDoc">The design doc on which the view resides</param>
        /// <returns></returns>
        ViewResult<T> View<T>(string viewName, ViewOptions options, string designDoc) where T:class;

        /// <summary>
        /// Gets all the documents in the database using the _all_docs uri
        /// </summary>
        /// <returns></returns>
        ViewResult GetAllDocuments();

        ViewResult GetAllDocuments(ViewOptions options);

        /// <summary>
        /// Gets the results of the view using the defaultDesignDoc and no view parameters.  Use the overloads to specify options.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="viewName"></param>
        /// <returns></returns>
        ViewResult<T> View<T>(string viewName) where T:class;

        /// <summary>
        /// Allows you to specify options and uses the defaultDesignDoc Specified.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="viewName"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        ViewResult<T>  View<T>(string viewName, ViewOptions options) where T:class;

        Document<T> GetDocument<T>(Guid id , IObjectSerializer objectSerializer) where T: class;
        Document<T> GetDocument<T>(Guid id) where T: class;
        string Show (string showName, string docId);
        IListResult List(string listName, string viewName, ViewOptions options,  string designDoc);
        IListResult List(string listName, string viewName, ViewOptions options);

        ViewResult View(string viewName, ViewOptions options, string designDoc);
        ViewResult View(string viewName, ViewOptions options);
        ViewResult View(string viewName);

        /// <summary>
        /// Set the timeout to be used for future HTTP requests
        /// </summary>
        /// <param name="timeoutMs">The timeout value, in milliseconds.</param>
        void SetTimeout(int timeoutMs);

        void SetDefaultDesignDoc(string designDoc);
    }
}

repository: soitgoes/LoveSeat

repo_name: soitgoes/LoveSeat

gha_license_id: NOASSERTION


text:
import '!style-loader!css-loader!./hello-world-view.css';
import {showNotification} from '@vaadin/flow-frontend/a-notification';
import '@vaadin/vaadin-button';
import '@vaadin/vaadin-combo-box';
import {customElement, html, query} from 'lit-element';
import {View} from '../../views/view';
import {Binder, field} from "Frontend/../target/flow-frontend/form";
import FormDataModel from "Frontend/generated/com/example/application/FormDataModel";
import * as backEnd from "../../generated/BackEnd";
import {ComboBoxElement} from "@vaadin/vaadin-combo-box";

@customElement('hello-world-view')
export class HelloWorldView extends View {
  binder = new  Binder(this, FormDataModel);
  @query("#combo") combo!: ComboBoxElement;

  constructor() {
    super();
  }

  render() {
    const {model} = this.binder;
    return html`
      <vaadin-combo-box id="combo" label="The Value" ...="${field(model.item)}"></vaadin-combo-box>
      <vaadin-button @click="${this.send}">Send</vaadin-button>
    `;
  }

  async firstUpdated() {
      const comboItems = await backEnd.getComboItems();
      this.combo.items = comboItems;
      this.combo.itemValuePath = 'id';
      this.combo.itemLabelPath = 'name';
      this.combo.allowCustomValue=true;
  }

  async send() {
    const value = await this.binder.submitTo(backEnd.doSomethingWithCombo)
    showNotification(`Value is ${value}`);
  }
}

license: Unlicense


text:
package nodes

import (
	sdk "github.com/pokt-network/pocket-core/types"
	"github.com/pokt-network/pocket-core/x/nodes/keeper"
	"github.com/pokt-network/pocket-core/x/nodes/types"
	abci "github.com/tendermint/tendermint/abci/types"
	"reflect"
	"testing"
	"time"
)

func TestExportGenesis(t *testing.T) {
	type args struct {
		ctx    sdk.Context
		keeper keeper.Keeper
	}

	context, _, kpr := createTestInput(t, true)

	tests := []struct {
		name string
		args args
		want types.GenesisState
	}{
		{"Test Export Genesis", args{
			ctx:    context,
			keeper: kpr,
		}, getGenesisStateForTest(context, kpr, false)},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := ExportGenesis(tt.args.ctx, tt.args.keeper); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("ExportGenesis() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestInitGenesis(t *testing.T) {
	type args struct {
		ctx          sdk.Context
		keeper       keeper.Keeper
		supplyKeeper types.AuthKeeper
		data         types.GenesisState
	}

	context, _, kpr := createTestInput(t, true)

	validator := getStakedValidator()
	consAddress := validator.GetAddress()
	kpr.SetPreviousProposer(context, consAddress)

	tests := []struct {
		name    string
		args    args
		wantRes []abci.ValidatorUpdate
	}{}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if gotRes := InitGenesis(tt.args.ctx, tt.args.keeper, tt.args.supplyKeeper, tt.args.data); !reflect.DeepEqual(gotRes, tt.wantRes) {
				t.Errorf("InitGenesis() = %v, want %v", gotRes, tt.wantRes)
			}
		})
	}
}

func TestValidateGenesis(t *testing.T) {
	type args struct {
		data types.GenesisState
	}

	ctx, _, k := createTestInput(t, true)
	datafortest := getGenesisStateForTest(ctx, k, true)
	datafortest2 := getGenesisStateForTest(ctx, k, true)
	datafortest3 := getGenesisStateForTest(ctx, k, true)
	datafortest4 := getGenesisStateForTest(ctx, k, true)
	datafortest5 := getGenesisStateForTest(ctx, k, true)
	datafortest6 := getGenesisStateForTest(ctx, k, true)
	datafortest7 := getGenesisStateForTest(ctx, k, true)
	datafortest8 := getGenesisStateForTest(ctx, k, false)

	datafortest2.Params.SlashFractionDowntime = sdk.NewDec(-3)
	datafortest3.Params.SlashFractionDoubleSign = sdk.NewDec(-3)
	datafortest4.Params.MinSignedPerWindow = sdk.NewDec(-3)
	datafortest5.Params.MaxEvidenceAge = 30 * time.Second
	datafortest6.Params.DowntimeJailDuration = 30 * time.Second
	datafortest7.Params.SignedBlocksWindow = 9

	tests := []struct {
		name    string
		args    args
		wantErr bool
	}{
		{"Test ValidateGenesis", args{data: datafortest}, false},
		{"Test ValidateGenesis 2", args{data: datafortest2}, true},
		{"Test ValidateGenesis 3", args{data: datafortest3}, true},
		{"Test ValidateGenesis 4", args{data: datafortest4}, true},
		{"Test ValidateGenesis 5", args{data: datafortest5}, true},
		{"Test ValidateGenesis 6", args{data: datafortest6}, true},
		{"Test ValidateGenesis 7", args{data: datafortest7}, true},
		{"Test ValidateGenesis 8", args{data: datafortest8}, true},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if err := ValidateGenesis(tt.args.data); (err != nil) != tt.wantErr {
				t.Errorf("ValidateGenesis() error = %v, wantErr %v", err, tt.wantErr)
			}
		})
	}
}

func Test_validateGenesisStateValidators(t *testing.T) {
	type args struct {
		validators   []types.Validator
		minimumStake sdk.BigInt
	}

	ctx, _, k := createTestInput(t, true)

	testdata := getGenesisStateForTest(ctx, k, true)

	val1 := getStakedValidator()
	val1.Jailed = true
	val2 := val1

	valList := []types.Validator{val1, val2}

	tests := []struct {
		name    string
		args    args
		wantErr bool
	}{
		{"Test ValidateGenesisStateValidators", args{
			validators:   testdata.Validators,
			minimumStake: sdk.OneInt(),
		}, false},
		{"Test ValidateGenesisStateValidators 2 duplicatedValidator", args{
			validators:   valList,
			minimumStake: sdk.OneInt(),
		}, true},
		{"Test ValidateGenesisStateValidators 3 jailed staked", args{
			validators:   []types.Validator{val1},
			minimumStake: sdk.OneInt(),
		}, false},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if err := validateGenesisStateValidators(tt.args.validators, tt.args.minimumStake); (err != nil) != tt.wantErr {
				t.Errorf("validateGenesisStateValidators() error = %v, wantErr %v", err, tt.wantErr)
			}
		})
	}
}

repository: pokt-network/pocket-core

repo_name: pokt-network/pocket-core

branch_name: refs/heads/staging

gha_language: Go

extension: go


text:
DESCRIPTION = "A modern, C++-native, header-only, test framework for unit-tests, \
TDD and BDD - using C++11, C++14, C++17 and later."
AUTHOR = "Phil Nash, Martin Horenovsky and others"
HOMEPAGE = "https://github.com/catchorg/Catch2"
LICENSE = "BSL-1.0"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=e4224ccaecb14d942c71d31bef20d78c"

SRC_URI = "git://github.com/catchorg/Catch2.git;branch=v2.x;protocol=https"
SRCREV = "c4e3767e265808590986d5db6ca1b5532a7f3d13"

S = "${WORKDIR}/git"

inherit cmake python3native

do_install:append() {
    rm ${D}${datadir}/Catch2/lldbinit
    rm ${D}${datadir}/Catch2/gdbinit
    rmdir ${D}${datadir}/Catch2/
}
# Header-only library
RDEPENDS:${PN}-dev = ""
RRECOMMENDS:${PN}-dbg = "${PN}-dev (= ${EXTENDPKGV})"

repository: openembedded/meta-openembedded

repo_name: openembedded/meta-openembedded

gha_language: BitBake

extension: bb


text:
## Copyright 2009-2020 Intel Corporation
## SPDX-License-Identifier: Apache-2.0

set(DNNL_VERSION_MAJOR 1)
set(DNNL_VERSION_MINOR 4)
set(DNNL_VERSION_PATCH 0)
set(DNNL_VERSION_HASH  "N/A")

set(DNNL_CPU_RUNTIME "TBB")
set(DNNL_CPU_THREADING_RUNTIME "TBB")
set(DNNL_GPU_RUNTIME "NONE")

configure_file(
  "${PROJECT_SOURCE_DIR}/mkl-dnn/include/dnnl_config.h.in"
  "${PROJECT_BINARY_DIR}/mkl-dnn/include/dnnl_config.h"
)
configure_file(
  "${PROJECT_SOURCE_DIR}/mkl-dnn/include/dnnl_version.h.in"
  "${PROJECT_BINARY_DIR}/mkl-dnn/include/dnnl_version.h"
)

file(GLOB_RECURSE DNNL_SOURCES
  mkl-dnn/src/common/*.h
  mkl-dnn/src/common/*.hpp
  mkl-dnn/src/common/*.c
  mkl-dnn/src/common/*.cpp
  mkl-dnn/src/cpu/bfloat16.cpp
  mkl-dnn/src/cpu/cpu_barrier.hpp
  mkl-dnn/src/cpu/cpu_barrier.cpp
  mkl-dnn/src/cpu/cpu_concat.cpp
  mkl-dnn/src/cpu/cpu_concat_pd.hpp
  mkl-dnn/src/cpu/cpu_convolution_list.cpp
  mkl-dnn/src/cpu/cpu_convolution_pd.hpp
  mkl-dnn/src/cpu/cpu_engine.hpp
  mkl-dnn/src/cpu/cpu_engine.cpp
  mkl-dnn/src/cpu/cpu_isa_traits.hpp
  mkl-dnn/src/cpu/cpu_isa_traits.cpp
  mkl-dnn/src/cpu/cpu_memory_storage.hpp
  mkl-dnn/src/cpu/cpu_pooling_list.cpp
  mkl-dnn/src/cpu/cpu_pooling_pd.hpp
  mkl-dnn/src/cpu/cpu_primitive.hpp
  mkl-dnn/src/cpu/cpu_reducer.hpp
  mkl-dnn/src/cpu/cpu_reducer.cpp
  mkl-dnn/src/cpu/cpu_reorder.cpp
  mkl-dnn/src/cpu/cpu_reorder_pd.hpp
  mkl-dnn/src/cpu/cpu_stream.hpp
  mkl-dnn/src/cpu/cpu_sum.cpp
  mkl-dnn/src/cpu/jit_avx2_conv_kernel_f32.hpp
  mkl-dnn/src/cpu/jit_avx2_conv_kernel_f32.cpp
  mkl-dnn/src/cpu/jit_avx2_convolution.hpp
  mkl-dnn/src/cpu/jit_avx2_convolution.cpp
  mkl-dnn/src/cpu/jit_avx512_core_f32_wino_conv_*.hpp
  mkl-dnn/src/cpu/jit_avx512_core_f32_wino_conv_*.cpp
  mkl-dnn/src/cpu/jit_generator.hpp
  mkl-dnn/src/cpu/jit_primitive_conf.hpp
  mkl-dnn/src/cpu/jit_sse41_conv_kernel_f32.hpp
  mkl-dnn/src/cpu/jit_sse41_conv_kernel_f32.cpp
  mkl-dnn/src/cpu/jit_sse41_convolution.hpp
  mkl-dnn/src/cpu/jit_sse41_convolution.cpp
  mkl-dnn/src/cpu/jit_transpose_src_utils.hpp
  mkl-dnn/src/cpu/jit_transpose_src_utils.cpp
  mkl-dnn/src/cpu/jit_uni_eltwise.hpp
  mkl-dnn/src/cpu/jit_uni_eltwise.cpp
  mkl-dnn/src/cpu/jit_uni_eltwise_injector.hpp
  mkl-dnn/src/cpu/jit_uni_eltwise_injector.cpp
  mkl-dnn/src/cpu/jit_uni_pooling.hpp
  mkl-dnn/src/cpu/jit_uni_pooling.cpp
  mkl-dnn/src/cpu/jit_uni_pool_kernel.hpp
  mkl-dnn/src/cpu/jit_uni_pool_kernel.cpp
  mkl-dnn/src/cpu/jit_uni_reorder.hpp
  mkl-dnn/src/cpu/jit_uni_reorder.cpp
  mkl-dnn/src/cpu/jit_uni_reorder_utils.cpp
  mkl-dnn/src/cpu/simple_q10n.hpp
  mkl-dnn/src/cpu/simple_reorder.hpp
  mkl-dnn/src/cpu/wino_reorder.hpp
  mkl-dnn/src/cpu/resampling/cpu_resampling_list.cpp
  mkl-dnn/src/cpu/resampling/cpu_resampling_pd.hpp
  mkl-dnn/src/cpu/resampling/resampling_utils.hpp
  mkl-dnn/src/cpu/resampling/simple_resampling.hpp
  mkl-dnn/src/cpu/resampling/simple_resampling.cpp
  mkl-dnn/src/cpu/jit_utils/*.h
  mkl-dnn/src/cpu/jit_utils/*.hpp
  mkl-dnn/src/cpu/jit_utils/*.c
  mkl-dnn/src/cpu/jit_utils/*.cpp
  mkl-dnn/src/cpu/xbyak/*.h
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  file(GLOB DNNL_SOURCES_BIGOBJ
    mkl-dnn/src/cpu/cpu_engine.cpp
    mkl-dnn/src/cpu/cpu_reorder.cpp
  )
  set_source_files_properties(${DNNL_SOURCES_BIGOBJ} PROPERTIES COMPILE_FLAGS "/bigobj")
endif()

add_library(dnnl STATIC ${DNNL_SOURCES})

target_include_directories(dnnl
  PUBLIC
    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/mkl-dnn/include>
    $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/mkl-dnn/include>
    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/mkl-dnn/src>
    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/mkl-dnn/src/common>
    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/mkl-dnn/src/cpu>
    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/mkl-dnn/src/cpu/xbyak>
)

target_compile_definitions(dnnl
  PUBLIC
    -DDNNL_ENABLE_CONCURRENT_EXEC
)

set(DNNL_COMPILE_OPTIONS "")
if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
  # Correct 'jnl' macro/jit issue
  list(APPEND DNNL_COMPILE_OPTIONS "/Qlong-double")
endif()
target_compile_options(dnnl PRIVATE ${DNNL_COMPILE_OPTIONS})

target_link_libraries(dnnl
  PUBLIC
    ${CMAKE_THREAD_LIBS_INIT}
    TBB
)
if(UNIX AND NOT APPLE)
  # Not every compiler adds -ldl automatically
  target_link_libraries(dnnl PUBLIC ${CMAKE_DL_LIBS})
endif()

if(OIDN_STATIC_LIB)
  install(TARGETS dnnl
    EXPORT
      ${PROJECT_NAME}_Export
    ARCHIVE
      DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel
  )
endif()

repository: WilliamTambellini/oidn

repo_name: WilliamTambellini/oidn

extension: cmake


text:
package data

import (
	"database/sql"
	"github.com/captainlee1024/go-gateway/internal/gateway/do"
	"github.com/captainlee1024/go-gateway/internal/gateway/po"
	"github.com/captainlee1024/go-gateway/internal/gateway/service"
	"github.com/captainlee1024/go-gateway/internal/gateway/settings"
	"github.com/captainlee1024/go-gateway/internal/pkg/public"
	"github.com/gin-gonic/gin"
	"github.com/jmoiron/sqlx"
	"time"
)

var _ service.ServiceRepo = (service.ServiceRepo)(nil)

type serviceRepo struct{}

func NewServiceRepo() service.ServiceRepo {
	return new(serviceRepo)
}

// ServiceInfo 相关持久化接口实现
// GetServiceInfoList 根据条件获取服务信息列表
func (repo *serviceRepo) GetServiceDetail(serviceInfo *po.ServiceInfo, c *gin.Context) (detail *do.ServiceDetail, err error) {
	// page size info -> 查询各个表组装数据
	// gateway_service_info -> id, service_name, service_desc, load_type
	// service_addr
	// gateway_service_tcp_rule -> service_addr
	// gateway_service_grpc_rule -> service_addr
	// gateway_service_http_rule -> service_addr
	// gateway_service_load_balance -> total_node
	// 中间件 -> qps, qpd

	detail = &do.ServiceDetail{Info: serviceInfo}

	if serviceInfo.LoadType == public.LoadTypeHTTP {
		// 查询 HTTPRule
		httpRule := &po.ServiceHTTPRule{}
		httpRule, err = repo.GetServiceHTTPRuleByID(serviceInfo.ID, c)
		if err != nil {
			return nil, err
		}
		detail.HTTPRule = httpRule
	} else if serviceInfo.LoadType == public.LoadTypeTCP {
		// 查询 TCPRule
		tcpRule := &po.ServiceTCPRule{}
		tcpRule, err = repo.GetServiceTCPRuleByID(serviceInfo.ID, c)
		if err != nil {
			return nil, err
		}
		detail.TCPRule = tcpRule
	} else if serviceInfo.LoadType == public.LoadTypeGRPC {
		// 查询 GRPCRule
		grpcRule := &po.ServiceGRPCRule{}
		grpcRule, err = repo.GetServiceGRPCRuleByID(serviceInfo.ID, c)
		if err != nil {
			return nil, err
		}
		detail.GRPCRule = grpcRule
	}

	// 查询 LoadBalance
	loadBalance := &po.ServiceLoadBalance{}
	loadBalance, err = repo.GetServiceLoadBalanceByID(serviceInfo.ID, c)
	if err != nil {
		return nil, err
	}
	detail.LoadBalance = loadBalance

	// 查询 AccessControl
	accessControl := &po.ServiceAccessControl{}
	accessControl, err = repo.GetServiceAccessControllerByID(serviceInfo.ID, c)
	if err != nil {
		return nil, err
	}
	detail.AccessControl = accessControl

	return detail, nil
}

// GetServiceInfoList 获取列表并返回查询的条数
func (repo *serviceRepo) GetServiceInfoList(info string, page, size int, c *gin.Context,
) (serviceInfoList []*po.ServiceInfo, total int64, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, 0, err
	}

	trace := public.GetGinTraceContext(c)
	//sqlStr := `SELECT id, load_type, service_name, service_desc, create_at, update_at, is_delete
	sqlStr := `SELECT *
			FROM gateway_service_info
			WHERE (service_name LIKE ? OR service_desc LIKE ?) AND is_delete = 0
			ORDER BY id DESC
			LIMIT ?,?`
	serviceInfoList = make([]*po.ServiceInfo, 0, 2)
	err = settings.SqlxLogSelect(trace, db, &serviceInfoList, sqlStr, "%"+info+"%", "%"+info+"%", (page-1)*size, size)
	if err != nil {
		if err == sql.ErrNoRows {
			serviceInfoList = nil
			err = nil
		} else {
			return nil, 0, err
		}
	}

	//countSqlStr := `SELECT COUNT(*) FROM (SELECT * FROM gateway_service_info
	//		WHERE (service_name LIKE ? OR service_desc LIKE ?) AND is_delete = 0
	//		LIMIT ?,?) a`
	countSqlStr := `SELECT COUNT(*) FROM (SELECT * FROM gateway_service_info
			WHERE (service_name LIKE ? OR service_desc LIKE ?) AND is_delete = 0) a`
	err = settings.SqlxLogGet(trace, db, &total, countSqlStr, "%"+info+"%", "%"+info+"%")
	if err != nil {
		if err == sql.ErrNoRows {
			total = 0
			return serviceInfoList, total, nil
		}
		return nil, 0, err
	}

	return serviceInfoList, total, nil
}

func (repo *serviceRepo) GetServiceInfoByID(ID int64, c *gin.Context) (serviceInfoPo *po.ServiceInfo, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	serviceInfoPo = &po.ServiceInfo{}
	trace := public.GetGinTraceContext(c)
	sqlStr := `SELECT *
			FROM gateway_service_info
			WHERE is_delete = 0
			AND id = ?`
	if err = settings.SqlxLogGet(trace, db, serviceInfoPo, sqlStr, ID); err != nil {
		if err == sql.ErrNoRows {
			return nil, ErrServiceNotExit
		} else {
			return nil, err
		}
	}

	return serviceInfoPo, nil
}

func (repo *serviceRepo) GetServiceInfoByName(serviceName string, c *gin.Context) (serviceInfoPo *po.ServiceInfo, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	serviceInfoPo = &po.ServiceInfo{}
	trace := public.GetGinTraceContext(c)
	sqlStr := `SELECT *
			FROM gateway_service_info
			WHERE is_delete = 0
			AND service_name = ?`
	if err = settings.SqlxLogGet(trace, db, serviceInfoPo, sqlStr, serviceName); err != nil {
		if err == sql.ErrNoRows {
			return nil, ErrServiceNotExit
		} else {
			return nil, err
		}
	}
	return serviceInfoPo, nil
}

func (repo *serviceRepo) InsertServiceInfo(tx *sqlx.Tx, serviceInfo *po.ServiceInfo, c *gin.Context) (ID int64, err error) {
	sqlStr := `INSERT INTO gateway_service_info(
			load_type, service_name, service_desc, create_at, update_at, is_delete)
			values(?,?,?,?,?,?)`
	trace := public.GetGinTraceContext(c)
	ret, err := settings.SqlxLogTxExec(trace, tx, sqlStr,
		serviceInfo.LoadType,
		serviceInfo.ServiceName,
		serviceInfo.ServiceDesc,
		serviceInfo.CreatedAt,
		serviceInfo.UpdatedAt,
		serviceInfo.IsDelete)
	if err != nil {
		return 0, err
	}

	ID, err = ret.LastInsertId()
	if err != nil {
		return 0, err
	}
	return ID, err
}

func (repo *serviceRepo) DeleteServiceInfo(serviceInfoPo *po.ServiceInfo, c *gin.Context) (err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return err
	}

	trace := public.GetGinTraceContext(c)
	sqlStr := `UPDATE gateway_service_info
			SET is_delete = 1
			WHERE id = ?`
	if _, err = settings.SqlxLogExec(trace, db, sqlStr, serviceInfoPo.ID); err != nil {
		return err
	}
	return nil
}

func (repo *serviceRepo) UpdateServiceInfo(tx *sqlx.Tx, serviceInfo *po.ServiceInfo, c *gin.Context) (err error) {
	sqlStr := `UPDATE gateway_service_info
			SET service_desc = ?, update_at = ?
			WHERE id = ?`
	trace := public.GetGinTraceContext(c)
	_, err = settings.SqlxLogTxExec(trace, tx, sqlStr, serviceInfo.ServiceDesc, time.Now(), serviceInfo.ID)
	return err
}

// HTTPRule 相关持久化接口实现
// GetServiceHTTPRuleByID 根据 ID 查询一条 service_http_rule 数据
func (repo *serviceRepo) GetServiceHTTPRuleByID(ID int64, c *gin.Context,
) (httpRule *po.ServiceHTTPRule, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	httpRule = new(po.ServiceHTTPRule)
	trace := public.GetGinTraceContext(c)
	httpRuleSqlStr := `SELECT * FROM gateway_service_http_rule WHERE service_id=?`
	if err = settings.SqlxLogGet(trace, db, httpRule, httpRuleSqlStr, ID); err != nil {
		if err == sql.ErrNoRows {
			return nil, nil
		}
		return nil, err
	}

	return httpRule, nil
}

func (repo *serviceRepo) GetServiceHTTPRuleByRule(ruleType int, rule string, c *gin.Context) (httpRule *po.ServiceHTTPRule, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	httpRule = new(po.ServiceHTTPRule)
	trace := public.GetGinTraceContext(c)
	httpRuleSqlStr := `SELECT * FROM gateway_service_http_rule WHERE rule_type = ? AND rule=?`
	if err = settings.SqlxLogGet(trace, db, httpRule, httpRuleSqlStr, ruleType, rule); err != nil {
		if err == sql.ErrNoRows {
			return nil, err
		}
		return nil, err
	}

	return httpRule, nil
}

func (repo *serviceRepo) AddHTTPDetail(httpDetail *do.ServiceDetail, c *gin.Context) (err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return err
	}
	tx, err := db.Beginx()
	if err != nil {
		return err
	}

	// 插入 serviceInfo，并返回 ID
	ID, err := repo.InsertServiceInfo(tx, httpDetail.Info, c)
	if err != nil {
		tx.Rollback()
		return err
	}

	// 获取 ServiceID
	//httpDetail.Info, err = repo.GetServiceInfoByName(httpDetail.Info.ServiceName, c)
	//if err != nil {
	//	tx.Rollback()
	//	return err
	//}
	httpDetail.Info.ID = ID

	// 使用 ServiceID 插入其他表
	httpDetail.HTTPRule.ServiceID = httpDetail.Info.ID
	httpDetail.LoadBalance.ServiceID = httpDetail.Info.ID
	httpDetail.AccessControl.ServiceID = httpDetail.Info.ID

	// HTTPRule
	if err = repo.InsertServiceHTTPRule(tx, httpDetail.HTTPRule, c); err != nil {
		tx.Rollback()
		return err
	}

	// LoadBalance
	if err = repo.InsertServiceHTTPLoadBalance(tx, httpDetail.LoadBalance, c); err != nil {
		tx.Rollback()
		return err
	}

	// AccessControl
	if err = repo.InsertServiceHTTPAccessControl(tx, httpDetail.AccessControl, c); err != nil {
		tx.Rollback()
		return err
	}

	tx.Commit()

	return nil
}

// InsertServiceHTTPRule 事务插入一条 http_rule 数据
func (repo *serviceRepo) InsertServiceHTTPRule(tx *sqlx.Tx, httpRule *po.ServiceHTTPRule, c *gin.Context) (err error) {
	sqlStr := `INSERT INTO gateway_service_http_rule(
			service_id, rule_type, rule, need_https, need_strip_uri,
			need_websocket, url_rewrite, header_transfor)
			VALUES(?,?,?,?,?,?,?,?)`
	trace := public.GetGinTraceContext(c)

	if _, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		httpRule.ServiceID,
		httpRule.RuleType,
		httpRule.Rule,
		httpRule.NeedHTTPs,
		httpRule.NeedStripUri,
		httpRule.NeedWebsocket,
		httpRule.UrlRewrite,
		httpRule.HeaderTransfor); err != nil {
		return err
	}
	return nil
}

func (repo *serviceRepo) UpdateHTTPDetail(httpDetail *do.ServiceDetail, c *gin.Context) (err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return err
	}

	tx, err := db.Beginx()
	if err != nil {
		return err
	}

	// 更新 ServiceInfo
	if err = repo.UpdateServiceInfo(tx, httpDetail.Info, c); err != nil {
		tx.Rollback()
		return err
	}

	// 更新 HTTPRule
	if err = repo.UpdateHTTPRule(tx, httpDetail.HTTPRule, c); err != nil {
		tx.Rollback()
		return err
	}

	// 更新 LoadBalance
	if err = repo.UpdateHTTPLoadBalance(tx, httpDetail.LoadBalance, c); err != nil {
		tx.Rollback()
		return err
	}

	// 更新 AccessControl
	if err = repo.UpdateHTTPAccessControl(tx, httpDetail.AccessControl, c); err != nil {
		tx.Rollback()
		return err
	}

	tx.Commit()

	return nil
}

func (repo *serviceRepo) UpdateHTTPRule(tx *sqlx.Tx, serviceHTTPRule *po.ServiceHTTPRule, c *gin.Context) (err error) {
	sqlStr := `UPDATE gateway_service_http_rule
			SET need_https=?, need_strip_uri=?, need_websocket=?, url_rewrite=?, header_transfor=?
			WHERE service_id=?`
	trace := public.GetGinTraceContext(c)
	_, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		serviceHTTPRule.NeedHTTPs,
		serviceHTTPRule.NeedStripUri,
		serviceHTTPRule.NeedWebsocket,
		serviceHTTPRule.UrlRewrite,
		serviceHTTPRule.HeaderTransfor,
		serviceHTTPRule.ServiceID)
	return err
}

// TCPRule 相关持久化接口实现
// GetServiceTCPRuleByID 根据 ID 查询一条 service_tcp_rule 记录
func (repo *serviceRepo) GetServiceTCPRuleByID(ID int64, c *gin.Context,
) (tcpRule *po.ServiceTCPRule, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	tcpRule = new(po.ServiceTCPRule)
	trace := public.GetGinTraceContext(c)
	httpRuleSqlStr := `SELECT * FROM gateway_service_tcp_rule WHERE service_id=?`
	if err = settings.SqlxLogGet(trace, db, tcpRule, httpRuleSqlStr, ID); err != nil {
		if err == sql.ErrNoRows {
			return nil, nil
		}
		return nil, err
	}
	return tcpRule, nil
}

func (repo *serviceRepo) InsertServiceTCPRule(tx *sqlx.Tx, tcpRule *po.ServiceTCPRule, c *gin.Context) (err error) {
	sqlStr := `INSERT INTO gateway_service_tcp_rule(service_id, port)
			VALUES(?,?)`

	trace := public.GetGinTraceContext(c)
	if _, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		tcpRule.ServiceID,
		tcpRule.Port); err != nil {
		return err
	}
	return nil
}

func (repo *serviceRepo) AddTCPDetail(tcpDetail *do.ServiceDetail, c *gin.Context) (err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return err
	}

	tx, err := db.Beginx()
	if err != nil {
		return err
	}

	// 插入 ServiceInfo 并返回 ID
	ID, err := repo.InsertServiceInfo(tx, tcpDetail.Info, c)
	if err != nil {
		tx.Rollback()
		return err
	}

	tcpDetail.Info.ID = ID
	tcpDetail.TCPRule.ServiceID = ID
	tcpDetail.LoadBalance.ServiceID = ID
	tcpDetail.AccessControl.ServiceID = ID

	// 插入其他表
	// TCPRule
	if err = repo.InsertServiceTCPRule(tx, tcpDetail.TCPRule, c); err != nil {
		tx.Rollback()
		return err
	}

	// LoadBalance
	if err = repo.InsertServiceGRPCTCPLoadBalance(tx, tcpDetail.LoadBalance, c); err != nil {
		tx.Rollback()
		return err
	}

	// AccessControl
	if err = repo.InsertServiceGRPCTCPAccessControl(tx, tcpDetail.AccessControl, c); err != nil {
		tx.Rollback()
		return err
	}

	tx.Commit()

	return nil
}

func (repo *serviceRepo) UpdateTCPDetail(tcpDetail *do.ServiceDetail, c *gin.Context) (err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return err
	}

	tx, err := db.Beginx()
	if err != nil {
		return err
	}

	// 更新 ServiceInfo
	if err = repo.UpdateServiceInfo(tx, tcpDetail.Info, c); err != nil {
		tx.Rollback()
		return err
	}

	// 更新 TCPRule -> 没有可变更选项
	//if err = repo.UpdateTCPRule(tx, tcpDetail.TCPRule, c); err != nil {
	//	tx.Rollback()
	//	return err
	//}

	// 更新 LoadBalance
	if err = repo.UpdateGRPCTCPLoadBalance(tx, tcpDetail.LoadBalance, c); err != nil {
		tx.Rollback()
		return err
	}

	// 更新 AccessControl
	if err = repo.UpdateGRPCTCPAccessControl(tx, tcpDetail.AccessControl, c); err != nil {
		tx.Rollback()
		return err
	}

	tx.Commit()

	return nil
}

func (repo *serviceRepo) UpdateTCPRule(tx *sqlx.Tx, serviceTCPRule *po.ServiceTCPRule, c *gin.Context) (err error) {
	// TCPRule 里的数据都是不允许变更的
	return nil
}

func (repo *serviceRepo) GetServiceTCPRuleByPort(port int, c *gin.Context) (serviceTCPRule *po.ServiceTCPRule, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	trace := public.GetGinTraceContext(c)
	sqlStr := `SELECT * FROM gateway_service_tcp_rule
			WHERE port = ?`
	serviceTCPRule = &po.ServiceTCPRule{}
	if err = settings.SqlxLogGet(trace, db, serviceTCPRule, sqlStr, port); err != nil {
		return nil, err
	}

	return serviceTCPRule, nil
}

// GRPCRule 相关持久化接口实现
// GetServiceGRPCRuleByID 根据 ID 查询一条 Service
func (repo *serviceRepo) GetServiceGRPCRuleByID(ID int64, c *gin.Context,
) (grpcRule *po.ServiceGRPCRule, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	grpcRule = new(po.ServiceGRPCRule)
	trace := public.GetGinTraceContext(c)
	httpRuleSqlStr := `SELECT * FROM gateway_service_grpc_rule WHERE service_id=?`
	if err = settings.SqlxLogGet(trace, db, grpcRule, httpRuleSqlStr, ID); err != nil {
		if err == sql.ErrNoRows {
			return nil, nil
		}
		return nil, err
	}
	return grpcRule, nil
}

func (repo *serviceRepo) InsertServiceGRPCRule(tx *sqlx.Tx, grpcRule *po.ServiceGRPCRule, c *gin.Context) (err error) {
	sqlStr := `INSERT INTO gateway_service_grpc_rule(
			service_id, port, header_transfor)
			VALUES(?,?,?)`
	trace := public.GetGinTraceContext(c)
	if _, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		grpcRule.ServiceID,
		grpcRule.Port,
		grpcRule.HeaderTransfor); err != nil {
		return err
	}
	return nil
}

func (repo *serviceRepo) AddGRPCDetail(grpcDetail *do.ServiceDetail, c *gin.Context) (err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return err
	}

	tx, err := db.Beginx()
	if err != nil {
		return err
	}

	// 插入 ServiceInfo 并返回 ID
	ID, err := repo.InsertServiceInfo(tx, grpcDetail.Info, c)
	if err != nil {
		tx.Rollback()
		return err
	}

	grpcDetail.Info.ID = ID
	grpcDetail.GRPCRule.ServiceID = ID
	grpcDetail.LoadBalance.ServiceID = ID
	grpcDetail.AccessControl.ServiceID = ID

	// 插入其他表
	// GRPCRule
	if err = repo.InsertServiceGRPCRule(tx, grpcDetail.GRPCRule, c); err != nil {
		tx.Rollback()
		return err
	}

	// LoadBalance
	if err = repo.InsertServiceGRPCTCPLoadBalance(tx, grpcDetail.LoadBalance, c); err != nil {
		tx.Rollback()
		return err
	}

	// AccessControl
	if err = repo.InsertServiceGRPCTCPAccessControl(tx, grpcDetail.AccessControl, c); err != nil {
		tx.Rollback()
		return err
	}

	tx.Commit()

	return nil
}

func (repo *serviceRepo) UpdateGrpcDetail(grpcDetail *do.ServiceDetail, c *gin.Context) (err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return err
	}

	tx, err := db.Beginx()
	if err != nil {
		return err
	}

	// 更新 ServiceInfo
	if err = repo.UpdateServiceInfo(tx, grpcDetail.Info, c); err != nil {
		tx.Rollback()
		return err
	}

	// 更新 GRPCRule
	if err = repo.UpdateGRPCRule(tx, grpcDetail.GRPCRule, c); err != nil {
		tx.Rollback()
		return err
	}

	// 更新 LoadBalance
	if err = repo.UpdateGRPCTCPLoadBalance(tx, grpcDetail.LoadBalance, c); err != nil {
		tx.Rollback()
		return err
	}

	// 更新 AccessControl
	if err = repo.UpdateGRPCTCPAccessControl(tx, grpcDetail.AccessControl, c); err != nil {
		tx.Rollback()
		return err
	}

	tx.Commit()

	return nil
}

func (repo *serviceRepo) UpdateGRPCRule(tx *sqlx.Tx, serviceGRPCRule *po.ServiceGRPCRule, c *gin.Context) (err error) {
	sqlStr := `UPDATE gateway_service_grpc_rule
			SET header_transfor=?
			WHERE service_id=?`
	trace := public.GetGinTraceContext(c)
	_, err = settings.SqlxLogTxExec(trace, tx, sqlStr, serviceGRPCRule.HeaderTransfor, serviceGRPCRule.ServiceID)
	return err
}

func (repo *serviceRepo) GetServiceGRPCRuleByPort(port int, c *gin.Context) (serviceGRPCRUle *po.ServiceGRPCRule, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	trace := public.GetGinTraceContext(c)
	sqlStr := `SELECT * FROM gateway_service_grpc_rule
			WHERE port = ?`
	serviceGRPCRUle = &po.ServiceGRPCRule{}
	if err = settings.SqlxLogGet(trace, db, serviceGRPCRUle, sqlStr, port); err != nil {
		return nil, err
	}

	return serviceGRPCRUle, nil
}

// LoadBalance 相关持久化接口实现
// GetServiceLoadBalanceByID 根据 ID 查询一条 service_load_balance　记录
func (repo *serviceRepo) GetServiceLoadBalanceByID(ID int64, c *gin.Context,
) (loadBalance *po.ServiceLoadBalance, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	loadBalance = new(po.ServiceLoadBalance)
	trace := public.GetGinTraceContext(c)
	loadBalanceSqlStr := `SELECT * FROM gateway_service_load_balance WHERE service_id=?`
	if err = settings.SqlxLogGet(trace, db, loadBalance, loadBalanceSqlStr, ID); err != nil {
		if err == sql.ErrNoRows {
			return nil, nil
		}
		return nil, err
	}
	return loadBalance, nil
}

func (repo *serviceRepo) InsertServiceHTTPLoadBalance(tx *sqlx.Tx, loadBalance *po.ServiceLoadBalance, c *gin.Context) (err error) {
	sqlStr := `INSERT INTO gateway_service_load_balance(
			service_id, round_type, ip_list, weight_list,
			upstream_connect_timeout, upstream_header_timeout,
			upstream_idle_timeout, upstream_max_idle)
			VALUES(?,?,?,?,?,?,?,?)`
	trace := public.GetGinTraceContext(c)
	if _, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		loadBalance.ServiceID,
		loadBalance.RoundType,
		loadBalance.IPList,
		loadBalance.WeightList,
		loadBalance.UpStreamConnectTimeout,
		loadBalance.UpStreamHeaderTimeout,
		loadBalance.UpStreamIdleTimeout,
		loadBalance.UpStreamMaxIdle); err != nil {
		return err
	}
	return nil
}

func (repo *serviceRepo) UpdateHTTPLoadBalance(tx *sqlx.Tx, loadBalance *po.ServiceLoadBalance, c *gin.Context) (err error) {
	sqlStr := `UPDATE gateway_service_load_balance
			SET round_type=?, ip_list=?, weight_list=?,
			upstream_connect_timeout=?, upstream_header_timeout=?,
			upstream_idle_timeout=?, upstream_max_idle=?
			WHERE service_id = ?`
	trace := public.GetGinTraceContext(c)
	_, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		loadBalance.RoundType,
		loadBalance.IPList,
		loadBalance.WeightList,
		loadBalance.UpStreamConnectTimeout,
		loadBalance.UpStreamHeaderTimeout,
		loadBalance.UpStreamIdleTimeout,
		loadBalance.UpStreamMaxIdle,
		loadBalance.ServiceID)

	return err
}

func (repo *serviceRepo) InsertServiceGRPCTCPLoadBalance(tx *sqlx.Tx, loadBalance *po.ServiceLoadBalance, c *gin.Context) (err error) {
	sqlStr := `INSERT INTO gateway_service_load_balance(
			service_id, round_type, ip_list, weight_list, forbid_list)
			VALUES(?,?,?,?,?)`
	trace := public.GetGinTraceContext(c)
	if _, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		loadBalance.ServiceID,
		loadBalance.RoundType,
		loadBalance.IPList,
		loadBalance.WeightList,
		loadBalance.ForbidList); err != nil {
		return err
	}

	return nil
}
func (repo *serviceRepo) UpdateGRPCTCPLoadBalance(tx *sqlx.Tx, loadBalance *po.ServiceLoadBalance, c *gin.Context) (err error) {
	sqlStr := `UPDATE gateway_service_load_balance
			SET round_type=?, ip_list=?, weight_list=?, forbid_list=?
			WHERE service_id = ?`
	trace := public.GetGinTraceContext(c)
	_, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		loadBalance.RoundType,
		loadBalance.IPList,
		loadBalance.WeightList,
		loadBalance.ForbidList,
		loadBalance.ServiceID)

	return err
}

// AccessControl 相关持久化接口实现
// GetServiceAccessControllerByID 根据 ID 查询一条 service_access_control 记录
func (repo *serviceRepo) GetServiceAccessControllerByID(ID int64, c *gin.Context,
) (accessController *po.ServiceAccessControl, err error) {
	db, err := settings.GetDBPool("default")
	if err != nil {
		return nil, err
	}

	accessController = new(po.ServiceAccessControl)
	trace := public.GetGinTraceContext(c)
	accessControlSqlStr := `SELECT * FROM gateway_service_access_control WHERE service_id=?`
	if err = settings.SqlxLogGet(trace, db, accessController, accessControlSqlStr, ID); err != nil {
		if err == sql.ErrNoRows {
			return nil, nil
		}
		return nil, err
	}
	return accessController, nil
}

func (repo *serviceRepo) InsertServiceHTTPAccessControl(tx *sqlx.Tx, accessControl *po.ServiceAccessControl, c *gin.Context) (err error) {
	sqlStr := `INSERT INTO gateway_service_access_control(
			service_id, open_auth, black_list, white_list, clientip_flow_limit, service_flow_limit)
			VALUES(?,?,?,?,?,?)`
	trace := public.GetGinTraceContext(c)
	if _, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		accessControl.ServiceID,
		accessControl.OpenAuth,
		accessControl.BlackList,
		accessControl.WhiteList,
		accessControl.ClientIPFlowLimit,
		accessControl.ServiceFlowLimit); err != nil {
		return err
	}
	return nil
}

func (repo *serviceRepo) UpdateHTTPAccessControl(tx *sqlx.Tx, accessControl *po.ServiceAccessControl, c *gin.Context) (err error) {
	sqlStr := `UPDATE gateway_service_access_control
			SET open_auth=?, black_list=?, white_list=?, clientip_flow_limit=?, service_flow_limit=?
			WHERE service_id = ?`
	trace := public.GetGinTraceContext(c)
	_, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		accessControl.OpenAuth,
		accessControl.BlackList,
		accessControl.WhiteList,
		accessControl.ClientIPFlowLimit,
		accessControl.ServiceFlowLimit,
		accessControl.ServiceID)

	return err
}

func (repo *serviceRepo) InsertServiceGRPCTCPAccessControl(tx *sqlx.Tx, accessControl *po.ServiceAccessControl, c *gin.Context) (err error) {
	sqlStr := `INSERT INTO gateway_service_access_control(
			service_id, open_auth, black_list, white_list, clientip_flow_limit, service_flow_limit, white_host_name)
			VALUES(?,?,?,?,?,?,?)`
	trace := public.GetGinTraceContext(c)
	if _, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		accessControl.ServiceID,
		accessControl.OpenAuth,
		accessControl.BlackList,
		accessControl.WhiteList,
		accessControl.ClientIPFlowLimit,
		accessControl.ServiceFlowLimit,
		accessControl.WhiteHostName); err != nil {
		return err
	}
	return nil
}
func (repo *serviceRepo) UpdateGRPCTCPAccessControl(tx *sqlx.Tx, accessControl *po.ServiceAccessControl, c *gin.Context) (err error) {
	sqlStr := `UPDATE gateway_service_access_control
			SET open_auth=?, black_list=?, white_list=?, clientip_flow_limit=?, service_flow_limit=?, white_host_name=?
			WHERE service_id = ?`
	trace := public.GetGinTraceContext(c)
	_, err = settings.SqlxLogTxExec(trace, tx, sqlStr,
		accessControl.OpenAuth,
		accessControl.BlackList,
		accessControl.WhiteList,
		accessControl.ClientIPFlowLimit,
		accessControl.ServiceFlowLimit,
		accessControl.WhiteHostName,
		accessControl.ServiceID)

	return err
}


text:
DESCRIPTION = "ISCO BSP Filesystem Image Utilities"
SECTION = "BSP"
LICENSE = "Proprietary"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Proprietary;md5=0557f9d92cf58f2ccdd50f62f8ac0b28"
PR="r0"

SRC_URI += "file://uboot2emmc"
SRC_URI += "file://flashmmc"
SRC_URI += "file://mkmmcparts"
SRC_URI += "file://mkmmc2parts"
SRC_URI += "file://rootfs2parta"

# bbone: customized in recipes-ssangsto
#SRC_URI += "file://update-rootfs"
#SRC_URI += "file://update-kernel"
SRC_URI += "file://flash_all"

RDEPENDS_isco-fsutils := " \
    e2fsprogs-e2fsck \
    e2fsprogs-mke2fs \
    util-linux-sfdisk \
    dosfstools \
"

do_install() {
    install -d ${D}${sbindir}
    install -m 0700 ${WORKDIR}/uboot2emmc ${D}${sbindir}
    install -m 0744 ${WORKDIR}/flashmmc ${D}${sbindir}
    install -m 0744 ${WORKDIR}/mkmmcparts ${D}${sbindir}
    install -m 0744 ${WORKDIR}/mkmmc2parts ${D}${sbindir}
    install -m 0755 ${WORKDIR}/rootfs2parta ${D}${sbindir}
    install -m 0755 ${WORKDIR}/flash_all ${D}${sbindir}

	install -d ${D}${bindir}
#	install -m 0755 ${WORKDIR}/update-rootfs ${D}${bindir}
#	install -m 0755 ${WORKDIR}/update-kernel ${D}${bindir}
}

repository: swsangston/meta-ssangsto

repo_name: swsangston/meta-ssangsto


text:
/*
Copyright 2021 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package variables

import (
	"reflect"
	"testing"

	"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
	apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
	"k8s.io/apimachinery/pkg/util/validation/field"
	"k8s.io/utils/pointer"

	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

func Test_convertToAPIExtensionsJSONSchemaProps(t *testing.T) {
	defaultJSON := apiextensions.JSON(`defaultValue`)

	tests := []struct {
		name    string
		schema  *clusterv1.JSONSchemaProps
		want    *apiextensions.JSONSchemaProps
		wantErr bool
	}{
		{
			name: "pass for basic schema validation",
			schema: &clusterv1.JSONSchemaProps{
				Type:             "integer",
				Format:           "uri",
				MaxLength:        pointer.Int64(4),
				MinLength:        pointer.Int64(2),
				Pattern:          "abc.*",
				Maximum:          pointer.Int64(43),
				ExclusiveMaximum: true,
				Minimum:          pointer.Int64(1),
				ExclusiveMinimum: false,
			},
			want: &apiextensions.JSONSchemaProps{
				Type:             "integer",
				Format:           "uri",
				MaxLength:        pointer.Int64(4),
				MinLength:        pointer.Int64(2),
				Pattern:          "abc.*",
				Maximum:          pointer.Float64(43),
				ExclusiveMaximum: true,
				Minimum:          pointer.Float64(1),
				ExclusiveMinimum: false,
			},
		},
		{
			name: "pass for schema validation with enum & default",
			schema: &clusterv1.JSONSchemaProps{
				Example: &apiextensionsv1.JSON{
					Raw: []byte(`"defaultValue"`),
				},
				Default: &apiextensionsv1.JSON{
					Raw: []byte(`"defaultValue"`),
				},
				Enum: []apiextensionsv1.JSON{
					{Raw: []byte(`"enumValue1"`)},
					{Raw: []byte(`"enumValue2"`)},
				},
			},
			want: &apiextensions.JSONSchemaProps{
				Default: &defaultJSON,
				Example: &defaultJSON,
				Enum: []apiextensions.JSON{
					`enumValue1`,
					`enumValue2`,
				},
			},
		},
		{
			name: "fail for schema validation with default value with invalid JSON",
			schema: &clusterv1.JSONSchemaProps{
				Default: &apiextensionsv1.JSON{
					Raw: []byte(`defaultValue`), // missing quotes
				},
			},
			wantErr: true,
		},
		{
			name: "pass for schema validation with object",
			schema: &clusterv1.JSONSchemaProps{
				Properties: map[string]clusterv1.JSONSchemaProps{
					"property1": {
						Type:    "integer",
						Minimum: pointer.Int64(1),
					},
					"property2": {
						Type:      "string",
						Format:    "uri",
						MinLength: pointer.Int64(2),
						MaxLength: pointer.Int64(4),
					},
				},
			},
			want: &apiextensions.JSONSchemaProps{
				Properties: map[string]apiextensions.JSONSchemaProps{
					"property1": {
						Type:    "integer",
						Minimum: pointer.Float64(1),
					},
					"property2": {
						Type:      "string",
						Format:    "uri",
						MinLength: pointer.Int64(2),
						MaxLength: pointer.Int64(4),
					},
				},
			},
		},
		{
			name: "pass for schema validation with map",
			schema: &clusterv1.JSONSchemaProps{
				AdditionalProperties: &clusterv1.JSONSchemaProps{
					Properties: map[string]clusterv1.JSONSchemaProps{
						"property1": {
							Type:    "integer",
							Minimum: pointer.Int64(1),
						},
						"property2": {
							Type:      "string",
							Format:    "uri",
							MinLength: pointer.Int64(2),
							MaxLength: pointer.Int64(4),
						},
					},
				},
			},
			want: &apiextensions.JSONSchemaProps{
				AdditionalProperties: &apiextensions.JSONSchemaPropsOrBool{
					Allows: true,
					Schema: &apiextensions.JSONSchemaProps{
						Properties: map[string]apiextensions.JSONSchemaProps{
							"property1": {
								Type:    "integer",
								Minimum: pointer.Float64(1),
							},
							"property2": {
								Type:      "string",
								Format:    "uri",
								MinLength: pointer.Int64(2),
								MaxLength: pointer.Int64(4),
							},
						},
					},
				},
			},
		},
		{
			name: "pass for schema validation with array",
			schema: &clusterv1.JSONSchemaProps{
				Items: &clusterv1.JSONSchemaProps{
					Type:      "integer",
					Minimum:   pointer.Int64(1),
					Format:    "uri",
					MinLength: pointer.Int64(2),
					MaxLength: pointer.Int64(4),
				},
			},
			want: &apiextensions.JSONSchemaProps{
				Items: &apiextensions.JSONSchemaPropsOrArray{
					Schema: &apiextensions.JSONSchemaProps{
						Type:      "integer",
						Minimum:   pointer.Float64(1),
						Format:    "uri",
						MinLength: pointer.Int64(2),
						MaxLength: pointer.Int64(4),
					},
				},
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, errs := convertToAPIExtensionsJSONSchemaProps(tt.schema, field.NewPath(""))
			if tt.wantErr {
				if len(errs) == 0 {
					t.Errorf("convertToAPIExtensionsJSONSchemaProps() error = %v, wantErr %v", errs, tt.wantErr)
				}
				return
			}
			if !reflect.DeepEqual(got, tt.want) {
				t.Errorf("convertToAPIExtensionsJSONSchemaProps() got = %v, want %v", got, tt.want)
			}
		})
	}
}

repository: kubernetes-sigs/cluster-api

repo_name: kubernetes-sigs/cluster-api

branch_name: refs/heads/main


text:
package sysgo

import (
	"fmt"
	"math"
	_ "math/rand"
	"sync"
)

//go:generate stringer -type simInternalEvent
//go:generate stringer -type simChanType

type simInternalEvent uint32
const (
	blockRun simInternalEvent = 1 << iota
	blockComplete
	blockProgress
	blockWait
	blockError
	delayWait
	updateRegisters
	registerUpdateComplete
	propagateWireValues
	wirePropagateComplete
	simFinish
	allEvents = 0xffffffff
)

type simChanType uint32
const (
	module simChanType = 1 << iota
	initializer
	sensitivity
	allChanTypes = 0xffffffff
)

type eventCounts struct {
	module uint32
	initializer uint32
	sensitivity uint32
}

type simEventAndId struct {
	e simInternalEvent
	id int
}

type SimChanPair struct {
	send chan simEventAndId // Send from module/initializer/etc. to simulator
	recv chan simInternalEvent // Receive by module/initializer/etc.
	id int
	chanType simChanType
	valid bool
	data interface{}
	dataMutex sync.Mutex
}

// Blocking send to simulator
func (A *SimChanPair) Send(e simInternalEvent) {
	A.send <- simEventAndId{e: e, id: A.id}
}

// Non-blocking send to simulator
func (A *SimChanPair) SendNB(e simInternalEvent) {
	select {
	case A.send <- simEventAndId{e: e, id: A.id}:
	default:
	}
}

func (A *SimChanPair) Recv(eventMask simInternalEvent) simInternalEvent {
	for {
		event, ok := <- A.recv
		if !ok {
			close(A.recv)
			return simFinish
		} else {
			if event & eventMask > 0 {
				return event
			}
		}
	}
}

type Simulator struct {
	timescale float64
	precision float64
	modules []*Module

	simTime uint64
	simTimeMutex sync.Mutex

	// Internal simulator event channels
	simRecvChan chan simEventAndId
	simChans []*SimChanPair
	simChansMutex sync.Mutex
	simChanCounts map[simChanType]uint

	eventCounts map[simInternalEvent]uint

	runnersWG *sync.WaitGroup

	numInitBlocks uint32
	numSenseClauses uint32
}

// Make sure there is only a single simulator instance using sync.Once
var simulator *Simulator
var once sync.Once

func GetSimulator() *Simulator {
    once.Do(func() {
        simulator = &Simulator{}
    })
    return simulator
}

func (A *Simulator) Initialize(timescale, precision float64) {
	A.timescale = timescale
	A.precision = precision
	A.modules = make([]*Module, 0, 10)
	A.simRecvChan = make(chan simEventAndId)
	A.simChans = make([]*SimChanPair, 0, 10)
	A.simChanCounts = make(map[simChanType]uint)

	A.simChanCounts[module] = uint(0)
	A.simChanCounts[initializer] = uint(0)
	A.simChanCounts[sensitivity] = uint(0)

	A.eventCounts = make(map[simInternalEvent]uint)
}

// This should only be called once per *TOP-LEVEL* module
func (A *Simulator) RegisterModule(m *Module) {
	A.modules = append(A.modules, m)

	// Figure out the total # of initializer and procedural blocks
	n, s := m.getNumBlocks()
	A.numInitBlocks += n
	A.numSenseClauses += s
}

func (A *Simulator) RegisterChannelPair(cp *SimChanPair) {
	cp.id = len(A.simChans)
	cp.send = A.simRecvChan
	A.simChansMutex.Lock()
	defer A.simChansMutex.Unlock()

	A.simChans = append(A.simChans, cp)
	A.simChans[cp.id].valid = true
	A.simChanCounts[cp.chanType]++
}

func (A *Simulator) UnregisterChannelPair(chanId int) {
	A.simChansMutex.Lock()
	defer A.simChansMutex.Unlock()

	A.simChanCounts[A.simChans[chanId].chanType]--
	A.simChans[chanId].send = nil
	A.simChans[chanId].valid = false
	A.simChans[chanId].id = -1
	close(A.simChans[chanId].recv)
}

func (A *Simulator) Run() {
	A.simTime = 0
	/* Order of operations:
           1. Go through all initialize clauses and fire them off, each into it's own go routine
           2. Setup go routines for all sensitivity clauses with channels to each for event broadcast.
           3. (Except on iteration 0) Update all registers currentValue <- nextValue, keeping track of what's changed
           4. Update all wires, by propagating driver values to receivers, keeping track of what's changed.
           5. Determine active clauses based on registers/wires that have changed and send events to each go routine.

        */

	blockReadyWG := new(sync.WaitGroup)
	A.runnersWG = new(sync.WaitGroup)

	blockReadyWG.Add(int(A.numInitBlocks + A.numSenseClauses))
	A.runnersWG.Add(1)

	go A.spawnRunners(blockReadyWG)

	blockReadyWG.Wait()

	// Main event coordination loop
	for finish := false; !finish; {
		// May need a mutex on simChanCounts
		expEventCount := A.simChanCounts[initializer] + A.simChanCounts[sensitivity]

		chanIds := A.sendEvent(initializer | sensitivity, blockRun, true)
		A.waitForResponses(chanIds, blockProgress | blockWait | blockComplete | delayWait | simFinish, expEventCount)

		finish = A.getEventCounts(simFinish) > 0
		delayCount := A.getEventCounts(delayWait)
		blockWaitCount := A.getEventCounts(blockWait)

		chanIds = A.sendEvent(module, updateRegisters, true)
		A.waitForResponses(chanIds, registerUpdateComplete, A.simChanCounts[module])

		chanIds = A.sendEvent(module, propagateWireValues, true)
		A.waitForResponses(chanIds, wirePropagateComplete, A.simChanCounts[module])

		// Increment simTime if everything is just waiting
		if (delayCount + blockWaitCount) == expEventCount {
			// Find the minimum target time and fast-forward
			min := uint64(0xffffffffffffffff)
			for _, cp := range A.simChans {
				if cp.valid {
					cp.dataMutex.Lock()
					switch d := cp.data.(type) {
					case nil:
					case uint64:
						tt := d
						if tt > 0 && tt < min {
							min = tt
						}
					}
					cp.dataMutex.Unlock()
				}
			}
			// fmt.Printf("Fast-forwarding to %d\n", min)
			A.simTimeMutex.Lock()
			A.simTime = min
			A.simTimeMutex.Unlock()
		}
	}

	fmt.Printf("Simulator: out of main event loop.\n")

	A.sendEvent(allChanTypes, simFinish, true)

	A.runnersWG.Wait()
}

func (A *Simulator) initEventCounts() {
	for i := blockRun; i <= simFinish; i = i << 1 {
		A.eventCounts[i] = 0
	}
}

func (A *Simulator) getEventCounts(e simInternalEvent) (n uint) {
	n = 0
	if _, ok := A.eventCounts[e]; ok {
		n = A.eventCounts[e]
	}
	return
}

func (A *Simulator) spawnRunners(blockReadyWG *sync.WaitGroup) {
	defer A.runnersWG.Done()

	wg := new(sync.WaitGroup)
	wg.Add(len(A.modules))

	// Spawn all module runners
	for _, m := range A.modules {
		go m.run(wg, blockReadyWG)
	}

	wg.Wait()
}

func newSimChannelPair(t simChanType) (cp *SimChanPair) {
	cp = new(SimChanPair)
	cp.send = nil
	cp.recv = make(chan simInternalEvent, 1)
	cp.chanType = t

	return
}

func (A *Simulator) sendEvent(chanMask simChanType, e simInternalEvent, blocking bool) (c []int) {
	c = make([]int, 0, 2)
	A.simChansMutex.Lock()
	defer A.simChansMutex.Unlock()
	for _, cp := range A.simChans {
		if cp.valid && (cp.chanType & chanMask > 0) {
			if blocking {
				cp.recv <- e
			} else {
				select {
				case cp.recv <- e:
				default:
				}
			}
			c = append(c, cp.id)
		}
	}
	return
}

func (A *Simulator) waitForResponses(chanIds []int, eventMask simInternalEvent, minCount uint) {
	A.initEventCounts()
	for e := range A.simRecvChan {
		in := -1
		for i, id := range chanIds {
			if e.id == id {
				in = i
				break
			}
		}

		if (in >= 0) && (e.e & eventMask > 0) {
			A.eventCounts[e.e]++
			chanIds = append(chanIds[:in], chanIds[in+1:]...)
			if len(chanIds) == 0 {
				break
			}
		}
	}
}

/*
    Waits until the simulator proceeds from the current simTime to
    simTime + d. Returns true if it waited for the entire delay or false
    if a simFinish event occurred during the delay.
*/
func Delay(cp *SimChanPair, d float64) bool {
	sim := GetSimulator()

	sim.simTimeMutex.Lock()
	simTime := sim.simTime
	sim.simTimeMutex.Unlock()

	// Compute target time by rounding the delay

	targetTime := uint64(math.Floor(d * (sim.timescale / sim.precision) + 0.5)) + simTime

	// Catch corner cases
	if targetTime == simTime {
		return true
	}

	// Send a delayWait event
	cp.dataMutex.Lock()
	cp.data = targetTime
	cp.dataMutex.Unlock()
	cp.Send(delayWait)

	// Now wait until the correct timestep
	for {
		e := cp.Recv(blockRun | simFinish)
		switch e {
		case simFinish:
			return false
		case blockRun:
			sim.simTimeMutex.Lock()
			if sim.simTime >= targetTime {
				sim.simTimeMutex.Unlock()
				cp.dataMutex.Lock()
				cp.data = uint64(0)
				cp.dataMutex.Unlock()
				return true
			} else {
				cp.Send(delayWait)
			}
			sim.simTimeMutex.Unlock()
		}
	}
}

func SimTime() uint64 {
	sim := GetSimulator()
	sim.simTimeMutex.Lock()
	simTime := sim.simTime
	sim.simTimeMutex.Unlock()

	return simTime
}

repository: ndrego/sysgo

repo_name: ndrego/sysgo