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

Merge branch 'master' of git@github.com:preble/P-ROC

This commit is contained in:
gstellenberg
2009-05-31 17:32:40 -05:00
5 changed files with 76 additions and 15 deletions

View File

@@ -11,17 +11,17 @@ PRBumpers:
- slingR - slingR
PRSwitches: PRSwitches:
flipperLwR: flipperLwR:
number: 1 number: SF2
flipperLwL: flipperLwL:
number: 3 number: SF4
flipperUpR: flipperUpR:
number: 5 number: SF6
flipperUpL: flipperUpL:
number: 7 number: SF8
slingL: slingL:
number: 96 number: S34
slingR: slingR:
number: 97 number: S35
PRCoils: PRCoils:
flipperLwRMain: flipperLwRMain:
number: 32 number: 32
@@ -40,9 +40,17 @@ PRCoils:
flipperUpLHold: flipperUpLHold:
number: 39 number: 39
slingL: slingL:
number: 54 number: C11
slingR: slingR:
number: 55 number: C10
slotKickout:
number: C01
rocketKickout:
number: C02
outhole:
number: C08
ballRelease:
number: C09
PRLamps: PRLamps:
doorTheCamera: doorTheCamera:
number: 80 number: L11

View File

@@ -28,6 +28,7 @@
*/ */
#include "pinproctest.h" #include "pinproctest.h"
PRMachineType machineType = kPRMachineInvalid;
/** Demonstration of the custom logging callback. */ /** Demonstration of the custom logging callback. */
void TestLogger(PRLogLevel level, const char *text) void TestLogger(PRLogLevel level, const char *text)
@@ -147,7 +148,6 @@ int main(int argc, const char **argv)
return 1; return 1;
} }
PRMachineType machineType = kPRMachineInvalid;
std::string machineTypeString; std::string machineTypeString;
yamlDoc["PRGame"]["machineType"] >> machineTypeString; yamlDoc["PRGame"]["machineType"] >> machineTypeString;
if (machineTypeString == "wpc") if (machineTypeString == "wpc")

View File

@@ -24,6 +24,8 @@
*/ */
#include "pinproctest.h" #include "pinproctest.h"
extern PRMachineType machineType;
typedef struct SwitchStatus { typedef struct SwitchStatus {
PREventType state; PREventType state;
uint32_t lastEventTime; uint32_t lastEventTime;
@@ -96,15 +98,16 @@ void ConfigureBumperRule (PRHandle proc, int swNum, int coilNum, int pulseTime)
void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc) void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc)
{ {
// WPC Flippers // WPC Flippers
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::Iterator flippersIt = flippers.begin(); flippersIt != flippers.end(); ++flippersIt)
{ {
int swNum, coilMain, coilHold; int swNum, coilMain, coilHold;
std::string flipperName; std::string flipperName;
*flippersIt >> flipperName; *flippersIt >> flipperName;
yamlDoc[kSwitchesSection][flipperName][kNumberField] >> swNum; yamlDoc[kSwitchesSection][flipperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField] >> coilMain; yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField] >> numStr; coilMain = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][flipperName + "Hold"][kNumberField] >> coilHold; yamlDoc[kCoilsSection][flipperName + "Hold"][kNumberField] >> numStr; coilHold = PRDecode(machineType, numStr.c_str());
ConfigureWPCFlipperSwitchRule (proc, swNum, coilMain, coilHold, kFlipperPulseTime); ConfigureWPCFlipperSwitchRule (proc, swNum, coilMain, coilHold, kFlipperPulseTime);
} }
@@ -115,8 +118,8 @@ void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc)
// WPC Slingshots // WPC Slingshots
std::string bumperName; std::string bumperName;
*bumpersIt >> bumperName; *bumpersIt >> bumperName;
yamlDoc[kSwitchesSection][bumperName][kNumberField] >> swNum; yamlDoc[kSwitchesSection][bumperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][bumperName][kNumberField] >> coilNum; yamlDoc[kCoilsSection][bumperName][kNumberField] >> numStr; coilNum = PRDecode(machineType, numStr.c_str());
ConfigureBumperRule (proc, swNum, coilNum, kBumperPulseTime); ConfigureBumperRule (proc, swNum, coilNum, kBumperPulseTime);
} }
} }

View File

@@ -243,6 +243,13 @@ PR_EXPORT void PRDriverStateSchedule(PRDriverState *driverState, uint32_t schedu
*/ */
PR_EXPORT void PRDriverStatePatter(PRDriverState *driverState, uint16_t millisecondsOn, uint16_t millisecondsOff, uint16_t originalOnTime); PR_EXPORT void PRDriverStatePatter(PRDriverState *driverState, uint16_t millisecondsOn, uint16_t millisecondsOff, uint16_t originalOnTime);
/**
* @brief Converts a coil, lamp, switch, or GI string into a P-ROC driver number.
* The following formats are accepted: Cxx (coil), Lxx (lamp), Sxx (matrix switch), SFx (flipper grounded switch), or SDx (dedicated grounded switch).
* If the string does not match this format it will be converted into an integer using atoi().
*/
PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str);
/** @} */ // End of Drivers /** @} */ // End of Drivers
// Switches // Switches

View File

@@ -231,6 +231,49 @@ PR_EXPORT void PRDriverStatePatter(PRDriverState *driver, uint16_t millisecondsO
driver->patterEnable = true; driver->patterEnable = true;
} }
PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str)
{
if (str == NULL)
return 0;
if (strlen(str) != 3)
return atoi(str);
uint16_t x = (str[1]-'0') * 10 + (str[2]-'0');
if (machineType == kPRMachineWPC)
{
switch (str[0])
{
case 'L':
case 'l':
return 80 + 8 * ((x / 10) - 1) + ((x % 10) -1);
case 'C':
case 'c':
if (x <= 28)
return x + 39;
else
return x + 7;
case 'G':
case 'g':
return x + 71;
case 'S':
case 's':
{
switch (str[1])
{
case 'D':
case 'd':
return 8 + ((str[2]-'0') - 1);
case 'F':
case 'f':
return (str[2]-'0') - 1;
default:
return 32 + 16 * ((x / 10) - 1) + ((x % 10) - 1);
}
}
}
}
return atoi(str);
}
// Switches // Switches