Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insteon: Add Support for ALDB_Delta #74

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6ea66b9
Add support for saving ALDB_Delta
krkeegan Jan 30, 2013
5678c13
Enable Framework for Skipping Unchanged Devices in Scan All Linkes
krkeegan Jan 30, 2013
7016178
Add Query ALDB Delta to ALDB object
krkeegan Jan 30, 2013
ee3572f
Intercept status_request responses for Query ALDB Delta
krkeegan Jan 30, 2013
b95a4e9
Query for ALDB Delta at end of Device Scan and Store
krkeegan Jan 30, 2013
702ba75
Sync All Links, Skip Devices that have not changed
krkeegan Jan 30, 2013
614d157
Prevent Adding a Link if ALDB is Out of Sync
krkeegan Jan 31, 2013
76d920d
Force Check ALDB_Delta Prior to Deleting Links
krkeegan Feb 1, 2013
f008fad
Update Link Table Health on all Status Requests
krkeegan Feb 2, 2013
0250d82
Skip requesting ALDB_Delta if MH Link Table is out-of-sync
krkeegan Feb 2, 2013
a3e864e
Fix Typos in Delete_Link, Fix Logic for Checking ALDB Delta
krkeegan Feb 2, 2013
824212a
Change ALDB health nomenclature corrupt is now out-of-sync
krkeegan Feb 2, 2013
82a2b25
Dont Request ALDB_Delta if it is less than 2 Seconds Old
krkeegan Feb 2, 2013
878b44d
Peek address after add_link and set new aldb_delta
krkeegan Feb 2, 2013
4d3d538
After delete_link scan the address and store ALDB_Delta
krkeegan Feb 2, 2013
4fbd7df
Merge branch 'fix_issue_46' into aldb_delta_v2
krkeegan Feb 5, 2013
bde2f01
Only Mark Duplicate in ALDB if address is not the same
krkeegan Feb 5, 2013
ec36ea7
Call Query ALDB_Delta for scan_one after delete
krkeegan Feb 5, 2013
5c78ef3
Merge branch 'master' into aldb_delta_v2
krkeegan Feb 5, 2013
26e457f
Bump ALDB_Delta if Set to 00
krkeegan Feb 6, 2013
340fc03
Enable Aldb_Delta Support for Update_Flags
krkeegan Feb 6, 2013
9638175
Enable Aldb_Delta Support for Update_Local
krkeegan Feb 6, 2013
0c77e06
Add ALDB_Delta Support to Update Links
krkeegan Feb 8, 2013
887bd06
Fix type in log message in Query_ALDB_Delta
krkeegan Feb 11, 2013
86cb28f
Add Voice Command for Scan Changed Device Links
krkeegan Feb 12, 2013
2c475a1
Clean up Comments in ALDB_Delta Changes
krkeegan Feb 12, 2013
d507d5f
Fix Callback in _Get_Next_Linkscan to respect Skip Unchanged
krkeegan Feb 12, 2013
9d29f51
Catch Reference to Voice_Cmd if Skip Unchanged is Not Specified
krkeegan Feb 12, 2013
64b662d
Merge branch 'master' into aldb_delta_v2
krkeegan Feb 11, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 41 additions & 12 deletions lib/Insteon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ my (@_sync_devices,@_sync_device_failures,$current_sync_device);

sub scan_all_linktables
{
if ($current_scan_device)
my $skip_unchanged = pop(@_);
$skip_unchanged = 0 if (ref $skip_unchanged || !defined($skip_unchanged));
if ($current_scan_device)
{
&main::print_log("[Scan all linktables] WARN: link already underway. Ignoring request for new scan ...");
return;
Expand Down Expand Up @@ -58,31 +60,57 @@ sub scan_all_linktables
}
$_scan_cnt = scalar @_scan_devices;

&_get_next_linkscan();
&_get_next_linkscan($skip_unchanged);
}

sub _get_next_linkscan_failure
{
my($skip_unchanged) = @_;
push @_scan_device_failures, $current_scan_device;
&main::print_log("[Scan all link tables] WARN: failure occurred when scanning "
. $current_scan_device->get_object_name . ". Moving on...");
&_get_next_linkscan();
&_get_next_linkscan($skip_unchanged);

}

sub _get_next_linkscan
{
$current_scan_device = shift @_scan_devices;

if ($current_scan_device)
{
&main::print_log("[Scan all link tables] Now scanning: "
. $current_scan_device->get_object_name . " ("
my($skip_unchanged, $changed_device) = @_;
if ($skip_unchanged && $changed_device) {
## if a device's aldb_delta has changed it is returned as an object here
$current_scan_device = $changed_device;
&main::print_log("[Scan all link tables] Now scanning: "
. $current_scan_device->get_object_name . " ("
. ($_scan_cnt - scalar @_scan_devices)
. " of $_scan_cnt)");
# pass first the success callback followed by the failure callback
$current_scan_device->scan_link_table('&Insteon::_get_next_linkscan()','&Insteon::_get_next_linkscan_failure()');
} else {
$current_scan_device->scan_link_table('&Insteon::_get_next_linkscan('.$skip_unchanged.')','&Insteon::_get_next_linkscan_failure('.$skip_unchanged.')');
return;
} else {
$current_scan_device = shift @_scan_devices;
}
# Calling scan_all_link(2) will skip scanning the PLM
if (($skip_unchanged == 2) && ($current_scan_device == &Insteon::active_interface)){
_get_next_linkscan(2);
return;
}
if ($current_scan_device) {
if ($skip_unchanged){
## check if aldb_delta has changed;
if ($current_scan_device != &Insteon::active_interface){
$current_scan_device->_aldb->{_aldb_unchanged_callback} = '&Insteon::_get_next_linkscan('.$skip_unchanged.')';
$current_scan_device->_aldb->{_aldb_changed_callback} = '&Insteon::_get_next_linkscan('.$skip_unchanged.', '.$current_scan_device->get_object_name.')';
$current_scan_device->_aldb->query_aldb_delta("check");
return;
}
}
&main::print_log("[Scan all link tables] Now scanning: "
. $current_scan_device->get_object_name . " ("
. ($_scan_cnt - scalar @_scan_devices)
. " of $_scan_cnt)");
# pass first the success callback followed by the failure callback
$current_scan_device->scan_link_table('&Insteon::_get_next_linkscan('.$skip_unchanged.')','&Insteon::_get_next_linkscan_failure('.$skip_unchanged.')');
} else {
&main::print_log("[Scan all link tables] All tables have completed scanning");
my $_scan_failure_cnt = scalar @_scan_device_failures;
if ($_scan_failure_cnt)
Expand Down Expand Up @@ -296,7 +324,7 @@ sub generate_voice_commands
$object_string .= &main::store_object_data($object_name_v, 'Voice_Cmd', 'Insteon', 'Insteon_item_commands');
push @_insteon_device, $object_name if $group eq '01'; # don't allow non-base items to participate
} elsif ($object->isa('Insteon_PLM')) {
my $cmd_states = "complete linking as responder,cancel linking,delete link with PLM,scan link table,show link table to log,delete orphan links,AUDIT - delete orphan links,scan all device link tables,sync all links,AUDIT - sync all links";
my $cmd_states = "complete linking as responder,cancel linking,delete link with PLM,scan link table,show link table to log,delete orphan links,AUDIT - delete orphan links,scan all device link tables,scan changed device link tables, sync all links,AUDIT - sync all links";
$object_string .= "$object_name_v = new Voice_Cmd '$command [$cmd_states]';\n";
$object_string .= "$object_name_v -> tie_event('$object_name->complete_linking_as_responder','complete linking as responder');\n\n";
$object_string .= "$object_name_v -> tie_event('$object_name->initiate_unlinking_as_controller','initiate unlinking');\n\n";
Expand All @@ -306,6 +334,7 @@ sub generate_voice_commands
$object_string .= "$object_name_v -> tie_event('$object_name->delete_orphan_links','delete orphan links');\n\n";
$object_string .= "$object_name_v -> tie_event('$object_name->delete_orphan_links(1)','AUDIT - delete orphan links');\n\n";
$object_string .= "$object_name_v -> tie_event('&Insteon::scan_all_linktables','scan all device link tables');\n\n";
$object_string .= "$object_name_v -> tie_event('&Insteon::scan_all_linktables(1)','scan changed device link tables');\n\n";
$object_string .= "$object_name_v -> tie_event('&Insteon::sync_all_links(0)','sync all links');\n\n";
$object_string .= "$object_name_v -> tie_event('&Insteon::sync_all_links(1)','AUDIT - sync all links');\n\n";
$object_string .= &main::store_object_data($object_name_v, 'Voice_Cmd', 'Insteon', 'Insteon_PLM_commands');
Expand Down
Loading