當前位置: 首頁>>代碼示例>>Python>>正文


Python OpenOPC類代碼示例

本文整理匯總了Python中OpenOPC的典型用法代碼示例。如果您正苦於以下問題:Python OpenOPC類的具體用法?Python OpenOPC怎麽用?Python OpenOPC使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了OpenOPC類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: reconnect

   def reconnect(self):
       """ reconnect """
       log.info("reconnect...")
 
       info = ""
       
       if self._lock.locked() == False:
           #self.reconnecting = 1
           self._lock.acquire()
           try:
             
               #self.opc  = OpenOPC.open_client(self.host, self.port)
               #self.opc.connect(self.provider, self.host)
               if self.mode == 'dcom':
                   self.opc = OpenOPC.client("Graybox.OPC.DAWrapper", self.host)
               else:
                   self.opc  = OpenOPC.open_client(self.host, self.port)
           
               info =  self.opc.servers()
               info = info + self.opc.info()
               for group in self.groups:
               
                   self.create_group(group, self.groups[group])
             
               #self.reconnecting = 0
           except Exception, e:
               # release the lock
               info = "excetp: %s"%(e.message)
               log.error(info)
               log.error(traceback.format_exc())
               #self.reconnecting = 0
               
           finally:
開發者ID:mabotech,項目名稱:mabopy,代碼行數:33,代碼來源:opc_proxy.py

示例2: connect

 def connect(self):
     
     self._lock.acquire()
     
     self._lock.release()        
   
     try:
         #print self.host
         #print self.opc_host
         #print self.opc_server
         
         #self.opc  = OpenOPC.open_client(self.host, self.port)
         if self.mode == 'dcom':
             self.opc = OpenOPC.client("Graybox.OPC.DAWrapper", self.host)                     
         else:
             self.opc  = OpenOPC.open_client(self.host, self.port)
             
         self.opc.connect(self.opc_server, self.opc_host) 
         #info =  self.opc.servers()
         
         #print info
         
     except OPCError, oe:
         log.debug( str(oe) )
         raise Exception(oe.message)
開發者ID:mabotech,項目名稱:mabo.io,代碼行數:25,代碼來源:opc_proxy.py

示例3: connect

    def connect(self):
        
        logger.debug("connect...............")
        
        try:
            
            if conf["Use_Wrapper"]  == True:
                
                logger.debug(conf["DAWrapper"])
                
                self.opc_client = OpenOPC.client(conf["DAWrapper"], conf["HOST"])

                
            else:
                
                logger.debug(conf["PROVIDER"])
            
                self.opc_client = OpenOPC.open_client(conf["HOST"], conf["PORT"])

            self.opc_client.connect(conf["PROVIDER"], conf["OPC_HOST"]) 
                
            self.connected = 1
            
        except Exception as ex:
            logger.debug(ex)
            self.connected = 0
開發者ID:mabotech,項目名稱:mabo.io,代碼行數:26,代碼來源:opc_monitor.py

示例4: OPCconnect

def OPCconnect():
    opc = OpenOPC.client()
    #opc = OpenOPC.open_client('localhost')
    opc = OpenOPC.open_client(wm_global.OpcClientName)
    opc.servers()

    # opc.connect('KEPware.KEPServerEx.V4')

    opc.connect(wm_global.OpcServerName)
    return opc
開發者ID:chrylarson,項目名稱:WM,代碼行數:10,代碼來源:pythonprog.py

示例5: connect

    def connect(self):
        print "attempting OPC connection to", self.opc_name
        self.opc = OpenOPC.client()
        self.opc.connect(self.opc_name, self.opc_host)
        props = self.opc.properties(self.points.keys())
        print "loaded", len(props), "properties"
        points = {}
        for point, pid, key, val in props:
            name = self.make_path(point)
            if not name in points:
                points[name] = self.points[point]
            if not exclude(key):
                points[name]["OpcDA/" + key] = str(val)

        # try to make some sense out of the metadata
        for name, meta in points.iteritems():
            unit = str(meta.get("OpcDA/" + self.unit_tag, "None"))
            dtype = meta.get("OpcDA/Item Canonical DataType", None)
            if not dtype:
                print "no datatype tag in", name
                continue
            if dtype.startswith("VT_R"):
                dtype = "double"
            elif dtype.startswith("VT_U") or dtype.startswith("VT_I"):
                dtype = "long"
            else:
                print "skipping", name, "since cannot find data type"
                continue
            if not self.get_timeseries(name):
                self.add_timeseries(name, unit, data_type=dtype)
                self.set_metadata(name, points[name])
        vals = self.opc.read(self.points.keys(), group="smap-points-group")
開發者ID:rraabb,項目名稱:smap,代碼行數:32,代碼來源:opc.py

示例6: connect

def connect():
	''' return 2 connection objects: "opc" and "cursor" '''
	# PLC
	plc='Matrikon.OPC.Simulation.1'
	try:
		print "+------------+"
		print "|            | - Connecting to PLC...",
		opc=OpenOPC.client()
		opc.connect(plc)
		print "		Success!"
	except:
		print "Error connecting to OPC"
			
	print "| Connecting |"

	# MYSQL
	server='127.0.0.1'
	user='root'
	pasw=''
	dbName='mbr'
	try:
		print "|            | - Connecting to MySQL...",
		db=MySQLdb.connect(server,user,pasw,dbName)
		cursor = db.cursor()
		print "	Success!"
	except:
		print "Error connecting to MySQL"

	print "+------------+"
	return [opc,cursor]
開發者ID:holalluis,項目名稱:mbr,代碼行數:30,代碼來源:supervisor.py

示例7: connect

def connect():
    global opc 
    global list
    opc = None
    list = None
    if debug: print "Connecting..."
    r.set("connected", "BAD")
    while list is None:
        try:
            if debug: print "Connection Attempt {"
            opc = OpenOPC.open_client(opc_server)
            opc.connect(opc_server_name, opc_server)
            list = opc.list('Brave.calendar.opc_group')
            if debug: print "}"
            r.set("connected", "OK")
            r.set("opc_server", plc)
            r.set("opc_server_name", opc_server_name)
            r.set("plc", plc)
            r.set("redis_server", redis_server)
        except Exception as e:
            if debug: print e
            try:
                ping(opc_server, c=1)
                print {'error': 'Cannot connect to ' + opc_server_name, 'val': 0}
            except Exception as e:
                if debug: print e
                print {'error': 'Cannot connect to network', 'val': 0}
                pass
            pass
        finally:
            time.sleep(poll_rate)
開發者ID:casullivan,項目名稱:project,代碼行數:31,代碼來源:opc_redis.py

示例8: connect

    def connect(self):
        print "attempting OPC connection to", self.opc_name
        self.opc = OpenOPC.open_client(host=self.opc_host)
        self.opc.connect(self.opc_name, self.opc_host)
        if self.points is None:
            pointlist = self.opc.list(recursive=True, flat=True)
            self.points = self.parse_pointlist(pointlist)
        props = self.opc.properties(self.points.keys())
        print "loaded", len(props), "properties"
        points = {}
        for point, pid, key, val in props:
            key = key.decode().encode('ascii','ignore')
            key = key.replace(' ','')
            if isinstance(val, unicode) or isinstance(val, str):
                val = val.encode('ascii','ignore')
            name = self.make_path(point)
            if not name in points:
                points[name] = self.points[point]
            if not exclude(key):
                points[name]['OpcDA/' + key] = str(val)

        # try to make some sense out of the metadata
        for name, meta in points.iteritems():
            unit = str(meta.get('OpcDA/' + self.unit_tag, 'None'))
            dtype = meta.get('OpcDA/ItemCanonicalDataType', None)
            if not dtype:
                print "no datatype tag in", name
                continue
            dtype = 'double'
            if not self.get_timeseries(name):
                name = name.decode().encode('ascii','ignore')
                self.add_timeseries(name, unit, data_type=dtype)
                self.set_metadata(name, points[name])
        vals = self.opc.read(self.points.keys(), group="smap-points-group")
        self.updater = task.LoopingCall(self.update).start(self.rate)
開發者ID:aslakjohansen,項目名稱:smap,代碼行數:35,代碼來源:opc_auto.py

示例9: get_opc_info

 def get_opc_info(self,opc_server):
     print "Get opc server infomation"
     opc = OpenOPC.client() 
     opc.connect(opc_server)
     all = opc.info()
     opc.close()
     
     return all 
開發者ID:sompoch,項目名稱:nepohmi,代碼行數:8,代碼來源:pyro_opc_server.py

示例10: jobWriteOPC

def jobWriteOPC(TVpairs,opcserver='OPCManager.DA.XML-DA.Server.DA',client_name=None):
    opc = OpenOPC.client(client_name=client_name)
    opc.connect(opcserver)
    sleep(0.7)
    status = opc.write(TVpairs)
    sleep(0.7)
    opc.close()
    return status
開發者ID:ERIN-LIST,項目名稱:mogrepeau_repo,代碼行數:8,代碼來源:OPCThreadingtest.py

示例11: OPCCommand

def OPCCommand(self):
    '''
    You will also need to add the following to your config file:
    opc:
      server: 10.0.1.107
      name: OPC SERVER NAME
      tags: ["OPC-SERVER.Brightness_1.Brightness", "OPC-SERVER.TAGNAME"]
      tagcounter: OPC-SERVER.tag_which_is_int_that_tells_frame_has_changed


    This also requires the server you are connecting to be running the OpenOPC
    gateway service.  It comes bundled with OpenOPC.  To get it to route over
    the network you also have to set the windows environment variable OPC_GATE_HOST
    to the actual of the IP address of the server it's running on instead of 'localhost'
    otherwise the interface doesn't bind and you won't be able to connect via
    linux.
    '''
    try:
        import OpenOPC
    except:
        raise Exception('Requires OpenOPC plugin')

    from SimpleSeer.realtime import ChannelManager
    opc_settings = self.session.opc

    if opc_settings.has_key('name') and opc_settings.has_key('server'):
      self.log.info('Trying to connect to OPC Server[%s]...' % opc_settings['server'])
      try:
        opc_client = OpenOPC.open_client(opc_settings['server'])
      except:
        ex = 'Cannot connect to server %s, please verify it is up and running' % opc_settings['server']
        raise Exception(ex)
      self.log.info('...Connected to server %s' % opc_settings['server'])
      self.log.info('Mapping OPC connection to server name: %s' % opc_settings['name'])
      opc_client.connect(opc_settings['name'])
      self.log.info('Server [%s] mapped' % opc_settings['name'])
      
    if opc_settings.has_key('tagcounter'):
      tagcounter = int(opc_client.read(opc_settings['tagcounter'])[0])

    counter = tagcounter
    self.log.info('Polling OPC Server for triggers')
    while True:
      tagcounter = int(opc_client.read(opc_settings['tagcounter'])[0])

      if tagcounter != counter:
        self.log.info('Trigger Received')
        data = dict()
        for tag in opc_settings.get('tags'):
          tagdata = opc_client.read(tag)
          if tagdata:
            self.log.info('Read tag[%s] with value: %s' % (tag, tagdata[0]))
            data[tag] = tagdata[0]

        self.log.info('Publishing data to PUB/SUB OPC channel')
        ChannelManager().publish('opc/', data)
        counter = tagcounter
開發者ID:carriercomm,項目名稱:SimpleSeer,代碼行數:57,代碼來源:core_commands.py

示例12: __init__

    def __init__(self,canNum,modNum,host=hostDefault,srvName=srvNameDefault):
        self.canNum = canNum
        self.modNum = modNum

        #connect to OPC Server
        self.opc = OpenOPC.open_client(host)
        self.opc.connect(srvName,host)
        time.sleep(waittimeDefault)
        assert self.opc.ping()
開發者ID:pwuertz,項目名稱:qao,代碼行數:9,代碼來源:iSegControl.py

示例13: checkICONICS_Simulator

def checkICONICS_Simulator():
    opc = OpenOPC.client()
    opc.connect(IconicsSim)

    j=0
    for i in tagset:
        print i, ": ", opc[i]
        j = j+1

    opc.close()
開發者ID:UOCEAN,項目名稱:projTLcontrol,代碼行數:10,代碼來源:opcTest.py

示例14: Connect

 def Connect(self, RemoteHost="dcspc", RemotePort=7766, OPCHost="epdt120", OPCServer="OPC20CanOpen+"):
     self.RemoteHost = RemoteHost
     self.RemotePort = RemotePort
     self.OPCHost = OPCHost
     self.OPCServer = OPCServer
     print "Connectining to OPC server " + self.OPCServer + " on " + self.RemoteHost
     self.OPC = OpenOPC.open_client(self.RemoteHost, self.RemotePort)
     self.OPC.connect(self.OPCServer, self.OPCHost)
     print "Connected\nWaiting for OPC server to read all values from devices ..."
     time.sleep(10)
開發者ID:nlurkin,項目名稱:Other,代碼行數:10,代碼來源:ThControl.py

示例15: connect

    def connect(self):
        
        _lock.acquire()
        
        _lock.release()        
      
        try:
            self.opc  = OpenOPC.open_client(self.host, self.port)
            
            self.opc.connect(self.provider,self.host)      

        except Exception, e:
            
            raise Exception(e.message)
開發者ID:mabotech,項目名稱:mabo.io,代碼行數:14,代碼來源:opc_connector.py


注:本文中的OpenOPC類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。