00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "testpin.h"
00012
00013 #include "libraryitem.h"
00014 #include "flowcode.h"
00015
00016 #include <klocale.h>
00017
00018 Item* TestPin::construct( ItemDocument *itemDocument, bool newItem, const char *id )
00019 {
00020 return new TestPin( (ICNDocument*)itemDocument, newItem, id );
00021 }
00022
00023 LibraryItem* TestPin::libraryItem()
00024 {
00025 return new LibraryItem(
00026 QString("flow/testpin"),
00027 i18n("Test Pin State"),
00028 i18n("I\\/O"),
00029 "pinread.png",
00030 LibraryItem::lit_flowpart,
00031 TestPin::construct );
00032 }
00033
00034 TestPin::TestPin( ICNDocument *icnDocument, bool newItem, const char *id )
00035 : FlowPart( icnDocument, newItem, (id) ? id : "testpin" )
00036 {
00037 m_name = i18n("Test Pin State");
00038 m_desc = i18n("Conditional branch point, depending on the high/low state of a pin.");
00039 initDecisionSymbol();
00040 createStdInput();
00041 createStdOutput();
00042 createAltOutput();
00043
00044 createProperty( "pin", Variant::Type::Pin );
00045 property("pin")->setCaption( i18n("Pin") );
00046 property("pin")->setValue("RA0");
00047
00048 addDisplayText( "output_false", QRect( offsetX()+width(), 2, 40, 20 ), "Low" );
00049 addDisplayText( "output_true", QRect( 0, offsetY()+height(), 50, 20 ), "High" );
00050 }
00051
00052
00053 TestPin::~TestPin()
00054 {
00055 }
00056
00057
00058 void TestPin::dataChanged()
00059 {
00060 setCaption( "Test " + dataString("pin") );
00061 }
00062
00063
00064 void TestPin::generateMicrobe( FlowCode *code )
00065 {
00066 const QString pin = dataString("pin");
00067 const QString port = "PORT" + QString((QChar)pin[1]);
00068 const QString bit = (QChar)pin[2];
00069
00070 handleIfElse( code, port+"."+bit+" is high", port+"."+bit+" is low", "stdoutput", "altoutput" );
00071
00072 #if 0
00073 QString newCode;
00074
00075 newCode += "btfss "+port+","+bit+" ; Check if pin is clear\n";
00076 newCode += gotoCode("altoutput") + " ; Pin is low\n";
00077 newCode += gotoCode("stdoutput") + " ; Pin is high, continue on from this point\n";
00078
00079 code->addCodeBlock( id(), newCode );
00080 #endif
00081 }
00082
00083