added testcases / a bit refactored

This commit is contained in:
Meydin87
2023-07-09 07:57:06 +02:00
parent 58325fdd88
commit d8a9bb7610
7 changed files with 91 additions and 15 deletions

View File

@@ -15,9 +15,9 @@ Packages
---------------------------------
0xF00: HELLO->ADOPT
Payload:
2 bytes | DeviceId -> DeviceId Explicit
2 bytes | Byte -> Software-Version (1.0)
2 bytes | Byte -> Hw Version (4.0
2 bytes | Byte -> Hw Version (4.0)
2 bytes | DeviceId -> DeviceId Explicit
0x050: Input Switch Triggered
-> Broadcast
@@ -29,7 +29,7 @@ Payload:
0x055: Command Set Switch
-> Broadcast
---------------------------------
2 bytes | TargetDeviceId -> The id of the board
2 bytes | TargetDeviceId -> The id of the device to set the pin of
1 byte | PinId -> Idof the pin of the board
1 byte | state -> 1 to swtich on, 0 to switch off

View File

@@ -138,7 +138,7 @@ void SendVersionPackage(MCP2515 *interface)
DoSendCanPkg(interface, &toSend);
}
void SendDoTriggerSwitchCanPackage(uint16_t targetCanId, byte pinId, byte state)
void BroadcastTriggerMeyPinCanPackage(uint16_t targetCanId, byte pinId, byte state)
{
can_frame toSend;

View File

@@ -54,7 +54,7 @@ uint32_t CreateCanId(uint16_t commandId);
void SendVersionPackage(MCP2515 *interface);
void SendSwitchedTriggeredCanPackage(byte pinId, int state);
void SendDoTriggerSwitchCanPackage(uint16_t targetCanId, byte pinId, byte state);
void BroadcastTriggerMeyPinCanPackage(uint16_t targetCanId, byte pinId, byte state);
void DoSendCanPkg(can_frame *frame);
void DoSendCanPkg(MCP2515 *interface, can_frame *frame);

View File

@@ -71,20 +71,27 @@ void CheckRule(uint16_t deviceId, uint8_t dt, uint8_t state, Rule *rule)
if (rule->toggle)
pinState = (currentPinState->getPinState(rule->targetMeyPinId) ^ true);
SendDoTriggerSwitchCanPackage(rule->targetDevId, rule->targetMeyPinId, pinState);
// //digitalWrite(foundPinId->pin_id, pinState);
// //foundPinId->pin_state = pinState;
//
currentPinState->setPinState(rule->targetMeyPinId, pinState);
BroadcastTriggerMeyPinCanPackage(rule->targetDevId, rule->targetMeyPinId, pinState);
currentPinState->setPinState(rule->targetMeyPinId, pinState);
}
void HandleTriggered(can_frame *frame)
{
if (GetPackageType(frame->can_id) == SWITCH_TRIGGERED_CAN_ID)
{
RemotePinInfo *currentPinState = remotePinInfo.FindOrAdd(GetDeviceId(frame->can_id) );
if (currentPinState == NULL)
return;
currentPinState->setPinState(frame->data[0], frame->data[1]);
}
}
void HandleRules(can_frame *frame)
{
HandleTriggered(frame);
if (rules == NULL) return;
if (GetPackageType(frame->can_id) == SWITCH_TRIGGERED_CAN_ID)
{

View File

@@ -107,4 +107,5 @@ void AddToggle(uint16_t sourceDevId, byte sourceMeyPinId, uint16_t targetDevId,
void AddToggleInverse(uint16_t sourceDevId, byte sourceMeyPinId, uint16_t targetDevId, byte targetMeyPinId);
void HandleRules(can_frame *frame);
void PutRule(Rule *rule);
void CheckRule(uint16_t deviceId, uint8_t dt, uint8_t state, Rule *rule);
#endif

View File

@@ -63,7 +63,7 @@ void loop()
}
HandleFrame(&incomingCanFrame);
HandleRules(&incomingCanFrame);
// HandleRules(&incomingCanFrame);
}
}
}

68
Software/Testfälle.txt Normal file
View File

@@ -0,0 +1,68 @@
Testfälle Meycan Switch
PreCons for each:
GIVEN XX XX is the deviceId of the target device
GIVEN YY YY is another device id, which is NOT XX XX
GIVEN 2nd CAN Debug Device on another CanBus of switch
1) A MeyPin can be triggered directly (repeat Test for all MeyPins and each CAN Bus Interface specified)
WHEN Send CAN Pkg 00 55 11 11 | XX XX 01 01 -> (MeyPin1 Should switch to on)
THEN The MeyPin 1 should trigger
THEN you receive a message 00 50 XX XX | 01 01
THEN 2nd device should receive 2 messages
* 00 50 XX XX | 01 01
* 00 55 11 11 | XX XX 01 01
1a) A MeyPin trigger is effecltess, if only set
GIVEN the above testcast
WHEN Send CAN Pkg 00 55 11 11 | XX XX 01 01
THEN Nothing changed
THEN you dont receive a message
THEN 2nd device should receive 00 55 11 11 | XX XX 01 01
WHEN Send CAN Pkg 00 55 11 11 | XX XX 01 00 -> (MeyPin1 Should switch to off)
THEN The MeyPin 1 should switch to OFF
THEN you receive a message 00 50 XX XX | 01 00
THEN 2nd device should receive 2 messages
* 00 50 XX XX | 01 00
* 00 55 11 11 | XX XX 01 00
2) A MeyPin is not triggered, if the device id dont match
WHEN Send CAN Pkg 00 55 11 11 | YY YY 01 01
THEN None of the pins of the device triggered
THEN you receive no message
THEN 2nd device should receive 1 messages
* 00 55 11 11 | XX XX 01 01
3) A MeyPin is not triggered, if the Package Type dont match
WHEN Send CAN Pkg 50 00 11 11 | YY YY 01 01
THEN None of the pins of the device triggered
THEN you receive no message
THEN 2nd device should receive 1 messages
* 50 00 11 11 | XX XX 01 01
3) A MeyPin is not triggered, if the MeyPin is above 8 (max pins)
WHEN Send CAN Pkg 00 55 11 11 | XX XX 09 01
THEN None of the pins of the device triggered
THEN you receive no message
THEN 2nd device should receive 1 messages
* 00 55 11 11 | XX XX 09 01
THEN you can execute any other testcase, as the switch didnt crash
4) All MeyPins can be activated more than 15 minutes in parallel(Activate each port for at least 15 mins)
GIVE You have a relais connected to each of the ports
WHEN Send CAN Pkg 00 55 11 11 | XX XX 01 01 -> (MeyPin1 Should switch to on)
WHEN Send CAN Pkg 00 55 11 11 | XX XX 02 01 -> (MeyPin2 Should switch to on)
WHEN Send CAN Pkg 00 55 11 11 | XX XX 03 01 -> (MeyPin3 Should switch to on)
WHEN Send CAN Pkg 00 55 11 11 | XX XX 04 01 -> (MeyPin4 Should switch to on)
WHEN Send CAN Pkg 00 55 11 11 | XX XX 05 01 -> (MeyPin5 Should switch to on)
WHEN Send CAN Pkg 00 55 11 11 | XX XX 06 01 -> (MeyPin6 Should switch to on)
WHEN Send CAN Pkg 00 55 11 11 | XX XX 07 01 -> (MeyPin7 Should switch to on)
WHEN Send CAN Pkg 00 55 11 11 | XX XX 08 01 -> (MeyPin8 Should switch to on)
THEN you should only receive the packages from above.
THEN you should NOT receive a VersionPackage
WHEN you wait 15 Minutes
THEN nothing should be send
THEN the Pins should not trigger