Exemple #1
0
 def resistance_check(self):
     if self.mid > self.dfD.iloc[-1]['Daily Pivot Point']:
         # print '**** Checking Resistance Pivots ****'
         resistance = Resistance(self.instrument, self.dfD, self.mid,
                                 self.units, self.pivot, self.rl1, self.rl2,
                                 self.rl3, self.sl1, self.sl2, self.sl3,
                                 self.rate1, self.rate2)
         units, stop_loss, profit = resistance.resistance()
         return units, stop_loss, profit
    def __init__(self,setting_file_path):
        with open(setting_file_path) as f:
            self._setting = json.load(f,"utf-8")

        self._circuit = circuit.parse(self._setting["GPIO"])
        self._current_status = self._circuit.get_status()

        self._on_resistance = Resistance(self._setting["on_resistance"],1,self._update_status)
        self._off_resistance = Resistance(self._setting["off_resistance"],0,self._update_status)

        self._pubnub = Pubnub(publish_key=self._setting["publish_key"], subscribe_key=self._setting["subscribe_key"])
        self._pubnub.subscribe(channels='plzcast_' + self._setting["group"], callback=self._callback_plzcast,connect=self._callback_connect, reconnect=self._callback_connect)
Exemple #3
0
 def res_check(self):
     if self.mid > self.dfD.iloc[-1]['D Pivot Point']:
         print '**** Checking Resistance Pivots ****'
         try:
             res = Resistance(self.instrument, self.mid, self.dfD,
                              self.breakout, self.pivot, self.rl1, self.rl2,
                              self.rl3, self.rate1, self.rate2)
             # print res.resistance()
             resLoss = res.resistance()
             loss = float(round(resLoss + .025, 3))
             return loss
         except:
             pass
Exemple #4
0
 def res_check(self):
     if self.mid > self.dfD.iloc[-1]['Daily Pivot Point']:
         print '**** Checking Resistance Pivots ****'
         res = Resistance(self.instrument, self.mid, self.dfD, self.units,
                          self.pivot, self.rl1, self.rl2, self.rl3,
                          self.rate1, self.rate2)
         print res.resistance()
         try:
             resUnits, resProfit, resLoss = res.resistance()
             resex = Execute(self.api, self._id, self.instrument, resUnits,
                             resProfit, resLoss)
             resex.trade()
         except Exception as e:
             print(e)
    def __init__(self, setting_file_path):
        with open(setting_file_path) as f:
            self._setting = json.load(f, "utf-8")

        self._circuit = circuit.parse(self._setting["GPIO"])
        self._current_status = self._circuit.get_status()

        self._on_resistance = Resistance(self._setting["on_resistance"], 1,
                                         self._update_status)
        self._off_resistance = Resistance(self._setting["off_resistance"], 0,
                                          self._update_status)

        self._pubnub = Pubnub(publish_key=self._setting["publish_key"],
                              subscribe_key=self._setting["subscribe_key"])
        self._pubnub.subscribe(channels='plzcast_' + self._setting["group"],
                               callback=self._callback_plzcast,
                               connect=self._callback_connect,
                               reconnect=self._callback_connect)
class WorkspaceSensor:
    def __init__(self, setting_file_path):
        with open(setting_file_path) as f:
            self._setting = json.load(f, "utf-8")

        self._circuit = circuit.parse(self._setting["GPIO"])
        self._current_status = self._circuit.get_status()

        self._on_resistance = Resistance(self._setting["on_resistance"], 1,
                                         self._update_status)
        self._off_resistance = Resistance(self._setting["off_resistance"], 0,
                                          self._update_status)

        self._pubnub = Pubnub(publish_key=self._setting["publish_key"],
                              subscribe_key=self._setting["subscribe_key"])
        self._pubnub.subscribe(channels='plzcast_' + self._setting["group"],
                               callback=self._callback_plzcast,
                               connect=self._callback_connect,
                               reconnect=self._callback_connect)

    def run(self):
        while True:
            sensor_status = self._circuit.get_status()
            if (sensor_status == 1):
                self._on_resistance.load()
                self._off_resistance.clear()
            else:
                self._off_resistance.load()
                self._on_resistance.clear()

            time.sleep(self._setting["duration"])

    def _send(self):
        message = json.dumps({
            "floor": self._setting["floor"],
            "id": self._setting["id"],
            "name": self._setting["name"],
            "status": self._current_status
        })

        self._pubnub.publish(channel='wkstatus_' + self._setting["group"],
                             message=message)

    def _callback_plzcast(self, message, channel):
        self._send()

    def _callback_connect(self, message):
        self._send()

    def _update_status(self, new_status):
        if (new_status != self._current_status):
            self._current_status = new_status
            self._send()
class WorkspaceSensor:
    def __init__(self,setting_file_path):
        with open(setting_file_path) as f:
            self._setting = json.load(f,"utf-8")

        self._circuit = circuit.parse(self._setting["GPIO"])
        self._current_status = self._circuit.get_status()

        self._on_resistance = Resistance(self._setting["on_resistance"],1,self._update_status)
        self._off_resistance = Resistance(self._setting["off_resistance"],0,self._update_status)

        self._pubnub = Pubnub(publish_key=self._setting["publish_key"], subscribe_key=self._setting["subscribe_key"])
        self._pubnub.subscribe(channels='plzcast_' + self._setting["group"], callback=self._callback_plzcast,connect=self._callback_connect, reconnect=self._callback_connect)

    def run(self):
        while True:
            sensor_status = self._circuit.get_status()
            if(sensor_status == 1):
                self._on_resistance.load()
                self._off_resistance.clear()
            else:
                self._off_resistance.load()
                self._on_resistance.clear()

            time.sleep(self._setting["duration"])

    def _send(self):
        message=json.dumps({
            "floor":self._setting["floor"],
            "id":self._setting["id"],
            "name":self._setting["name"],
            "status":self._current_status
        })

        self._pubnub.publish(channel='wkstatus_' + self._setting["group"],message=message)

    def _callback_plzcast(self,message,channel):
        self._send()

    def _callback_connect(self,message):
        self._send()

    def _update_status(self,new_status):
        if(new_status != self._current_status):
            self._current_status = new_status
            self._send()
Exemple #8
0
import sys
import socket
import threading
import logging
from resistance import Resistance
from cadence import Cadence
from power import calculate_power
from flask import Flask, jsonify, render_template

gymnasticon = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_address = ('localhost', 4000)
gymnasticon.bind(server_address)

app = Flask(__name__)
resistance = Resistance(gymnasticon)
cadence = Cadence(gymnasticon, resistance)


@app.route('/')
def hello():
    message = "Hello, World"
    return render_template('index.html', message=message)


@app.route('/status')
def get_status():
    power = calculate_power(cadence.get(), resistance.get())
    return jsonify({
        "power": power,
        "cadence": cadence.get(),
        "resistanceLevel": resistance.get(),
Exemple #9
0
def setValues():
    """Default settings

  :Returns:
    - Default settings for the probabilistic models for degradation of concrete.
  """

    # Concrete settings
    concrete = Concrete('C25/30')

    concrete.setWCratio(0.4)
    # values: (0.3),0.4,(0.45),0.5

    concrete.setCuringPeriod(1)
    # values: 1,3,7,28

    concrete.setGrade(45)
    # values: 45,40,25,35

    # Reinforcement settings
    reinforcement = Reinforcement('S500')
    reinforcement.setYieldStress(500)
    # values: all

    reinforcement.setDiameter(16)
    # values: (8),10,16,27

    reinforcement.setBars(1)
    # values: all

    # Geometry settings
    geometrie = Geometrie('Beam')
    geometrie.setCover(30)  # values: all
    geometrie.setBeamWidth(350)
    geometrie.setBeamHeight(550)
    geometrie.setBeamLength(5000)

    # Environment settings
    environment = Environment()

    environment.setZone('Submerged')
    # values: 'Submerged','Tidal','Splash','Atmospheric'

    environment.setHumidity(80)
    # values: 50,65,80,95,100

    # for the simplified corrosion rate:
    # environment.setExposure('Wet-Dry')
    # values: 'Wet','Wet-Dry','Airborne sea water','Tidal'

    environment.setTemperature(20)
    # values: all

    environment.setShelter('Unsheltered')
    # 'Sheltered','Unsheltered'

    # Chloride
    chloride = Chloride(concrete, geometrie, environment)

    # Carbonation
    carbonation = Carbonation(concrete, geometrie, environment)

    # Propagation
    rate = Propagation(environment)

    # Corrosion
    pitting = Pitting(reinforcement, rate)
    # pitting.setDeltaTime(50)
    # values: all

    # Resistance
    resistance = Resistance(concrete, reinforcement, geometrie, rate, pitting)

    return concrete, reinforcement, geometrie, environment, chloride, carbonation, rate, pitting, resistance