Jump to content

Insteon PLM Ruby Code 351: Difference between revisions

From LinuxMCE
Ddamron (talk | contribs)
No edit summary
 
Ddamron (talk | contribs)
Updated to support X10
Line 1: Line 1:
<pre>
<pre>#### Written by Dan Damron
#### Written by Dan Damron
#### #351 Process IDLE ####
#### #351 Process IDLE ####
############################ RECEIVE Error Trap ###########################
############################ RECEIVE Error Trap ###########################
if  $cmdqueue.length != 0
if  $cmdqueue.length != 0
   if $resetNext != 0
   if $resetNext != 0
     log($redBack + 'receive timeout='+$resetNext.to_s + $blackBack)
     log($red + 'receive timeout='+$resetNext.to_s + $grey)
   end
   end
   if $cmdqueue.to_s == $savedstate
   if $cmdqueue.to_s == $savedstate
     if $resetNext == $timeout
     if $resetNext == $timeout
      if $attempts == 2 then
if $attempts == 2 then
        #Third attempt.. fail the command.
#Third attempt.. fail the command.
        log('Third attempt, Failing Command!')
log('Third attempt, Failing Command!')
        $recvbuff = ''
$recvbuff = ''
        $currentcmd = 0
$currentcmd = 0
        $attempts = 0
$attempts = 0
        cmdComplete
cmdComplete
      else
else
        #Command has stalled. Reset wait flag and resend command.
      #Command has stalled. Reset wait flag and resend command.
        log('Command Stalled!  resetting and retrying')
      log('Command Stalled!  resetting and retrying')


        log('Current Command:' + $currentcmd.to_s)
      log('Current Command:' + $currentcmd.to_s)
        $recvbuff = ''
      $recvbuff = ''
        $currentcmd = 0
      $currentcmd = 0
        $attempts += 1
      $attempts += 1
        #hack to reset the command
      #hack to reset the command
        if $cmdqueue[0]['Command'] == 'InsStdMsg'
      if $cmdqueue[0]['Command'] == 'InsStdMsg'
          $cmdqueue[0]['Command'] = 'SndIns'
        $cmdqueue[0]['Command'] = 'SndIns'
        end
      end
      end
end
       $wAIT = false
       $wAIT = false
       $resetNext = 0
       $resetNext = 0
Line 41: Line 40:
     $attempts = 0
     $attempts = 0
   end
   end
end
end</pre>
</pre>

Revision as of 00:45, 14 February 2008

#### Written by Dan Damron
#### #351 Process IDLE ####
############################ RECEIVE Error Trap ###########################
if  $cmdqueue.length != 0
  if $resetNext != 0
    log($red + 'receive timeout='+$resetNext.to_s + $grey)
  end
  if $cmdqueue.to_s == $savedstate
    if $resetNext == $timeout
	if $attempts == 2 then
		#Third attempt.. fail the command.
		log('Third attempt, Failing Command!')
		$recvbuff = ''
		$currentcmd = 0
		$attempts = 0
		cmdComplete
		
	else
	      #Command has stalled. Reset wait flag and resend command.
	      log('Command Stalled!  resetting and retrying')

	      log('Current Command:' + $currentcmd.to_s)
	      $recvbuff = ''
	      $currentcmd = 0
	      $attempts += 1
	      #hack to reset the command
	      if $cmdqueue[0]['Command'] == 'InsStdMsg'
	        $cmdqueue[0]['Command'] = 'SndIns'
	      end
	end
      $wAIT = false
      $resetNext = 0
      SndIns()
    else
      $resetNext +=1
    end
  else
    $resetNext = 0
    $savedstate = $cmdqueue.to_s
    $attempts = 0
  end
end