#!/usr/bin/env python3
#-*- coding: utf-8 -*-

#--------------------------------------------------------------------------------------------------
import time
import globals

#--------------------------------------------------------------------------------------------------
def SPL_init():

	global SPL_open_flag

	try :
		SPL_open_flag = False

		Timestamp = int(time.time())

		SPL_file_name = "/home/AQCM_log/SPL_A.txt"
		SPL_file = open(SPL_file_name, 'r')
		SPL_string = SPL_file.readline()
		SPL_file.close()

		SPL_brut_string = SPL_string.split("|")
		SPL_timestamp   = int(SPL_brut_string[0])

		if ( SPL_timestamp >= Timestamp - 15 ) :
			SPL_open_flag = True
			return True
		else :
			if globals.DEBUG_SPL :
				print( "SPL_init ->     Timestamp = ", Timestamp )
				print( "SPL_init -> SPL_timestamp = ", SPL_timestamp )
			return False
	
	except Exception as e0: 
		print("SPL_init -> exception -> " + str(e0) )
		SPL_open_flag = False
		return False

#--------------------------------------------------------------------------------------------------
