Ejemplo n.º 1
0
PICComponent::PICComponent( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "pic" )
{
	m_name = i18n("PIC Micro");
	
	if ( _def_PICComponent_fileName.isEmpty() )
		_def_PICComponent_fileName = i18n("<Enter location of PIC Program>");
	
	m_bCreatedInitialPackage = false;
	m_bLoadingProgram = false;
	m_pGpsim = 0L;
	
	addButton( "run", QRect(), KIcon( "media-playback-start" ) );
	addButton( "pause", QRect(), KIcon( "media-playback-pause" ) );
	addButton( "reset", QRect(), KIcon( "process-stop" ) );
	addButton( "reload", QRect(), KIcon( "view-refresh" ) );
	
	connect( KTechlab::self(), SIGNAL(recentFileAdded(const KUrl &)), this, SLOT(slotUpdateFileList()) );
	
	connect( ProjectManager::self(),	SIGNAL(projectOpened()),		this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(projectClosed()),		this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(projectCreated()),		this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(subprojectCreated()),	this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(filesAdded()),			this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(filesRemoved()),			this, SLOT(slotUpdateFileList()) );
	
	createProperty( "program", Variant::Type::FileName );
	property("program")->setCaption( i18n("Program") );
	QString filter;
	filter = QString("*.flowcode *.cod *.asm *.basic *.c|%1").arg(i18n("All Supported Files"));
	filter += QString("\n*.flowcode|FlowCode (*.flowcode)");
	filter += QString("\n*.cod|%1 (*.cod)").arg(i18n("Symbol File"));
	filter += QString("\n*.asm|%1 (*.asm)").arg(i18n("Assembly Code"));
	filter += QString("\n*.basic *.microbe|Microbe (*.basic, *.microbe)");
	filter += QString("\n*.c|C (*.c)");
	filter += QString("\n*|%1").arg(i18n("All Files"));
	property("program")->setFilter( filter );
	
	// Used for restoring the pins on file loading before we have had a change
	// to compile the PIC program
	createProperty( "lastPackage", Variant::Type::String );
	property("lastPackage")->setHidden( true );
	
// 	//HACK This is to enable loading with pre-0.3 files (which didn't set a "lastPackage"
// 	// property). This will allow a P16F84 PIC to be initialized (which agrees with pre-0.3
// 	// behaviour), but it will also load it if
	
	// This to allow loading of the PIC component from pre-0.3 files (which didn't set a
	// "lastPackage" property).
	if ( !newItem )
		property("lastPackage")->setValue("P16F84");
	
	slotUpdateFileList();
	slotUpdateBtns();
	
	initPackage( 0 );
}
Ejemplo n.º 2
0
void sendAck(char * data, uip_ipaddr_t * ip) {
	static iptable_t * ipt;
	static char * pack;
	pack = initPackage(buf, ACKNOWLEDGE_M);
	memcpy(pack,data,RID_SIZE);
	if( ipt = findTableByIp(ip) ) {
		sendPackageByTable(data, PACKAGE_HEAD+RID_SIZE, ipt);
	}
}
Ejemplo n.º 3
0
void PICComponent::initPIC( bool forceReload )
{
	if ( !m_bCreatedInitialPackage )
	{
        qDebug() << Q_FUNC_INFO << " creating initial package";
		// We are still being created, so other connectors will be expecting us to
		// have grown pins soonish.
		MicroInfo * microInfo = MicroLibrary::self()->microInfoWithID( dataString("lastPackage") );
		if ( microInfo ) {
			initPackage( microInfo );
        } else {
            qDebug() << Q_FUNC_INFO << " unknown last package: " << dataString("lastPackage");
        }
	}
	
	QString newProgram = KUrl( dataString("program") ).path();
    qDebug() << Q_FUNC_INFO << "newProgram=" << newProgram;
	bool newFile = (m_picFile != newProgram);
	if ( !newFile && !forceReload ) {
        qDebug() << Q_FUNC_INFO << "not new program, not force reload, exiting";
		return;
    }
	
	delete m_pGpsim;
	m_pGpsim = 0L;
	
	switch ( GpsimProcessor::isValidProgramFile(newProgram) )
	{
		case GpsimProcessor::DoesntExist:
			if ( newProgram == _def_PICComponent_fileName && !newProgram.isEmpty() )
				break;
			KMessageBox::sorry( 0l, i18n("The file \"%1\" does not exist.", newProgram ) );
			m_picFile = QString::null;
			break;
			
		case GpsimProcessor::IncorrectType:
			if ( newProgram == _def_PICComponent_fileName && !newProgram.isEmpty() )
				break;
			KMessageBox::sorry( 0L, i18n("\"%1\" is not a valid PIC program.\nThe file must exist, and the extension should be \".cod\", \".asm\", \".flowcode\", \".basic\", \".microbe\" or \".c\".\n\".hex\" is allowed, provided that there is a corresponding \".cod\" file.", newProgram) );
			m_picFile = QString::null;
			break;
			
		case GpsimProcessor::Valid:
			m_picFile = newProgram;
			m_symbolFile = createSymbolFile();
			break;
	}
	
	slotUpdateBtns();
}
Ejemplo n.º 4
0
void PICComponent::slotCODCreationSucceeded()
{
    qDebug() << Q_FUNC_INFO << " m_symbolFile=" << m_symbolFile;
	m_bLoadingProgram = false;
	
	delete m_pGpsim;
	m_pGpsim = new GpsimProcessor(m_symbolFile);
	
	if ( m_pGpsim->codLoadStatus() == GpsimProcessor::CodSuccess )
	{
		MicroInfo * microInfo = m_pGpsim->microInfo();
		if(!microInfo){
			// FIXME we should be select somehow the type of the PIC. this is only a stability hack.
			kWarning() << k_funcinfo << "cannot identify the PIC, defaulting to P16F84" << endl;
			microInfo = MicroLibrary::self()->microInfoWithID("P16F84");
		}
		property("lastPackage")->setValue( microInfo->id() );
		initPackage( microInfo );
		
		connect( m_pGpsim, SIGNAL(runningStatusChanged(bool )), this, SLOT(slotUpdateBtns()) );
		attachPICComponentPins();
	}
Ejemplo n.º 5
0
//----------------------------------------------------------------------------
// getPkgOrder(): 	Gets the packages order from cin and stores them in a
// 					dynamic array.
// Input:          	None
// Output:         	None
//----------------------------------------------------------------------------
void Factory::getPkgOrder() {
    Package tempPkg;
    tempPkg = initPackage(tempPkg);

    string junk;

    cin >> junk;
    while (junk == "Package")
    {
        cin >> junk;
        cin >> junk;
        cin >> tempPkg.order_number;
        cin >> junk;
        cin >> tempPkg.unit_number;;
        cin >> junk;
        cin >> junk;
        cin >> junk;
        cin >> junk;
        cin >> tempPkg.time_Arrived;
        packageBufferQ.enqueue(tempPkg);
        pkgCount++;
        cin >> junk;
    }
}
Ejemplo n.º 6
0
void announceMe() {
	char * pack = initPackage(buf, ANNOUNCEMENT_M);
	memcpy(pack, myIp, sizeof(uip_ipaddr_t));
	strncpy(pack + sizeof(uip_ipaddr_t), myName, NAME_SIZE);
	SharePackage(buf, PACKAGE_HEAD+sizeof(uip_ipaddr_t)+NAME_SIZE);
}
Ejemplo n.º 7
0
void sendIpRequest(uip_ipaddr_t * ip) {
	char * pack = initPackage(buf, IP_REQUEST_M);
	memcpy(pack, ip, sizeof(uip_ipaddr_t));
	SharePackage(buf, PACKAGE_HEAD+sizeof(uip_ipaddr_t));
}
Ejemplo n.º 8
0
void sendNameRequest(char * name) {
	char * pack = initPackage(buf, NAME_REQUEST_M);
	strncpy(pack, name, NAME_SIZE);
	SharePackage(buf, PACKAGE_HEAD+NAME_SIZE);
}