当前位置: 首页>>代码示例>>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;未经允许,请勿转载。