Example #1
0
GtkWidget *createResultPopUp ( void )
{
  GtkWidget *dialog = gtk_dialog_new_with_buttons ("Resultat",
      (GtkWindow*) app,
      GTK_DIALOG_MODAL,
      GTK_STOCK_OK,
      GTK_RESPONSE_ACCEPT,
      NULL);
 
  //Create labels
  GtkWidget *vbox = GTK_DIALOG(dialog)->vbox;

  gchar power[1024];
  sprintf(power, "Effekt: %.2f W", getPower());
  GtkWidget *lPower = gtk_label_new(power);
  gtk_container_add(GTK_CONTAINER(vbox), lPower);

  gchar totRes[1024];
  sprintf(totRes, "Ersättningsresistans: %.2f ohm", getResistance());
  GtkWidget *lRes = gtk_label_new(totRes);
  gtk_container_add(GTK_CONTAINER(vbox), lRes);

  gchar comp[1024];
  sprintf(comp, "Ersättningsresistanser i E12-serien kopplade i serie: %s", getComponentStr());
  GtkWidget *lComp = gtk_label_new(comp);
  gtk_container_add(GTK_CONTAINER(vbox), lComp);

  gtk_widget_show_all( GTK_WIDGET (GTK_DIALOG (dialog)->vbox ) );
  
  return dialog;
}
Example #2
0
float getTemperatureC(Thermistor *thermistor) {
	chDbgCheck(initialized, "initialized");
	float resistance = getResistance(thermistor);

	float kelvinTemperature = getKelvinTemperature(resistance, thermistor->config);
	return convertKelvinToC(kelvinTemperature);
}
Example #3
0
/*---------------------------------------------------------------------------*/
float calc_resistance(int count, char conn, float *array)
{
  const int ERROR_CODE = -1;

  if (!validParamsSupplied(count, conn, array))
  {
    return ERROR_CODE;
  }

  return getResistance(count, conn, array);
}
Example #4
0
static void printTemperatureInfo(void) {
	printThermistor("CLT", &engineConfiguration2->clt);
	printThermistor("IAT", &engineConfiguration2->iat);

	float rClt = getResistance(&engineConfiguration2->clt);
	float rIat = getResistance(&engineConfiguration2->iat);

#if EFI_PROD_CODE
	int cltChannel = engineConfiguration2->clt.channel;
	scheduleMsg(&logger, "CLT R=%f on channel %d@%s", rClt, cltChannel,
			getPinNameByAdcChannel(cltChannel, pinNameBuffer));
	int iatChannel = engineConfiguration2->iat.channel;
	scheduleMsg(&logger, "IAT R=%f on channel %d@%s", rIat, iatChannel,
			getPinNameByAdcChannel(iatChannel, pinNameBuffer));

	scheduleMsg(&logger, "cranking fuel %fms @ %fC", engineConfiguration->crankingSettings.fuelAtMinTempMs,
			engineConfiguration->crankingSettings.coolantTempMinC);
	scheduleMsg(&logger, "cranking fuel %fms @ %fC", engineConfiguration->crankingSettings.fuelAtMaxTempMs,
			engineConfiguration->crankingSettings.coolantTempMaxC);
#endif
}
Example #5
0
static void printThermistor(char *msg, Thermistor *thermistor) {
	int adcChannel = thermistor->channel;
	float voltage = getVoltageDivided(adcChannel);
	float r = getResistance(thermistor);

	float t = getTemperatureC(thermistor);

	scheduleMsg(&logger, "%s v=%f C=%f R=%f on channel %d", msg, voltage, t, r, adcChannel);
	scheduleMsg(&logger, "bias=%f A=%f B=%f C=%f", thermistor->config->bias_resistor, thermistor->config->s_h_a,
			thermistor->config->s_h_b, thermistor->config->s_h_c);
#if EFI_PROD_CODE
	scheduleMsg(&logger, "@%s", getPinNameByAdcChannel(adcChannel, pinNameBuffer));
#endif
}
Example #6
0
static void printThermistor(const char *msg, ThermistorConf *config, ThermistorMath *tm) {
	thermistor_curve_s * curve = &tm->curve;
	adc_channel_e adcChannel = config->adcChannel;
	float voltage = getVoltageDivided("term", adcChannel);
	float r = getResistance(config);

	float t = getTemperatureC(config, tm);

	thermistor_conf_s *tc = &config->config;

	scheduleMsg(&logger, "%s volts=%f Celsius=%f sensorR=%f on channel %d", msg, voltage, t, r, adcChannel);
	scheduleMsg(&logger, "@%s", getPinNameByAdcChannel(adcChannel, pinNameBuffer));
	scheduleMsg(&logger, "C=%f/R=%f C=%f/R=%f C=%f/R=%f",
			tc->tempC_1, tc->resistance_1,
			tc->tempC_2, tc->resistance_2,
			tc->tempC_3, tc->resistance_3);

	scheduleMsg(&logger, "bias resistor=%fK A=%..100000f B=%..100000f C=%..100000f", tc->bias_resistor / 1000,
			curve->s_h_a, curve->s_h_b, curve->s_h_c);
	scheduleMsg(&logger, "==============================");
}
Example #7
0
bool Entity::damage(Entity *Victim, bool PhysicalAttack, long Amount, long DmgClass, long CureClass){

	char Text[128];
	float Resist;
	float Range;
	long  DmgAmount;

	// Error checking
	if (Victim == NULL)
		return false;

	// Can't attack if already dead or being hurt (or not enabled)
	if ( Victim->Action == CHAR_DIE ||	Victim->Action == CHAR_HURT)
		return false;

	// Adjust for definition if physical attack
	if (PhysicalAttack == true) {

		// Random value for less/more damage (-+20%)
		Range = (float)((rand() % 20) + 90) / 100.0f;
		DmgAmount = (long)((float)Amount * Range);

		// Subtract for defense of victim (allow -20% difference)
		Range = (float)((rand() % 20) + 80) / 100.0f;
		DmgAmount -= (long)((float)getDefense(Victim) * Range);
	}
	else {
		// Adjust for magical attack
		Resist = 1.0f - ((float)getResistance(Victim) / 100.0f);
		DmgAmount = (long)((float)Amount * Resist);
	}

	// Bounds check value
	if (DmgAmount < 0)
		DmgAmount = 0;

	// Check for double damage
	if (Victim->definition.Class == DmgClass)
		DmgAmount *= 2;

	// Check for cure damage
	if (Victim->definition.Class == CureClass)
		DmgAmount = -(labs(DmgAmount) / 2);

	// If no physical damage is dealt then randomly deal 
	// 10-20% of damage from the original amount.
	if (!DmgAmount && PhysicalAttack == true) {
		Range = (float)((rand() % 10) + 10) / 100.0f;
		DmgAmount = (long)((float)Amount * Range);
	}

	// Subtract damage amount
	Victim->current_health -=  DmgAmount;

	// Set hurt status and display message
	if (DmgAmount > 0) {
		

		sprintf_s(Text, "-%lu HP", DmgAmount);
		std::string msg = Victim->getEntityType() + " loss " + std::to_string(DmgAmount) + " HP";
		log_message->setString(msg);
		log_message->setColor(sf::Color::Red);
		Victim->addMessage(Text, 1000, sf::Color::Red);

		// Only set hurt if any damage (and idle or moving)
		if (DmgAmount) {
			if (Victim->Action == CHAR_MOVE || Victim->Action == CHAR_IDLE)
				setAction( CHAR_HURT);
				notify(*Victim, EVENT_HURT);

		}
	}

	// Display cure amount
	if (DmgAmount < 0) {

		sprintf_s(Text, "+%lu HP", -DmgAmount);
		std::string msg = getEntityType() + " gained " +  std::to_string(DmgAmount) + " HP" ;
		log_message->setString(msg);
		log_message->setColor(sf::Color::Green);
		addMessage(Text, 1000, sf::Color::Green);
	}

	return true;

}
Example #8
0
File: MQ135.cpp Project: 0x/Jarvis
float MQ135::getPPM() {
  return PARA * pow((getResistance()/RZERO), -PARB);
}
Example #9
0
File: MQ135.cpp Project: 0x/Jarvis
float MQ135::getCorrectedResistance(float t, float h) {
  return getResistance()/getCorrectionFactor(t, h);
}
Example #10
0
File: MQ135.cpp Project: 0x/Jarvis
float MQ135::getRZero() {
  return getResistance() * pow((ATMOCO2/PARA), (1./PARB));
}
Example #11
0
float MQ135::getPPMNH3() {
  return NH3PARA * pow((getResistance()/NH3RZERO), -NH3PARB);
}
Example #12
0
float MQ135::getRZeroNH3() {
  return getResistance() * pow((ATMONH3/NH3PARA), (1./NH3PARB));
}