{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from pycomm3 import LogixDriver\n", "import json, pprint" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "ip_address = \"166.195.18.153\" # \"ngrok.iot.inhandnetworks.com:3021\"\n", "path = '/Users/nico/Documents/GitHub/HP_InHand_IG502/Pub_Sub/plcfreshwater_advvfdipp/thingsboard/as11_tag_dump.json' # code snippets/tag_dump.json'" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "with LogixDriver(ip_address) as plc:\n", " #info = plc.get_plc_info()\n", " plctags = plc.get_tag_list()\n", " #print(info)\n", " with open(path, 'w') as f:\n", " json.dump(plc.tags_json,f, indent=4)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(plctags)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "json.dumps(plctags, indent=4)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "readtags = [\n", " \"Lact_01_Monthly_Total\",\n", " \"Lact_01_Prev_Month_Total\",\n", " \"Lact_01_Today_Total\",\n", " \"Lact_01_Yesterday_Total\",\n", " \"Lact_02_Monthly_Total\",\n", " \"Lact_02_Prev_Month_Total\",\n", " \"Lact_02_Today_Total\",\n", " \"Lact_02_Yesterday_Total\",\n", " \"XferPump_01_Daily_Totalizer.Total\",\n", " \"XferPump_01_Daily_Totalizer.OldTotal\",\n", " \"XferPump_02_Monthly_Totalizer.Total\",\n", " \"XferPump_02_Monthly_Totalizer.OldTotal\",\n", " \"Val_Water_Xfer_Current_Day\",\n", " \"Val_Water_Xfer_Prev_Day\"\n", "]\n", "with LogixDriver('63.40.227.154') as plc:\n", " print(*plc.read(*readtags), sep=\"\\n\")\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with LogixDriver(ip_address) as plc:\n", " #for x in range(20):\n", " print(plc.read('Lifetime_Flow_Meter_Gal'))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with LogixDriver('107.84.254.147') as plc:\n", " print(plc.write(\"Lifetime_Flow_Meter_Gal\", 0))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "attributes = [\n", " \"EnableIn\",\n", " \"EnableOut\",\n", " \"Inp_PV\",\n", " \"Inp_PVSrcQ\",\n", " \"Inp_PVBad\",\n", " \"Inp_PVUncertain\",\n", " \"Inp_Sim\",\n", " \"Inp_HiHiGate\",\n", " \"Inp_HiGate\",\n", " \"Inp_LoGate\",\n", " \"Inp_LoLoGate\",\n", " \"Inp_FailGate\",\n", " \"Inp_Reset\",\n", " \"Cfg_NoSubstPV\",\n", " \"Cfg_SetTrack\",\n", " \"Cfg_HasChanObj\",\n", " \"Cfg_UseChanSrcQ\",\n", " \"Cfg_PCmdClear\",\n", " \"Cfg_ProgDefault\",\n", " \"Cfg_HasHiHiAlm\",\n", " \"Cfg_HasHiAlm\",\n", " \"Cfg_HasLoAlm\",\n", " \"Cfg_HasLoLoAlm\",\n", " \"Cfg_HasFailAlm\",\n", " \"Cfg_HiHiResetReqd\",\n", " \"Cfg_HiResetReqd\",\n", " \"Cfg_LoResetReqd\",\n", " \"Cfg_LoLoResetReqd\",\n", " \"Cfg_FailResetReqd\",\n", " \"Cfg_HiHiAckReqd\",\n", " \"Cfg_HiAckReqd\",\n", " \"Cfg_LoAckReqd\",\n", " \"Cfg_LoLoAckReqd\",\n", " \"Cfg_FailAckReqd\",\n", " \"Cfg_HiHiSeverity\",\n", " \"Cfg_HiSeverity\",\n", " \"Cfg_LoSeverity\",\n", " \"Cfg_LoLoSeverity\",\n", " \"Cfg_FailSeverity\",\n", " \"Cfg_InpRawMin\",\n", " \"Cfg_InpRawMax\",\n", " \"Cfg_PVEUMin\",\n", " \"Cfg_PVEUMax\",\n", " \"Cfg_FiltTC\",\n", " \"Cfg_HiHiDB\",\n", " \"Cfg_HiHiOnDly\",\n", " \"Cfg_HiHiOffDly\",\n", " \"Cfg_HiHiGateDly\",\n", " \"Cfg_HiDB\",\n", " \"Cfg_HiOnDly\",\n", " \"Cfg_HiOffDly\",\n", " \"Cfg_HiGateDly\",\n", " \"Cfg_LoDB\",\n", " \"Cfg_LoOnDly\",\n", " \"Cfg_LoOffDly\",\n", " \"Cfg_LoGateDly\",\n", " \"Cfg_LoLoDB\",\n", " \"Cfg_LoLoOnDly\",\n", " \"Cfg_LoLoOffDly\",\n", " \"Cfg_LoLoGateDly\",\n", " \"Cfg_FailHiLim\",\n", " \"Cfg_FailLoLim\",\n", " \"Cfg_FailDB\",\n", " \"Cfg_FailOnDly\",\n", " \"Cfg_FailOffDly\",\n", " \"Cfg_FailGateDly\",\n", " \"PSet_Owner\",\n", " \"PSet_HiHiLim\",\n", " \"PSet_HiLim\",\n", " \"PSet_LoLim\",\n", " \"PSet_LoLoLim\",\n", " \"MSet_SubstPV\",\n", " \"OSet_HiHiLim\",\n", " \"OSet_HiLim\",\n", " \"OSet_LoLim\",\n", " \"OSet_LoLoLim\",\n", " \"Set_SimPV\",\n", " \"PCmd_ClearCapt\",\n", " \"PCmd_Acq\",\n", " \"PCmd_Rel\",\n", " \"PCmd_Lock\",\n", " \"PCmd_Unlock\",\n", " \"PCmd_Reset\",\n", " \"PCmd_HiHiAck\",\n", " \"PCmd_HiHiSuppress\",\n", " \"PCmd_HiHiUnsuppress\",\n", " \"PCmd_HiHiUnshelve\",\n", " \"PCmd_HiAck\",\n", " \"PCmd_HiSuppress\",\n", " \"PCmd_HiUnsuppress\",\n", " \"PCmd_HiUnshelve\",\n", " \"PCmd_LoAck\",\n", " \"PCmd_LoSuppress\",\n", " \"PCmd_LoUnsuppress\",\n", " \"PCmd_LoUnshelve\",\n", " \"PCmd_LoLoAck\",\n", " \"PCmd_LoLoSuppress\",\n", " \"PCmd_LoLoUnsuppress\",\n", " \"PCmd_LoLoUnshelve\",\n", " \"PCmd_FailAck\",\n", " \"PCmd_FailSuppress\",\n", " \"PCmd_FailUnsuppress\",\n", " \"PCmd_FailUnshelve\",\n", " \"MCmd_SubstPV\",\n", " \"MCmd_InpPV\",\n", " \"OCmd_ClearCapt\",\n", " \"MCmd_Acq\",\n", " \"MCmd_Rel\",\n", " \"OCmd_AcqLock\",\n", " \"OCmd_Unlock\",\n", " \"OCmd_Reset\",\n", " \"OCmd_ResetAckAll\",\n", " \"Val\",\n", " \"Val_InpPV\",\n", " \"Val_PVMinCapt\",\n", " \"Val_PVMaxCapt\",\n", " \"Val_PVEUMin\",\n", " \"Val_PVEUMax\",\n", " \"SrcQ_IO\",\n", " \"SrcQ\",\n", " \"Val_Fault\",\n", " \"Val_Mode\",\n", " \"Val_Owner\",\n", " \"Val_Notify\",\n", " \"Val_HiHiLim\",\n", " \"Val_HiLim\",\n", " \"Val_LoLim\",\n", " \"Val_LoLoLim\",\n", " \"Sts_SubstPV\",\n", " \"Sts_InpPV\",\n", " \"Sts_PVBad\",\n", " \"Sts_PVUncertain\",\n", " \"Sts_MaintByp\",\n", " \"Sts_AlmInh\",\n", " \"Sts_Err\",\n", " \"Err_Raw\",\n", " \"Err_EU\",\n", " \"Err_Timer\",\n", " \"Err_Filt\",\n", " \"Err_DB\",\n", " \"Err_Alarm\",\n", " \"Sts_Maint\",\n", " \"Sts_Prog\",\n", " \"Sts_Oper\",\n", " \"Sts_ProgOperLock\",\n", " \"Sts_NoMode\",\n", " \"Sts_MAcqRcvd\",\n", " \"Sts_HiHiCmp\",\n", " \"Sts_HiHiGate\",\n", " \"Sts_HiHi\",\n", " \"Alm_HiHi\",\n", " \"Ack_HiHi\",\n", " \"Sts_HiHiDisabled\",\n", " \"Sts_HiHiSuppressed\",\n", " \"Sts_HiHiShelved\",\n", " \"Sts_HiCmp\",\n", " \"Sts_HiGate\",\n", " \"Sts_Hi\",\n", " \"Alm_Hi\",\n", " \"Ack_Hi\",\n", " \"Sts_HiDisabled\",\n", " \"Sts_HiSuppressed\",\n", " \"Sts_HiShelved\",\n", " \"Sts_LoCmp\",\n", " \"Sts_LoGate\",\n", " \"Sts_Lo\",\n", " \"Alm_Lo\",\n", " \"Ack_Lo\",\n", " \"Sts_LoDisabled\",\n", " \"Sts_LoSuppressed\",\n", " \"Sts_LoShelved\",\n", " \"Sts_LoLoCmp\",\n", " \"Sts_LoLoGate\",\n", " \"Sts_LoLo\",\n", " \"Alm_LoLo\",\n", " \"Ack_LoLo\",\n", " \"Sts_LoLoDisabled\",\n", " \"Sts_LoLoSuppressed\",\n", " \"Sts_LoLoShelved\",\n", " \"Sts_FailCmp\",\n", " \"Sts_FailGate\",\n", " \"Sts_Fail\",\n", " \"Alm_Fail\",\n", " \"Ack_Fail\",\n", " \"Sts_FailDisabled\",\n", " \"Sts_FailSuppressed\",\n", " \"Sts_FailShelved\",\n", " \"Rdy_SubstPV\",\n", " \"Rdy_InpPV\",\n", " \"Rdy_Reset\",\n", " \"Rdy_ResetAckAll\",\n", " \"Rdy_OSet\",\n", " \"P_AIn\",\n", " \"inp_ProcessRunning\",\n", " \"LoLo\",\n", " \"Lo\",\n", " \"Hi\",\n", " \"HiHi\",\n", " \"Mode\",\n", " \"Cfg_EU\",\n", " \"Cfg_Tag\",\n", " \"Cfg_Label\",\n", " \"Cfg_Desc\",\n", " \"Fail\",\n", " \"Wrk_Notify\",\n", " \"Inf_Tab\",\n", " \"Wrk_Fault\",\n", " \"Wrk_SrcQ\",\n", " \"Wrk_SubstPV\",\n", " \"Wrk_UnfiltPV\",\n", " \"Wrk_Alpha\",\n", " \"Wrk_ScanT\",\n", " \"Wrk_ScanTime\",\n", " \"Wrk_FiltPV\",\n", " \"Wrk_ValidONS\",\n", " \"Wrk_SelPVDINT\",\n", " \"Wrk_SelPVInfNaN\",\n", " \"Inf_Type\",\n", " \"Wrk_Fail\",\n", " \"Wrk_LoLo\",\n", " \"Wrk_Lo\",\n", " \"Wrk_Hi\",\n", " \"Wrk_HiHi\",\n", " \"FailGate\",\n", " \"LoLoGate\",\n", " \"LoGate\",\n", " \"HiHiGate\",\n", " \"HiGate\",\n", " \"Wrk_InpInfNaN\",\n", " \"Wrk_InpDINT\",\n", " \"Inf_Lib\",\n", " \"Wrk_InpFail\",\n", " \"ONS_Supress\",\n", " \"ONS_Unsupress\",\n", " \"ONS_ProcessRunning\",\n", " \"ONS_ProcessNotRunning\"\n", " ]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "taglist = []\n", "basetag = \"AIn_IntakePressure\"\n", "for x in attributes:\n", " taglist.append(basetag + \".\" + x)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with LogixDriver('166.252.25.65') as plc:\n", " r = plc.read(*taglist)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "for x in r:\n", " print(x)" ] } ], "metadata": { "kernelspec": { "display_name": "pycomm", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }