Ejemplo n.º 1
0
void comp_temps() {
	// If the product temperature is below the threshold, stop pumping heat
	if (temps[0] <= desired_product_temp) {
		printf("COLD!\n");
		// Set the outputs to the heatpump relays to open
		allOFF();
		// Keep the fans running
		turnON(FANS);
	} else {
		printf("WARM!\n");
		// Cycle through the heatpumps
		int i;
		for (i = 1; i < 5; ++i)
		{
			// If the pump is too hot, turn it off, start cooldown
			if (temps[i] >= PUMPHT) {
				turnOFF(heats[i-1]);
			} else {
				// Otherwise turn the pump on
				printf("%d:%f\n",i,temps[i]);
				turnON(heats[i-1]);
			}
		}
	}

}
Ejemplo n.º 2
0
void memoryAcessControl(uint64_t ir){
    if ((ir != 10)&&(ir>=1)&&(ir<=12)){
        turnON(READMEM_FLAG);
    }else if (ir == 33){
        turnON(WRITEMEM_FLAG);
        setReg(MSK, 0);
    }else if (ir == 18){
        turnON(WRITEMEM_FLAG);
        setReg(MSK, LCLEAN);
    }else if (ir == 19){
        turnON(WRITEMEM_FLAG);
        setReg(MSK, RCLEAN);
    }
}
Ejemplo n.º 3
0
int main (int argc, char *argv[]) {
	// Bind the clean-up function to program exit
	atexit(dbmsg_disconnect);


///////////////////////////////////////////////////////////////////////////////
	if (argc < 2) {
		// Initialize the controller
		init_local();
		// Determine heater posture based on current readings
		comp_temps();
		
///////////////////////////////////////////////////////////////////////////////
	} else {
		// Initialize the web controller
		init_web();
		// One time variables
		devStat state;
		int pin = 5;
		// Parse the input parameters
		while ((argc > 1) && (argv[1][0] == '-')) {
			switch (argv[1][1]) {
			case 'h':		// Heater
				pin = (int)argv[1][2] - '1';
				break;
			case 'f':		// Fan
				pin = 4;
				break;
			case 'r':		// Run
				state = ON;
				break;
			case 's':		// Stop
				state = OFF;
				break;
			case 'a':		// All on
				allON();
				return 0;
			case 'x':		// All stop
				allOFF();
				return 0;
			case 't':
				desired_product_temp = get_desired_temp();
				return 0;
			default:
				printf("Invalid parameters\n");
				display_help();
				return 0;
			}
			++argv;
			--argc;
		}
		if (state == OFF) {
			turnOFF(heats[pin]);
		} else {
			turnON(heats[pin]);
		}
	}

	return 0;
}
Ejemplo n.º 4
0
void allON() {
	// Turn each pin ON
	int i;
	for (i = 0; i < 5; i++) {
		turnON(heats[i]);
	}

	return;
}
Ejemplo n.º 5
0
void branchControl(uint64_t ir){
    if(ir == 0){
        turnON(END_FLAG);
    }else if ((ir == 13)||(ir == 14)){
        turnON(FETCH_FLAG);
        if(ir == 14){
            turnON(JMPR_FLAG);            
        }
        setReg(PC,getReg(MAR));
    }else if ((ir == 15)||(ir == 16)){
        if(getReg(MBR) == 0){        
            turnON(FETCH_FLAG);
            if(ir == 16){
                turnON(JMPR_FLAG);            
            }
            setReg(PC,getReg(MAR));
        }
    }
}
Ejemplo n.º 6
0
void fetchCycle(){
    if(isON(FETCH_FLAG)){
        fetch();
    if(isOFF(JMPR_FLAG)){
            decodeL();
            turnOFF(FETCH_FLAG);
        }else{
            decodeR(MBR);
            turnOFF(JMPR_FLAG);
        }       
    }else{
        decodeR(IBR);
        turnON(FETCH_FLAG);        
    }

}