Skip to content

Commit

Permalink
click areas
Browse files Browse the repository at this point in the history
  • Loading branch information
KenT2 committed Jan 25, 2015
1 parent e8a2f24 commit 36c8f3d
Show file tree
Hide file tree
Showing 24 changed files with 408 additions and 197 deletions.
36 changes: 24 additions & 12 deletions pipresents.py
Expand Up @@ -305,6 +305,17 @@ def __init__(self):
self.animate.poll()

# Create list of start shows initialise them and then run them
show_id=-1
self.show_manager=ShowManager(show_id,self.showlist,self.starter_show,self.root,self.canvas,self.pp_dir,self.pp_profile,self.pp_home)

# first time through so register shows and set callback to terminate Pi Presents if all shows have ended.
self.show_manager.init(self.canvas,self.all_shows_ended_callback,self.handle_command,self.showlist)
reason,message=self.show_manager.register_shows()
if reason == 'error':
self.mon.err(self,message)
self.end('error',message)

# and run the start shows
self.run_start_shows()

# kick off the time of day scheduler which may run additional shows
Expand All @@ -331,16 +342,13 @@ def parse_screen(self,size_text):
# ********************
def run_start_shows(self):
self.mon.trace(self,'run start shows')
# start show manager
show_id=-1 #start show
self.show_manager=ShowManager(show_id,self.showlist,self.starter_show,self.root,self.canvas,self.pp_dir,self.pp_profile,self.pp_home)
# first time through so empty show register and set callback to terminate Pi Presents if all shows have ended.
self.show_manager.init(self.canvas,self.all_shows_ended_callback,self.handle_command)

# parse the start shows field and start the initial shows
show_refs=self.starter_show['start-show'].split()
for show_ref in show_refs:
reason,message=self.show_manager.control_a_show(show_ref,'open')
if reason == 'error':
self.mon.err(self,message)



# *********************
Expand All @@ -358,12 +366,14 @@ def handle_command(self,command_text):
self.mon.log(self,"command received: " + command_text)
if command_text.strip()=="":
return

fields= command_text.split()
show_command=fields[0]
if len(fields)>1:
show_ref=fields[1]
else:
show_ref=''

if show_command in ('open','close'):
reason,message=self.show_manager.control_a_show(show_ref,show_command)

Expand All @@ -378,9 +388,10 @@ def handle_command(self,command_text):
else:
reason='error'
message='command not recognised '+ command_text

if reason=='error':
self.mon.err(self,message)
self.end(reason,message)
return


def handle_output_event(self,symbol,param_type,param_values,req_time):
Expand Down Expand Up @@ -430,6 +441,7 @@ def terminate(self):
self.mon.log(self, "terminate received from user")
needs_termination=False
for show in self.show_manager.shows:
# print show[ShowManager.SHOW_OBJ], show[ShowManager.SHOW_REF]
if show[ShowManager.SHOW_OBJ] is not None:
needs_termination=True
self.mon.log(self,"Sent terminate to show "+ show[ShowManager.SHOW_REF])
Expand Down Expand Up @@ -515,10 +527,10 @@ def tidy_up(self):
if __name__ == '__main__':

pp = PiPresents()
## try:
## pp = PiPresents()
## except:
## traceback.print_exc(file=open("/home/pi/pp_exceptions.log","w"))
## pass
# try:
# pp = PiPresents()
# except:
# traceback.print_exc(file=open("/home/pi/pp_exceptions.log","w"))
# pass


45 changes: 31 additions & 14 deletions pp_animate.py
Expand Up @@ -172,36 +172,53 @@ def clear_events_list(self,tag):
Animate.events=[]


# [delay],symbol,type,state
def parse_animate_fields(self,line):
fields= line.split()
if len(fields) == 0:
return 'normal','no fields','','',[],0

name=fields[0]

if len(fields) not in (3,4):
elif len(fields) not in (3,4):
return 'error','Wrong number of fields in : '+ line,'','',[],0

param_type=fields[1]
elif len(fields)== 3:

name=fields[0]
param_type=fields[1]
delay_text='0'
start_params=2

elif len(fields)== 4:
delay_text=fields[0]
name=fields[1]
param_type=fields[2]
start_params=3

else:
return 'error','Wrong number of fields in : '+ line,'','',[],0

# check each field
if not delay_text.isdigit():
return 'error','Delay is not an integer in : '+ line,'','',[],0
else:
delay=int(delay_text)


#only one param type at the moment.
if param_type != 'state':
return 'error','uknnown parameter type in : '+ line,'','',[],0
else:
params_length = 1
params_check = ('on','off')


params=[]
for index in range(2, 2+params_length):
for index in range(start_params, start_params+ params_length):
param=fields[index]
if not param in params_check:
return 'error','unknown paramter value in : '+ line,'','',[],0
return 'error','unknown parameter value in : '+ line,'','',[],0
params.append(param)

if len(fields) == 2+params_length:
delay_text='0'
else:
delay_text=fields[2+params_length]

if not delay_text.isdigit():
return 'error','Delay is not an integer in : '+ line,'','','off',0
delay=int(delay_text)
return 'normal','event parsed OK',name,param_type,params,delay


9 changes: 6 additions & 3 deletions pp_artliveshow.py
Expand Up @@ -29,10 +29,13 @@ def __init__(self,
pp_profile,
command_callback)


# get the live tracks directories
self.options=command_options()

def play(self,end_callback,show_ready_callback, direction_command,level,controls_list):

self.end_callback=end_callback

# get the livetracks directories
if self.show_params['live-tracks-dir1'] != '':
self.pp_live_dir1= self.show_params['live-tracks-dir1']
Expand Down Expand Up @@ -80,9 +83,9 @@ def __init__(self,


# use the appropriate medialist
self.medialist=LiveList(show_params['sequence'])
self.medialist=LiveList(self.show_params['sequence'])

# and pass directories to Livelist
self.medialist.live_tracks(self.pp_live_dir1,self.pp_live_dir2)


ArtShow.play(self,end_callback,show_ready_callback, direction_command,level,controls_list)
7 changes: 4 additions & 3 deletions pp_artmediashow.py
Expand Up @@ -28,9 +28,10 @@ def __init__(self,
command_callback)


def play(self,end_callback,show_ready_callback, direction_command,level,controls_list):

# use the appropriate medialist
self.medialist=MediaList(show_params['sequence'])
self.medialist=MediaList(self.show_params['sequence'])



ArtShow.play(self,end_callback,show_ready_callback, direction_command,level,controls_list)

13 changes: 6 additions & 7 deletions pp_artshow.py
Expand Up @@ -168,7 +168,7 @@ def start_show(self):
def load_first_track(self):
self.mon.trace(self,'')
if self.medialist.start() is False:
# list is empty - display a message for 10 secs and then retry
# list is empty - display a message for 5 secs and then retry
Show.display_admin_message(self,Show.base_resource(self,'mediashow','m11'))
self.canvas.after(5000,self.remove_list_empty_message)
else:
Expand Down Expand Up @@ -268,7 +268,6 @@ def what_next(self):

else:
# otherwise show the next track
print 'show next track after end'
self.show_next_track()
else:
# otherwise show the next track
Expand All @@ -280,7 +279,7 @@ def show_next_track(self):
self.previous_player=self.current_player
self.current_player=self.next_player
self.next_player=None
self.mon.trace(self,'AFTER SHUFFLE n-c-p' + self.next_player + ' ' + self.current_player + ' ' + self.previous_player)
self.mon.trace(self,'AFTER SHUFFLE n-c-p' + str(self.next_player) + ' ' + str(self.current_player) + ' ' + str(self.previous_player))
self.mon.trace(self, 'showing track')
if self.end_medialist_warning is True:
self.end_medialist_signal = True
Expand Down Expand Up @@ -369,7 +368,7 @@ def close_current_and_next(self):


def end_close_current(self,reason,message):
self.mon.log(self,"end_close_current - Current closed with reason: "+ reason + ' and message: '+ message)
self.mon.log(self,"Current track closed with reason: "+ reason + ' and message: '+ message)
self.mon.trace(self,' - current closed')
self.current_player=None # safer to delete the player here rather than in player as play-state is read elsewhere.

Expand Down Expand Up @@ -412,14 +411,14 @@ def wait_for_end(self):
self.mon.err(self,"Unhandled ending_reason: ")
self.end('error',"Unhandled ending_reason")

def track_ready_callback(self):
def track_ready_callback(self,enable_show_background):
self.mon.trace(self, '')
# close the player from the previous track
if self.previous_player is not None:
self.mon.trace(self, 'hiding previous: ' + self.previous_player)
self.mon.trace(self, 'hiding previous: ' + str(self.previous_player))
self.previous_player.hide()
if self.previous_player.get_play_state() == 'showing':
self.mon.trace(self,'closing previous: ' + self.previous_player)
self.mon.trace(self,'closing previous: ' + str(self.previous_player))
self.previous_player.close(self.closed_callback)
else:
self.mon.trace(self, 'previous is none')
Expand Down
16 changes: 15 additions & 1 deletion pp_controlsmanager.py
Expand Up @@ -23,6 +23,20 @@ def get_controls(self,controls_text):
controls_list.append([control[0],control[1]])
return 'normal','controls read',controls_list

def merge_controls(self,current_controls,track_controls):
for track_control in track_controls:
for control in current_controls:
if track_control[0] == control[0]:
# link exists so overwrite
control[1]=track_control[1]
break
else:
# new link so append it
current_controls.append([track_control[0],track_control[1]])
# print "\n merging"
# print current_controls



# parse controls from controls field in a show
def parse_controls(self,controls_text):
Expand All @@ -45,7 +59,7 @@ def parse_control(self,line):
return "incorrect number of fields in control "+line,['','']
symbol=fields[0]
operation=fields[1]
if operation in ('stop','play','up','down','pause','exit') or operation[0:4] == 'omx-' or operation[0:6] == 'mplay-'or operation[0:5] == 'uzbl-':
if operation in ('stop','play','up','down','pause','exit','null','no-command') or operation[0:4] == 'omx-' or operation[0:6] == 'mplay-'or operation[0:5] == 'uzbl-':
return '',[symbol,operation]
else:
return "controls, unknown operation in\n "+ line,['','']
Expand Down

0 comments on commit 36c8f3d

Please sign in to comment.