I have a working calculator now, but it wont stop the timer. I need to sleep now, super tired with this… Frustrated. Could you please tell me what am i doing wrong? It counts to 16, process stops due to an error and simulation goes on.
At least I think you need to have a loop within the Sink process that contains the TransportIn and If statements. This is because your “Laskuri” variable will get reset to 0 every time the Sink process starts. This reset to default value is done for all routine variables.
Alternatively you could add your “Laskuri” variable as a component property instead, which can be used similarly in the process but doesn’t reset automatically. Your would need to implement logic to reset that at simulation start, though.