Package: aindapy
import aindapy
import random
import time
import json
import datetimefrom numpy.core.numeric import _correlate_dispatcherimport loggingimport http.client as http_clienthttp_client.HTTPConnection.debuglevel = 1logging.basicConfig()logging.getLogger().setLevel(logging.DEBUG)requests_log = logging.getLogger("requests.packages.urllib3")requests_log.setLevel(logging.DEBUG)requests_log.propagate = Trueaindapy.config(logLevel=1)auth = aindapy.Auth(
apiUrl='https://aindaanalytics.com/ainda/api/',
userName='asdfasdfasdfsdfsdf',
passWord='asdfasdfsdf'
)The datasource now accepts only the ids, so pls check what is the correct id for it.Demo WareHouse                  dataWareHouseId=7, dataSourceId=20Ainda Packaging Line WareHouse  dataWareHouseId=8, dataSourceId=22dataSource = aindapy.DataSource(
auth=auth,
dataWareHouseId=7,
dataSourceId=20
)Generate Data for graphics that are not timeseriesdata = aindapy.Data(auth=auth, dataSource=dataSource, bufferSize=1000)Generate Data Sample for piedata.deleteDataKeys([
'basicdemo/pie1',
'basicdemo/pie2',
'basicdemo/bar1',
'basicdemo/bar2',
'basicdemo/bar10Columns',
'basicdemo/bar50Columns',
'basicdemo/scaleline250points',
'basicdemo/scaleline500points'
])
data.addToBuffer('basicdemo/pie1', random.randint(50, 150), 'Ilha 1')
data.addToBuffer('basicdemo/pie1', random.randint(70, 180), 'Ilha 2')
data.addToBuffer('basicdemo/pie1', random.randint(10, 75), 'Ilha 3')
data.addToBuffer('basicdemo/pie1', random.randint(25, 45), 'Ilha 4')data.addToBuffer('basicdemo/pie2', random.randint(50, 150), 'Ilha 1')
data.addToBuffer('basicdemo/pie2', random.randint(70, 180), 'Ilha 2')
data.addToBuffer('basicdemo/pie2', random.randint(10, 75), 'Ilha 3')
data.addToBuffer('basicdemo/pie2', random.randint(25, 45), 'Ilha 4')
data.addToBuffer('basicdemo/pie2', random.randint(25, 45), 'Ilha 4')
data.addToBuffer('basicdemo/pie2', random.randint(25, 45), 'Ilha 4')
data.addToBuffer('basicdemo/pie2', random.randint(25, 45), 'Ilha 4')Generate Data Sample for one bar graphic with 10 columnsfor step in range(10):
data.addToBuffer('basicdemo/bar10Columns', random.randint(50, 150), step)Generate Data Sample for one bar graphic with 50 columnsfor step in range(50):
data.addToBuffer('basicdemo/bar50Columns', random.randint(50, 150), step)Generate Data Sample for linefor step in range(250):
data.addToBuffer('basicdemo/scaleline250points',
random.randint(50, 150), step)for step in range(500):
data.addToBuffer('basicdemo/scaleline500points',
random.randint(50, 150), step)data.commit()Generate data for one timeseries datatag. This data we can not deleted what was added beforeIf the tag do not exist, the code create this tag inside our system.stag1 = aindapy.SensorTag(auth=auth, dataSource=dataSource, channel='1', datatag='XRND1', tag='Random Value 1', tag_unit='KG', tag_updaterate=1000)
stag2 = aindapy.SensorTag(auth=auth, dataSource=dataSource, channel='1', datatag='XRND2', tag='Random Value 2', tag_unit='KG', tag_updaterate=1000)tdata = aindapy.DataTimeSeries(auth=auth, dataSource=dataSource, bufferSize=1000)
for step in range(10000):
tdata.addToBuffer(sensorTag=stag1, timeStamp=datetime.datetime.now(), value=random.randint(45,90))# if you do not pass timestamp, we will generate internaly
tdata.addToBuffer(sensorTag=stag2, value=random.randint(45,90))tdata.commit()