Metadata-Version: 2.1
Name: aindapy
Version: 0.0.14
Summary: Ainda Package made for python lovers. This is inteded to be used on ainda private cloud
Home-page: https://bitbucket.org/xsensors/aindapy
Author: Rafael Lima, Edgar Medina
Author-email: 
License: UNKNOWN
Project-URL: Bug Reports, https://bitbucket.org/xsensors/aindapy/issues
Project-URL: Source, https://bitbucket.org/xsensors/aindapy/
Keywords: aindapy,ainda,aindavision.com,aindaanalytics.com
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.6, <4
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: requests
Requires-Dist: Pillow
Provides-Extra: dev
Requires-Dist: check-manifest ; extra == 'dev'
Provides-Extra: test
Requires-Dist: coverage ; extra == 'test'

import aindapy
import random
import time
import json
import datetime

from numpy.core.numeric import _correlate_dispatcher

# import logging
# import http.client as http_client
# http_client.HTTPConnection.debuglevel = 1
# logging.basicConfig()
# logging.getLogger().setLevel(logging.DEBUG)
# requests_log = logging.getLogger("requests.packages.urllib3")
# requests_log.setLevel(logging.DEBUG)
# requests_log.propagate = True

aindapy.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=20
# Ainda Packaging Line WareHouse  dataWareHouseId=8, dataSourceId=22

dataSource = aindapy.DataSource(
    auth=auth,
    dataWareHouseId=7,
    dataSourceId=20
)


# Generate Data for graphics that are not timeseries

data = aindapy.Data(auth=auth, dataSource=dataSource, bufferSize=1000)

# Generate Data Sample for pie
data.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 columns
for step in range(10):
    data.addToBuffer('basicdemo/bar10Columns', random.randint(50, 150), step)


# Generate Data Sample for one bar graphic with 50 columns
for step in range(50):
    data.addToBuffer('basicdemo/bar50Columns', random.randint(50, 150), step)


# Generate Data Sample for line
for 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 before
# If 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()

