Closes POCONSOLE-36. PLC Logic for handshaking and corrections to datalogger driver

This commit is contained in:
Patrick McDonagh
2016-05-13 10:26:57 -05:00
parent 742f610ede
commit 3ae3224880
3 changed files with 56 additions and 5 deletions

50
PLCHandshakeRungs.L5X Normal file
View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RSLogix5000Content SchemaRevision="1.0" SoftwareRevision="21.00" TargetType="Rung" TargetCount="1" ContainsContext="true" Owner="Rockwell Automation, Rockwell Automation" ExportDate="Fri May 13 10:19:20 2016" ExportOptions="References DecoratedData Context RoutineLabels AliasExtras IOTags NoStringData ForceProtectedEncoding AllProjDocTrans">
<Controller Use="Context" Name="Henry_Pump_VFD">
<DataTypes Use="Context">
</DataTypes>
<Tags Use="Context">
<Tag Name="DataLogger_Comm_Fault" TagType="Base" DataType="BOOL" Radix="Decimal" Constant="false" ExternalAccess="Read/Write">
<Data>00</Data>
<Data Format="Decorated">
<DataValue DataType="BOOL" Radix="Decimal" Value="0"/>
</Data>
</Tag>
<Tag Name="handshake" TagType="Base" DataType="BOOL" Radix="Decimal" Constant="false" ExternalAccess="Read/Write">
<Data>00</Data>
<Data Format="Decorated">
<DataValue DataType="BOOL" Radix="Decimal" Value="0"/>
</Data>
</Tag>
</Tags>
<Programs Use="Context">
<Program Use="Context" Name="MainProgram">
<Tags Use="Context">
<Tag Name="handshake_ton" TagType="Base" DataType="TIMER" Constant="false" ExternalAccess="Read/Write">
<Data>5C B9 0E C0 60 EA 00 00 39 18 00 00</Data>
<Data Format="Decorated">
<Structure DataType="TIMER">
<DataValueMember Name="PRE" DataType="DINT" Radix="Decimal" Value="60000"/>
<DataValueMember Name="ACC" DataType="DINT" Radix="Decimal" Value="6201"/>
<DataValueMember Name="EN" DataType="BOOL" Value="1"/>
<DataValueMember Name="TT" DataType="BOOL" Value="1"/>
<DataValueMember Name="DN" DataType="BOOL" Value="0"/>
</Structure>
</Data>
</Tag>
</Tags>
<Routines Use="Context">
<Routine Use="Context" Name="MainRoutine">
<RLLContent Use="Context">
<Rung Use="Target" Number="8" Type="N">
<Text>
<![CDATA[[XIO(handshake) TON(handshake_ton,?,?) XIC(handshake_ton.DN) OTL(DataLogger_Comm_Fault) ,XIC(handshake) OTU(DataLogger_Comm_Fault) OTU(handshake) ];]]>
</Text>
</Rung>
</RLLContent>
</Routine>
</Routines>
</Program>
</Programs>
</Controller>
</RSLogix5000Content>

View File

@@ -25,7 +25,7 @@ device_types = {}
def main():
global web_address, scan_rate, save_all, tag_store, device_types
global web_address, scan_rate, save_all, tag_store, device_types, plc_handshake_tags, last_handshake_time
try:
# Get tags stored in database
get_tag_request_data = {'where': '{"tag_class": 5}'}
@@ -78,7 +78,7 @@ def main():
hs_tags = json.loads(get_hs_request.text)
if len(hs_tags) > 0:
for hs in hs_tags:
plc_handshake_tag[hs['name']] = Tag(hs['name'], hs['tag'], hs['id'], hs['data_type'], hs['change_threshold'], hs['guarantee_sec'], mapFn=hs['map_function'], ip_address=hs['deviceID']['address'], device_type=device_types[hs['deviceID']['device_type']])
plc_handshake_tags[hs['name']] = Tag(hs['name'], hs['tag'], hs['id'], hs['data_type'], hs['change_threshold'], hs['guarantee_sec'], mapFn=hs['map_function'], ip_address=hs['deviceID']['address'], device_type=device_types[hs['deviceID']['device_type']])
except Exception, e:
print("Error getting handshake tags: {}".format(e))
@@ -94,10 +94,11 @@ def main():
print("ERROR EVALUATING {}".format(tag))
traceback.print_exc()
if plc_handshake_tag:
if plc_handshake_tags:
if time.time() - last_handshake_time > 30.0:
for hs_tag in plc_handshake_tags:
hs_tag.write(1)
plc_handshake_tags[hs_tag].write(1)
print("Handshake with {} - {}".format(plc_handshake_tags[hs_tag].address, hs_tag))
last_handshake_time = time.time()
time.sleep(scan_rate)

View File

@@ -31,7 +31,7 @@ poconsole.controller('tagsCtrl', function($scope, $route, $http, $routeParams, P
var getTag = tags.getTag(id);
getTag.then(function(data){
$scope.error = false;
$scope.dTag = data.tag;
$scope.dTag = data.tag[0];
$log.info("Thinking about deleting tag with parameters: "+ JSON.stringify($scope.dTag));
});
};