Example #1
0
Material* SceneImporter<real>::ReadBlinnPhongMaterial( std::istream& stream, const std::string& name )
{
	BlinnPhongMaterial<real>* material = new BlinnPhongMaterial<real>;

	material->SetSurface( ReadColor( stream ) ); ReadNextExactToken( stream, "," );
	material->SetAmbient( ReadColor( stream ) ); ReadNextExactToken( stream, "," );
	material->SetDiffuse( ReadColor( stream ) ); ReadNextExactToken( stream, "," );
	material->SetSpecular( ReadColor( stream ) ); ReadNextExactToken( stream, "," );
	material->SetMetallic( ReadColor( stream ) ); ReadNextExactToken( stream, "," );
	material->SetReflection( ReadColor( stream ) ); ReadNextExactToken( stream, "," );
	material->SetRefraction( ReadColor( stream ) ); ReadNextExactToken( stream, "," );
	material->SetRefractionIndex( ReadReal( stream ) ); ReadNextExactToken( stream, "," );
	material->SetShininess( ReadReal( stream ) ); ReadNextExactToken( stream, "," );
	material->SetWireframe( ReadBoolean( stream ) ); ReadNextExactToken( stream, "," );

	material->SetTexture( GetTexture( ReadNextToken( stream ) ) ); ReadNextExactToken( stream, "," );
	Texture<real>* environment = GetTexture( ReadNextToken( stream ) );

	if ( environment && ( environment->GetTextureType() != Texture<real>::TypeCubeMap ) )
		throw "Environment must be a CubeMap";

	material->SetEnvironment( (CubeMap<real>*)environment );
	material->SetName( name );

	return material;
}
Example #2
0
void SceneImporter<real>::ReadVisualNodeHeader( std::istream& stream, VisualNode<real>* ioNode )
{
	ReadNodeHeader( stream, ioNode ); ReadNextExactToken( stream, "," );
	std::string materialName = ReadNextToken( stream ); ReadNextExactToken( stream, "," );
	bool isVisible = ReadBoolean( stream );

	ioNode->SetMaterial( GetMaterial( materialName ) );
	ioNode->SetVisible( isVisible );
}
Example #3
0
File: Simple.hpp Project: ifzz/FDK
    bool Factorial(const __int32& value, __int32& result)
    {
        MemoryBuffer buffer;
        m_channel->Initialize(buffer);

        WriteInt32(value, buffer);

        const HRESULT _status = m_channel->Invoke(0, 2, buffer);
        Throw(_status, buffer);

        result = ReadInt32(buffer);
        auto _result = ReadBoolean(buffer);
        return _result;
    }
Example #4
0
void LoadConfigFile(struct TConfig *Config)
{
	const char* CameraTypes[3] = {"None", "CSI - raspistill", "USB - fswebcam"};
	FILE *fp;
	int BaudRate;
	char *filename = "/boot/pisky.txt";

	if ((fp = fopen(filename, "r")) == NULL)
	{
		printf("\nFailed to open config file %s (error %d - %s).\nPlease check that it exists and has read permission.\n", filename, errno, strerror(errno));
		exit(1);
	}

	ReadBoolean(fp, "disable_monitor", -1, 0, &(Config->DisableMonitor));
	if (Config->DisableMonitor)
	{
		printf("HDMI/Composite outputs will be disabled\n");
	}
	
	ReadBoolean(fp, "Disable_RTTY", -1, 0, &(Config->DisableRTTY));
	Config->Channels[RTTY_CHANNEL].Enabled = !Config->DisableRTTY;
	if (Config->DisableRTTY)
	{
		printf("RTTY Disabled\n");
	}
	else
	{
		ReadString(fp, "payload", -1, Config->Channels[RTTY_CHANNEL].PayloadID, sizeof(Config->Channels[RTTY_CHANNEL].PayloadID), 1);
		printf ("RTTY Payload ID = '%s'\n", Config->Channels[RTTY_CHANNEL].PayloadID);
		
		ReadString(fp, "frequency", -1, Config->Frequency, sizeof(Config->Frequency), 0);

		BaudRate = ReadInteger(fp, "baud", -1, 1, 300);
		
		Config->Channels[RTTY_CHANNEL].BaudRate = BaudRate;
		
		Config->TxSpeed = BaudToSpeed(BaudRate);
		if (Config->TxSpeed == B0)
		{
			printf ("Unknown baud rate %d\nPlease edit in configuration file\n", BaudRate);
			exit(1);
		}
		printf ("Radio baud rate = %d\n", BaudRate);
	}
	
	// Logging
	Config->EnableGPSLogging = ReadBooleanFromString(fp, "logging", "GPS");
	if (Config->EnableGPSLogging) printf("GPS Logging enabled\n");

	Config->EnableTelemetryLogging = ReadBooleanFromString(fp, "logging", "Telemetry");
	if (Config->EnableTelemetryLogging) printf("Telemetry Logging enabled\n");
	
	Config->TelemetryFileUpdate = ReadInteger(fp, "telemetry_file_update", -1, 0, 0);
	if (Config->TelemetryFileUpdate > 0)
	{
		printf("Telemetry file 'latest.txt' will be created every %d seconds\n", Config->TelemetryFileUpdate);
	}
	
	ReadBoolean(fp, "enable_bmp085", -1, 0, &(Config->EnableBMP085));
	if (Config->EnableBMP085)
	{
		printf("BMP085 Enabled\n");
	}
	
	ReadBoolean(fp, "enable_bme280", -1, 0, &(Config->EnableBME280));
	if (Config->EnableBME280)
	{
		printf("BME280 Enabled\n");
	}
	
	Config->ExternalDS18B20 = ReadInteger(fp, "external_temperature", -1, 0, 1);
	if (Config->ExternalDS18B20)
	{
		printf("External DS18B20 Enabled\n");
	}

	Config->Camera = ReadCameraType(fp, "camera");
	printf ("Camera (%s) %s\n", CameraTypes[Config->Camera], Config->Camera ? "Enabled" : "Disabled");
	
	if (Config->Camera)
	{
		ReadString(fp, "camera_settings", -1, Config->CameraSettings, sizeof(Config->CameraSettings), 0);
		if (Config->CameraSettings)
		{
			printf ("Adding custom camera parameters '%s' to raspistill calls\n", Config->CameraSettings);
		}

		Config->SSDVHigh = ReadInteger(fp, "high", -1, 0, 2000);
		printf ("Image size changes at %dm\n", Config->SSDVHigh);
		
		Config->Channels[RTTY_CHANNEL].ImageWidthWhenLow = ReadInteger(fp, "low_width", -1, 0, 320);
		Config->Channels[RTTY_CHANNEL].ImageHeightWhenLow = ReadInteger(fp, "low_height", -1, 0, 240);
		printf ("RTTY Low image size %d x %d pixels\n", Config->Channels[RTTY_CHANNEL].ImageWidthWhenLow, Config->Channels[0].ImageHeightWhenLow);
		
		Config->Channels[RTTY_CHANNEL].ImageWidthWhenHigh = ReadInteger(fp, "high_width", -1, 0, 640);
		Config->Channels[RTTY_CHANNEL].ImageHeightWhenHigh = ReadInteger(fp, "high_height", -1, 0, 480);
		printf ("RTTY High image size %d x %d pixels\n", Config->Channels[RTTY_CHANNEL].ImageWidthWhenHigh, Config->Channels[0].ImageHeightWhenHigh);

		Config->Channels[RTTY_CHANNEL].ImagePackets = ReadInteger(fp, "image_packets", -1, 0, 4);
		printf ("RTTY: 1 Telemetry packet every %d image packets\n", Config->Channels[RTTY_CHANNEL].ImagePackets);
		
		Config->Channels[RTTY_CHANNEL].ImagePeriod = ReadInteger(fp, "image_period", -1, 0, 60);
		printf ("RTTY: %d seconds between photographs\n", Config->Channels[RTTY_CHANNEL].ImagePeriod);

		// Set up full-size image parameters		
		Config->Channels[FULL_CHANNEL].ImageWidthWhenLow = ReadInteger(fp, "full_low_width", -1, 0, 640);
		Config->Channels[FULL_CHANNEL].ImageHeightWhenLow = ReadInteger(fp, "full_low_height", -1, 0, 480);
		printf ("Full Low image size %d x %d pixels\n", Config->Channels[FULL_CHANNEL].ImageWidthWhenLow, Config->Channels[FULL_CHANNEL].ImageHeightWhenLow);
		
		Config->Channels[FULL_CHANNEL].ImageWidthWhenHigh = ReadInteger(fp, "full_high_width", -1, 0, 2592);
		Config->Channels[FULL_CHANNEL].ImageHeightWhenHigh = ReadInteger(fp, "full_high_height", -1, 0, 1944);
		printf ("Full High image size %d x %d pixels\n", Config->Channels[FULL_CHANNEL].ImageWidthWhenHigh, Config->Channels[FULL_CHANNEL].ImageHeightWhenHigh);

		Config->Channels[FULL_CHANNEL].ImagePeriod = ReadInteger(fp, "full_image_period", -1, 0, 60);
		printf ("Full size: %d seconds between photographs\n", Config->Channels[FULL_CHANNEL].ImagePeriod);
		
		Config->Channels[FULL_CHANNEL].ImagePackets = Config->Channels[FULL_CHANNEL].ImagePeriod > 0;
		Config->Channels[FULL_CHANNEL].Enabled = Config->Channels[FULL_CHANNEL].ImagePackets;
	}

	// GPS
	Config->GPSSource[0] = '\0';
	ReadString(fp, "gps_source", -1, Config->GPSSource, sizeof(Config->GPSSource), 0);
	ReadBoolean(fp, "Power_Saving", -1, 0, &(Config->Power_Saving));
	printf("GPS Power Saving = %s\n", Config->Power_Saving ? "ON" : "OFF");
	Config->Flight_Mode_Altitude = ReadInteger(fp, "Flight_Mode_Altitude", -1, 0, 1000);
	if (Config->Flight_Mode_Altitude) printf("Switching GPS to flight mode above %d metres\n", Config->Flight_Mode_Altitude);
	
	// Landing prediction
	Config->EnableLandingPrediction = 0;
	ReadBoolean(fp, "landing_prediction", -1, 0, &(Config->EnableLandingPrediction));
	if (Config->EnableLandingPrediction)
	{
		Config->cd_area = ReadFloat(fp, "cd_area", -1, 0, 0.66);
		Config->payload_weight = ReadFloat(fp, "payload_weight", -1, 0, 0.66);
		ReadString(fp, "prediction_id", -1, Config->PredictionID, sizeof(Config->PredictionID), 0);
	}
	
	// External data file
	Config->ExternalDataFileName[0] = '\0';
	ReadString(fp, "external_data", -1, Config->ExternalDataFileName, sizeof(Config->ExternalDataFileName), 0);
	
	// I2C overrides.  Only needed for users own boards, or for some of our prototypes
	if (ReadInteger(fp, "SDA", -1, 0, 0))
	{
		Config->SDA = ReadInteger(fp, "SDA", -1, 0, 0);
		printf ("I2C SDA overridden to %d\n", Config->SDA);
	}

	if (ReadInteger(fp, "SCL", -1, 0, 0))
	{
		Config->SCL = ReadInteger(fp, "SCL", -1, 0, 0);
		printf ("I2C SCL overridden to %d\n", Config->SCL);
	}
	
	Config->InfoMessageCount = ReadInteger(fp, "info_messages", -1, 0, -1);

	Config->QuietRTTYDuringLoRaUplink = 0;
	ReadBoolean(fp, "quiet_rtty_for_uplink", -1, 0, &(Config->QuietRTTYDuringLoRaUplink));

	LoadAPRSConfig(fp, Config);
	
	LoadLoRaConfig(fp, Config);
	
	fclose(fp);
}
Example #5
0
void LoadConfigFile()
{
	FILE *fp;
	char *filename = "gateway.txt";
	char Keyword[32];
	int Channel, Temp;
	char TempString[16];

	Config.EnableHabitat = 1;
	Config.EnableSSDV = 1;
	Config.EnableTelemetryLogging = 0;
	Config.ftpServer[0] = '\0';
	Config.ftpUser[0] = '\0';
	Config.ftpPassword[0] = '\0';
	Config.ftpFolder[0] = '\0';
	
	if ((fp = fopen(filename, "r")) == NULL)
	{
		printf("\nFailed to open config file %s (error %d - %s).\nPlease check that it exists and has read permission.\n", filename, errno, strerror(errno));
		exit(1);
	}

	// Receiver config
	ReadString(fp, "tracker", Config.Tracker, sizeof(Config.Tracker), 1);
	LogMessage("Tracker = '%s'\n", Config.Tracker);
	
	// Enable uploads
	ReadBoolean(fp, "EnableHabitat", 0, &Config.EnableHabitat);
	ReadBoolean(fp, "EnableSSDV", 0, &Config.EnableSSDV);
	
	// Enable logging
	ReadBoolean(fp, "LogTelemetry", 0, &Config.EnableTelemetryLogging);

	// Calling mode
	Config.CallingTimeout = ReadInteger(fp, "CallingTimeout", 0, 300);
	
	// LED allocations
	Config.NetworkLED = ReadInteger(fp, "NetworkLED", 0, -1);
	Config.InternetLED = ReadInteger(fp, "InternetLED", 0, -1);
	Config.LoRaDevices[0].ActivityLED = ReadInteger(fp, "ActivityLED_0", 0, -1);
	Config.LoRaDevices[1].ActivityLED = ReadInteger(fp, "ActivityLED_1", 0, -1);
	
	// Server Port
	Config.ServerPort = ReadInteger(fp, "ServerPort", 0, -1);	
	
	ReadString(fp, "ftpserver", Config.ftpServer, sizeof(Config.ftpServer), 0);
	ReadString(fp, "ftpUser", Config.ftpUser, sizeof(Config.ftpUser), 0);
	ReadString(fp, "ftpPassword", Config.ftpPassword, sizeof(Config.ftpPassword), 0);
	ReadString(fp, "ftpFolder", Config.ftpFolder, sizeof(Config.ftpFolder), 0);	

	for (Channel=0; Channel<=1; Channel++)
	{
		// Defaults
		Config.LoRaDevices[Channel].Frequency[0] = '\0';
		
		sprintf(Keyword, "frequency_%d", Channel);
		ReadString(fp, Keyword, Config.LoRaDevices[Channel].Frequency, sizeof(Config.LoRaDevices[Channel].Frequency), 0);
		if (Config.LoRaDevices[Channel].Frequency[0])
		{
			Config.LoRaDevices[Channel].ImplicitOrExplicit = EXPLICIT_MODE;
			Config.LoRaDevices[Channel].ErrorCoding = ERROR_CODING_4_8;
			Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_20K8;
			Config.LoRaDevices[Channel].SpreadingFactor = SPREADING_11;
			Config.LoRaDevices[Channel].LowDataRateOptimize = 0x00;		
			Config.LoRaDevices[Channel].AFC = FALSE;
			
			LogMessage("Channel %d frequency set to %s\n", Channel, Config.LoRaDevices[Channel].Frequency);
			Config.LoRaDevices[Channel].InUse = 1;

			// DIO0 / DIO5 overrides
			sprintf(Keyword, "DIO0_%d", Channel);
			Config.LoRaDevices[Channel].DIO0 = ReadInteger(fp, Keyword, 0, Config.LoRaDevices[Channel].DIO0);

			sprintf(Keyword, "DIO5_%d", Channel);
			Config.LoRaDevices[Channel].DIO5 = ReadInteger(fp, Keyword, 0, Config.LoRaDevices[Channel].DIO5);

			LogMessage("LoRa Channel %d DIO0=%d DIO5=%d\n", Channel, Config.LoRaDevices[Channel].DIO0, Config.LoRaDevices[Channel].DIO5);
			
			Config.LoRaDevices[Channel].SpeedMode = 0;
			sprintf(Keyword, "mode_%d", Channel);
			Config.LoRaDevices[Channel].SpeedMode = ReadInteger(fp, Keyword, 0, 0);

			if (Config.LoRaDevices[Channel].SpeedMode == 5)
			{
				// Calling channel
				Config.LoRaDevices[Channel].ImplicitOrExplicit = EXPLICIT_MODE;
				Config.LoRaDevices[Channel].ErrorCoding = ERROR_CODING_4_8;
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_41K7;
				Config.LoRaDevices[Channel].SpreadingFactor = SPREADING_11;
				Config.LoRaDevices[Channel].LowDataRateOptimize = 0;
			}
			else if (Config.LoRaDevices[Channel].SpeedMode == 4)
			{
				// Testing
				Config.LoRaDevices[Channel].ImplicitOrExplicit = IMPLICIT_MODE;
				Config.LoRaDevices[Channel].ErrorCoding = ERROR_CODING_4_5;
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_250K;
				Config.LoRaDevices[Channel].SpreadingFactor = SPREADING_6;
				Config.LoRaDevices[Channel].LowDataRateOptimize = 0;		
			}
			else if (Config.LoRaDevices[Channel].SpeedMode == 3)
			{
				// Normal mode for high speed images in 868MHz band
				Config.LoRaDevices[Channel].ImplicitOrExplicit = EXPLICIT_MODE;
				Config.LoRaDevices[Channel].ErrorCoding = ERROR_CODING_4_6;
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_250K;
				Config.LoRaDevices[Channel].SpreadingFactor = SPREADING_7;
				Config.LoRaDevices[Channel].LowDataRateOptimize = 0;		
			}
			else if (Config.LoRaDevices[Channel].SpeedMode == 2)
			{
				// Normal mode for repeater network
				Config.LoRaDevices[Channel].ImplicitOrExplicit = EXPLICIT_MODE;
				Config.LoRaDevices[Channel].ErrorCoding = ERROR_CODING_4_8;
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_62K5;
				Config.LoRaDevices[Channel].SpreadingFactor = SPREADING_8;
				Config.LoRaDevices[Channel].LowDataRateOptimize = 0x00;		
			}
			else if (Config.LoRaDevices[Channel].SpeedMode == 1)
			{
				// Normal mode for SSDV
				Config.LoRaDevices[Channel].ImplicitOrExplicit = IMPLICIT_MODE;
				Config.LoRaDevices[Channel].ErrorCoding = ERROR_CODING_4_5;
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_20K8;
				Config.LoRaDevices[Channel].SpreadingFactor = SPREADING_6;
				Config.LoRaDevices[Channel].LowDataRateOptimize = 0;
			}
			else
			{
				Config.LoRaDevices[Channel].ImplicitOrExplicit = EXPLICIT_MODE;
				Config.LoRaDevices[Channel].ErrorCoding = ERROR_CODING_4_8;
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_20K8;
				Config.LoRaDevices[Channel].SpreadingFactor = SPREADING_11;
				Config.LoRaDevices[Channel].LowDataRateOptimize = 0x08;		
			}

			sprintf(Keyword, "sf_%d", Channel);
			Temp = ReadInteger(fp, Keyword, 0, 0);
			if ((Temp >= 6) && (Temp <= 12))
			{
				Config.LoRaDevices[Channel].SpreadingFactor = Temp << 4;
				LogMessage("Setting SF=%d\n", Temp);
			}

			sprintf(Keyword, "bandwidth_%d", Channel);
			ReadString(fp, Keyword, TempString, sizeof(TempString), 0);
			if (*TempString)
			{
				LogMessage("Setting BW=%s\n", TempString);
			}
			if (strcmp(TempString, "7K8") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_7K8;
			}
			else if (strcmp(TempString, "10K4") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_10K4;
			}
			else if (strcmp(TempString, "15K6") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_15K6;
			}
			else if (strcmp(TempString, "20K8") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_20K8;
			}
			else if (strcmp(TempString, "31K25") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_31K25;
			}
			else if (strcmp(TempString, "41K7") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_41K7;
			}
			else if (strcmp(TempString, "62K5") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_62K5;
			}
			else if (strcmp(TempString, "125K") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_125K;
			}
			else if (strcmp(TempString, "250K") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_250K;
			}
			else if (strcmp(TempString, "500K") == 0)
			{
				Config.LoRaDevices[Channel].Bandwidth = BANDWIDTH_500K;
			}
			
			sprintf(Keyword, "implicit_%d", Channel);
			if (ReadBoolean(fp, Keyword, 0, &Temp))
			{
				if (Temp)
				{
					Config.LoRaDevices[Channel].ImplicitOrExplicit = IMPLICIT_MODE;
				}
			}
			
			sprintf(Keyword, "coding_%d", Channel);
			Temp = ReadInteger(fp, Keyword, 0, 0);
			if ((Temp >= 5) && (Temp <= 8))
			{
				Config.LoRaDevices[Channel].ErrorCoding = (Temp-4) << 1;
				LogMessage("Setting Error Coding=%d\n", Temp);
			}

			sprintf(Keyword, "lowopt_%d", Channel);
			if (ReadBoolean(fp, Keyword, 0, &Temp))
			{
				if (Temp)
				{
					Config.LoRaDevices[Channel].LowDataRateOptimize = 0x08;
				}
			}
			
			sprintf(Keyword, "AFC_%d", Channel);
			if (ReadBoolean(fp, Keyword, 0, &Temp))
			{
				if (Temp)
				{
					Config.LoRaDevices[Channel].AFC = TRUE;
					ChannelPrintf(Channel, 11, 24, "AFC");
				}
			}			
		}
	}

	fclose(fp);
}
Example #6
0
	Stream* Stream::ReadBitmap()
	{
		if (!ReadBoolean())
			return NULL;
		return Deserialize();
	}
bool RegistryPersistence::IsPulldown(const SmartPointer<IConfigurationElement>& element)
{
  const QString style = ReadOptional(element, ATT_STYLE);
  const bool pulldown = ReadBoolean(element, ATT_PULLDOWN, false);
  return (pulldown || STYLE_PULLDOWN == style);
}
Example #8
0
FLuaDataReader& FLuaDataReader::ReadGlobalBoolean(bool& bOutResult, const char* Name)
{
	LuaState.GetGlobal(Name);
	return ReadBoolean(bOutResult).Pop();
}
Example #9
0
//--------------------------------------------------------------------
bool CIniFile::ReadBoolean(const std::wstring& szSection, const std::wstring& szKey, bool bDefault)
{
    SetSection(szSection);
    return ReadBoolean(szKey, bDefault);
}