-
Notifications
You must be signed in to change notification settings - Fork 0
/
reader.erl
31 lines (27 loc) · 825 Bytes
/
reader.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-module(reader).
-export([start/0]).
-define(logfile, "quelle.log").
start() ->
spawn(reader, readBuffer, [self()]),
provideData("__________INIT__________").
% Lese 24 Bytes aus dem Puffer
readBuffer(PID) ->
case io:get_chars('', 24) of
eof ->
%werkzeug:logging("quelle.log",pid_to_list(self()) ++ ": " ++ "readBuffer: EOF\r\n"),
timer:sleep(500);
Text ->
%werkzeug:logging("quelle.log",pid_to_list(self()) ++ ": Read Text " ++ Text ++ "and sent to:" ++ pid_to_list(PID) ++ ": " ++ "readBuffer: READ\r\n"),
PID ! {content, Text}
end,
readBuffer(PID).
% Nachrichtengenerator
provideData(Data) ->
receive
{content, NewData} ->
provideData(NewData);
{generate, PID} ->
werkzeug:logging(?logfile,"generated and provided new message.\r\n"),
PID ! {content, Data},
provideData(Data)
end.