testpin.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2003-2004 by David Saxton                               *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
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 

Generated on Tue May 8 17:05:32 2007 for KTechLab by  doxygen 1.5.1