1
0
mirror of https://github.com/preble/libpinproc synced 2026-02-22 18:15:25 +01:00

changes for latest yaml-cpp and CPP 11

This commit is contained in:
darren
2019-05-29 14:06:19 -07:00
parent bd0046c144
commit dfe55cf217
3 changed files with 15 additions and 21 deletions

View File

@@ -13,12 +13,13 @@ if(POLICY CMP0015)
cmake_policy(SET CMP0015 OLD) cmake_policy(SET CMP0015 OLD)
endif() endif()
### ###
### Project settings ### Project settings
### ###
project(PINPROC) project(PINPROC)
set (CMAKE_CXX_STANDARD 11)
set(PINPROC_VERSION_MAJOR "2") set(PINPROC_VERSION_MAJOR "2")
set(PINPROC_VERSION_MINOR "0") set(PINPROC_VERSION_MINOR "0")
set(PINPROC_VERSION "${PINPROC_VERSION_MAJOR}.${PINPROC_VERSION_MINOR}") set(PINPROC_VERSION "${PINPROC_VERSION_MAJOR}.${PINPROC_VERSION_MINOR}")

View File

@@ -46,12 +46,8 @@ PRResult LoadConfiguration(YAML::Node& yamlDoc, const char *yamlFilePath)
fprintf(stderr, "YAML file not found: %s\n", yamlFilePath); fprintf(stderr, "YAML file not found: %s\n", yamlFilePath);
return kPRFailure; return kPRFailure;
} }
YAML::Parser parser(fin);
while(parser) yamlDoc = YAML::Load(fin);
{
parser.GetNextDocument(yamlDoc);
}
} }
// catch (YAML::ParserException& ex) // catch (YAML::ParserException& ex)
// { // {
@@ -341,8 +337,7 @@ int main(int argc, const char **argv)
return 1; return 1;
} }
std::string machineTypeString; std::string machineTypeString = yamlDoc["PRGame"]["machineType"].as<std::string>();
yamlDoc["PRGame"]["machineType"] >> machineTypeString;
if (machineTypeString == "wpc") if (machineTypeString == "wpc")
machineType = kPRMachineWPC; machineType = kPRMachineWPC;
else if (machineTypeString == "wpc95") else if (machineTypeString == "wpc95")

View File

@@ -142,36 +142,34 @@ void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc)
// WPC Flippers // WPC Flippers
std::string numStr; std::string numStr;
const YAML::Node& flippers = yamlDoc[kFlippersSection]; const YAML::Node& flippers = yamlDoc[kFlippersSection];
for (YAML::Iterator flippersIt = flippers.begin(); flippersIt != flippers.end(); ++flippersIt) for (YAML::const_iterator flippersIt = flippers.begin(); flippersIt != flippers.end(); ++flippersIt)
{ {
int swNum, coilMain, coilHold; int swNum, coilMain, coilHold;
std::string flipperName; std::string flipperName = flippersIt->as<std::string>();
*flippersIt >> flipperName;
if (machineType == kPRMachineWPC) if (machineType == kPRMachineWPC)
{ {
yamlDoc[kSwitchesSection][flipperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str()); numStr = yamlDoc[kSwitchesSection][flipperName][kNumberField].as<std::string>(); swNum = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField] >> numStr; coilMain = PRDecode(machineType, numStr.c_str()); numStr = yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField].as<std::string>(); coilMain = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][flipperName + "Hold"][kNumberField] >> numStr; coilHold = PRDecode(machineType, numStr.c_str()); numStr = yamlDoc[kCoilsSection][flipperName + "Hold"][kNumberField].as<std::string>(); coilHold = PRDecode(machineType, numStr.c_str());
ConfigureWPCFlipperSwitchRule (proc, swNum, coilMain, coilHold, kFlipperPulseTime); ConfigureWPCFlipperSwitchRule (proc, swNum, coilMain, coilHold, kFlipperPulseTime);
} }
else if (machineType == kPRMachineSternWhitestar || machineType == kPRMachineSternSAM) else if (machineType == kPRMachineSternWhitestar || machineType == kPRMachineSternSAM)
{ {
printf("hi\n"); printf("hi\n");
yamlDoc[kSwitchesSection][flipperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str()); numStr = yamlDoc[kSwitchesSection][flipperName][kNumberField].as<std::string>(); swNum = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField] >> numStr; coilMain = PRDecode(machineType, numStr.c_str()); numStr = yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField].as<std::string>(); coilMain = PRDecode(machineType, numStr.c_str());
ConfigureSternFlipperSwitchRule (proc, swNum, coilMain, kFlipperPulseTime, kFlipperPatterOnTime, kFlipperPatterOffTime); ConfigureSternFlipperSwitchRule (proc, swNum, coilMain, kFlipperPulseTime, kFlipperPatterOnTime, kFlipperPatterOffTime);
} }
} }
const YAML::Node& bumpers = yamlDoc[kBumpersSection]; const YAML::Node& bumpers = yamlDoc[kBumpersSection];
for (YAML::Iterator bumpersIt = bumpers.begin(); bumpersIt != bumpers.end(); ++bumpersIt) for (YAML::const_iterator bumpersIt = bumpers.begin(); bumpersIt != bumpers.end(); ++bumpersIt)
{ {
int swNum, coilNum; int swNum, coilNum;
// WPC Slingshots // WPC Slingshots
std::string bumperName; std::string bumperName = bumpersIt->as<std::string>();
*bumpersIt >> bumperName; numStr = yamlDoc[kSwitchesSection][bumperName][kNumberField].as<std::string>(); swNum = PRDecode(machineType, numStr.c_str());
yamlDoc[kSwitchesSection][bumperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str()); numStr = yamlDoc[kCoilsSection][bumperName][kNumberField].as<std::string>(); coilNum = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][bumperName][kNumberField] >> numStr; coilNum = PRDecode(machineType, numStr.c_str());
ConfigureBumperRule (proc, swNum, coilNum, kBumperPulseTime); ConfigureBumperRule (proc, swNum, coilNum, kBumperPulseTime);
} }
} }