Rome
Handling events in "blocks"
@Pobiega So, I figured out that the problem was that we kept starting a new loop everytime we received a button pressed event. We should have only started the loop on the first event and just add to the requests on subsequent event. Here is the updated event handler:
96 replies
Handling events in "blocks"
I think you might have to post your code since I don't understand it at all lol. I'll have to read your code to really understand your approach.
Do you think an approach using EventHandlerList is viable? I was reading this documentation and thought it might be promising
https://learn.microsoft.com/en-us/dotnet/standard/events/how-to-handle-multiple-events-using-event-properties
96 replies
Handling events in "blocks"
I believe that's the correct output for
i9,o8,o2,d3,i7,i4,o3
.
Yeah, you're correct about the elevator being at floor 2 when the events for 8, 2
happen. It should still be on floor 1 but I also see no way around.
The only workaround I see is to pass the input sequence to the Logic class so it knows how many "groups" of inputs are coming in but unfortunately that's against the requirements.
I have an idea of keeping track of the units of time that's passed for each move (Up, Down, Stop) and somehow use that to keep track of each grouping but I haven't quite figured out how I'll do that lol.
How are you getting it to stop at floor 2 for 8, 2
? Did you switch the structure of the loop or add if statements in the while
loop?96 replies
Handling events in "blocks"
I have to leave for a few hours. I'll try to think about the problem while I'm gone but if you do find the solution please don't give it to me right away. Maybe just give a hint to point me in the proper direction 🙂 ... thanks for your help!
96 replies
Handling events in "blocks"
Oh that's perfect. I was getting annoyed by the character limit lol.
Here's what I have so far. The only part that's stopping me from meeting the requirements is processing each "block" of inputs together.
The logic file is the only thing that can be edited.
https://paste.mod.gg/lljkatnacblm/0
96 replies
Handling events in "blocks"
The controller processes the events in order of the sequence order. Here is the part that's relevant to that process.
My example sequence above would look something like i9,o8,o2,d3,i7,i4,o3. I removed the i's and o's because they're not relevant to the order, however the d's are.
ProcessEvent() is called in proper order of the sequence i9,o8,o2,d3,i7,i4,o3.
The sequence is stored in a dictionary that'll look like { {0: [i9,o8,o2], 3: [i7,i4,o3] } } .
A for loop goes through the sequence, here's the part that does that.
96 replies