Skip to content

No data exists for extended channels. #1

Description

@maple100

I changed the source to support the expansion channel and tested it, and it is working.
Share the webpage and changed source for the expansion channel.
image

#Edit def append_graphtec_readings(self)frombs4importBeautifulSoupfromrequestsimportgetfrompandasimportDataFrameclassGraphtec:
#-----------------------------------def__init__(self, address, resource_manager):
self.address=addressself.tcpip_gl=f"TCPIP::{self.address}::8023::SOCKET"# TCPIP adress to contactself.instrument=resource_manager.open_resource(self.tcpip_gl,
write_termination='\n',
read_termination='\r\n')
self.query_id=self.get_graphtec_idn()
self.data= [] # Holds measurement data#-----------------------------------defappend_graphtec_readings(self):
"""Find all the measurements of the channels and append to self.data list"""# Format URLaddress_channel_data=f"http://{self.address}/digital.cgi?chgrp=13"# Get http responseresponse=get(address_channel_data) # Get response from the channel data page# Create response tablesoup_object=BeautifulSoup(response.text, 'html.parser') # Create a soup object from this, which is used to create a tabletemps=soup_object.select('b')
# Loop over table to yield formatted datachannels_data= []
# Holds all the found data > in format: [('CH 1', '+ 10', 'degC'), (CH2 ....]temps= [read_tag.get_text(strip=True) forread_tagintemps]
count=2foridx, tempinenumerate(temps):
ifidx==count:
channels_data.append(temps[idx-2:idx+1])
count=count+3# Append the data to the listself.data.append(channels_data)
#-----------------------------------defget_graphtec_idn(self):
"""SCPI command to get IDN"""idn=self.instrument.query("*IDN?")
returnidn#-----------------------------------defadd_channel_data_to_df(self):
"""Post processing method to format self.data list into a Pandas DataFrame"""name_index=0# Format is ['CH 1', '23.56', 'degC']reading_index=1# so index 0, 1 and 2 are, respectively channel name, value reading and unit.unit_index=2channel_count=len(self.data[0]) # Amount of channels to loop over, might depend on Graphtec device (I have 20)df=DataFrame()
# Loop over each channelforchannel_indinrange(channel_count):
channel_name=self.data[0][channel_ind][name_index] # get the channel namechannel_unit=self.data[0][channel_ind][unit_index] # and unitcolumn_name=f"GRPH {channel_name} [{channel_unit}]"# Format column name "GRPH CH1 [degC]"channel_readings= [] # Stores the channel data > [0.0, 0.1, 0.0 ....]# Loop over each row and retrieve channel dataforrowinself.data:
channel_reading=row[channel_ind][reading_index] # Read the data of channel for this row# Value formattingifchannel_reading=='-------'orchannel_reading=='+++++++'orchannel_reading=='BURNOUT':
channel_reading=None#"NaN" # NaN for false valueselse:
channel_reading=float(channel_reading.replace(' ',''))# Float for other values, remove spaces in order to have +/-channel_readings.append(channel_reading)
df[column_name] =channel_readings# Add a new column with datareturndf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions