Browse Source

removed RemotePin and some minor changes

digital 8 years ago
parent
commit
1d792cab3d
1 changed files with 8 additions and 39 deletions
  1. 8 39
      pin/__init__.py

+ 8 - 39
pin/__init__.py

@@ -16,17 +16,15 @@
 # You should have received a copy of the GNU General Public License
 # along with DigiLib.  If not, see <http://www.gnu.org/licenses/>.
 
+# Python modules
 import logging
+# Third party modules
+import curio
 import digilib.network
 
 log = logging.getLogger(__name__+"")
 lpin = logging.getLogger(__name__+".pin")
 
-client = digilib.network.Client("perry",5069,af_family="AF_INET")
-client.daemon = True
-client.start()
-client.connect()
-
 #
 # class PinBase(object):
 #     """docstring for PinBase."""
@@ -67,31 +65,7 @@ class PinBase(object):
         )
         return self.value
 
-class RemotePin(PinBase):
-    """RemotePin represents a remote pin"""
-    def output(self,value):
-        lpin.info(
-            "pin {} set to {}".format(
-                str(self.pin_number),
-                str(value)
-            )
-        )
-        self.value = value
-        client.send("set {} {}".format(
-                str(self.pin_number),
-                str(value)
-            )
-        )
-    def read(self):
-        lpin.debug(
-            "pin {} has value {}".format(
-                str(self.pin_number),
-                str(self.value)
-            )
-        )
-        return self.value
-
-class DigitalPin(RemotePin):
+class DigitalPin(PinBase):
     value_high = True
     value_low = False
     def __init__(self,pin_number):
@@ -129,18 +103,13 @@ class PCEngine(PinControllerBase):
     def set_speed(self,speed):
         self.pin_analog.output(speed)
         self.speed = speed
-    def turn_on(self,speed=turn_on_speed):
-        if self.is_on:
-            return
-        self.set_speed(speed)
-        self.pin_on_off.output(1)
-        self.is_on = True
-    def turn_off(self,speed=turn_on_speed):
-        if not self.is_on:
+    def set_state(self,state):
+        """state is boolean and specifies if the engine should be turned on (True) or turned off (False) """
+        if state == self.is_on:
             return
         self.set_speed(speed)
         self.pin_on_off.output(1)
-        self.is_on = True
+        self.is_on = state
 
 
 class PinAPIBase(object):