Skip to main content

This is a small library that composing of Timeline and Network utility function.

Project description

TimelineNetworkUtility

A TimelineNetworkUtility is a small library that composing of Timeline and Network utility function. The timeline can help to manage the execution step of function. The useful of timeline is to help the embedded device to handle the sequence of the data reading from sensor. Which prevented the exceeding of reading speed limit of the hardware. The network utility provided the simple to use of some network function. Which include normal POST, base64 image POST, and client listening (SSE).

Usage

import TimelineNetworkUtility as STLS
import _thread as thread

def interval_time():
	pass;

def off_able():
	print('excute off_able');
	STLS.StepEnable("off_able", False);

def sensor1_read():
	print('read sensor1 data');

def sensor2_read():
	print('read sensor2 data');

def sensor_post():
	BodyP = {
    	'data': 'post data'
    };
    status, data = STLS.SendPOST(BodyP, ServerIP + ":" + ServerPORT, "/PostData.php");
    time = 15.0; # seconds
    off_able_enable = True;
    if not off_able_enable:
        STLS.ChangeStepTime("interval_time", round(time*10/2));
    else:
        STLS.StepEnable("off_able", True);

def image_post():
	BodyP = {
        "base64_image": base64_image
    };
	status, res = STLS.SendPOSTImage(BodyP, ServerIP + ":" + ServerPORT, "/PostImage.php");

def listen_to_server(thread_name, delay):
    try:
        STLS.StartPYTHONListen(ServerIP, ServerPORT, image_post, "/PythonListen.php");
    except KeyboardInterrupt:
        print("^C received, shutting down the listen");

try:
	thread.start_new_thread( listen_to_server, ("Thread-2", 2, ) );
except:
	print("Error: unable to start listen thread");

STLS.AddStep("interval_time", 25, interval_time, True);
STLS.AddStep("sensor1_read", 1, sensor1_read, True);
STLS.AddStep("sensor2_read", 1, sensor2_read, True);

STLS.AddStep("sensor_post", 1, LocalOperate, True);
STLS.AddStep("off_able", 30, off_able, False);
STLS.AddStep("interval_time", 25, interval_time, True);

STLS.EnableLoop(True);
STLS.Start();
STLS.Run();

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file TimelineNetworkUtility-zzenlightenzz-0.1.6.tar.gz.

File metadata

  • Download URL: TimelineNetworkUtility-zzenlightenzz-0.1.6.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for TimelineNetworkUtility-zzenlightenzz-0.1.6.tar.gz
Algorithm Hash digest
SHA256 5c263d97f6c2fc06b31bed5c693ae5eda671d03254cccffa014d4700b73b6210
MD5 3c3f966eb8fc92b78ee43885e9023ecd
BLAKE2b-256 26cbae2360c315d10b4813fb9ee8a85f25d08963aa81922add2ffad52fec2670

See more details on using hashes here.

File details

Details for the file TimelineNetworkUtility_zzenlightenzz-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for TimelineNetworkUtility_zzenlightenzz-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 66ef2cada55fe1cd9c0880d9eb0bf836ba2f21d2d0f9648b0ce8744177a1df58
MD5 acb57e5a832ffc205ba147ec0bee6e6a
BLAKE2b-256 43cd00efe991546dd3589d6b5a56a44d04af7cf4b5aaf9d758557dbf50e18af8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page