import sys
import os
import threading
import random
sys.path.append(os.path.abspath("../../IoTPy/multiprocessing"))
sys.path.append(os.path.abspath("../../IoTPy/core"))
sys.path.append(os.path.abspath("../../IoTPy/agent_types"))
sys.path.append(os.path.abspath("../../IoTPy/helper_functions"))
sys.path.append(os.path.abspath("../timing"))

from multicore import SharedMemoryProcess
from multicore import shared_memory_process, Multiprocess
from multicore import single_process_single_source
from multicore import single_process_multiple_sources
from stream import Stream
from op import map_element, map_window, filter_element, map_list
from merge import zip_stream, blend, zip_map
from source import source_func_to_stream, source_function, source_list
from source import SourceList, source_list_to_stream
from sink import stream_to_file, sink_element
from timing import offsets_from_ntp_server
from print_stream import print_stream
from helper_control import _stop_, _close
from recent_values import recent_values

source_list = range(10)
def source(out_stream):
    return source_list_to_stream(source_list, out_stream)

def check_correctness_of_output(in_stream, check_list):
    def check(v, index, check_list):
        # v is in_list[index]
        assert v == check_list[index]
        next_index = index + 1
        return next_index
    sink_element(func=check, in_stream=in_stream, state=0,
                 check_list=check_list)