Connecting to Agilent VWorks#
This guide will walk you through how to connect Artificial to Agilent VWorks using the Agilent VWorks Resource Library.
Attention
Before you get started, make sure your local Adapter development environment is set up and ready to go.
Supported Agilent VWorks versions#
Agilent VWorks 13.1
Install the driver#
Download and install the Artificial Agilent VWorks Driver on the PC where VWorks is running.
Note
For more information on how to install and configure the Driver, see our guide on Installing and Configuring Device Drivers.
Install the Resource Library in your Adapter#
Run the following command in the terminal of your adapter repository to install Artificial’s Agilent VWorks Resource Library:
uv add artificial-vworks-adapter==1.1.*
Your pyproject.toml
file should now include artificial-vworks-adapter
in the project dependencies section:
[project]
dependencies = [
...
"artificial-vworks-adapter==1.1.*",
]
Update your Adapter Config#
config.yaml
#adapter:
name: VWorksTutorialAdapter
remoteConfig: False
allowAnySequenceId: True # Useful when running in a local dev container
plugin: # all resources this adapter can connect to
resource:
name: "Bravo" # user friendly name, unique in the adapter
id: "bravo" # This should match the device key in the asset_sync section below
driver:
name: "vworks" # Driver name, this is a non-configurable string that needs to match the driver identity
url: "http://vworks.webaddress.com:49835" # URL of the hardware and driver
resource_simulation: false # Set to true to run simulation without hardware
driver_simulation: false # Set to true to run simulation without a driver
cert_file: "adapter/certs/ca.crt"
user_name: ""
user_password: ""
asset_sync:
devices: # device string names/prefix must match resource id above
"bravo": { rid: "d1234567-34d0-4391-be64-7aef4e0b28be" }
Fill in the correct URL (including the port) for the VWorks device. The device’s IPv4 URL can be obtained from Network & Internet Settings or by running
ipconfig
in a command window. The port is listed in the running driver server console window.You may update the resource name above if you wish. Any string will work but it must be unique across the instance.
Fill in the
user_name
andpassword
if needed.If you wish to run in simulation without hardware or without a driver, change
resource_simulation
ordriver_simulation
totrue
, respectively.Update the
asset_sync
section to map the resource id to the instrument’s asset instance id in the digital twin. You can fill out the rest of the devices later. See Asset Sync Config for more information.
Use the Resource Library in your Adapter#
adapter/main/plugin.py
file#from artificial.adapter_common import ActionModulePlugin, action_modules
from artificial.adapter_common.plugin import PluginContext, plugin_config
from artificial.logging import get_logger
from artificial.resource_base.asset_syncer import ResourceAssetSyncer
from artificial.resource_base.models import SyncConfig
from artificial.vworks.actions import VWorksActions
from artificial.vworks.core import VWorksResource
from artificial.vworks.driver_client_simulator import VWorksDriverMock as Simulator
from artificial.vworks.event_handler import VWorksEventHandler
from artificial.vworks.models import PluginConfig
logger = get_logger(__name__)
@action_modules(VWorksActions)
class AdapterPlugin(ActionModulePlugin):
"""assemble resources components with resource configuration"""
_cfg = plugin_config(PluginConfig) # this will make PluginConfig show up in the adapter config UI
async def setup(self, pctx: PluginContext) -> None:
plugin_conf = self._cfg
prog_config = pctx.config
sync_config: SyncConfig = pctx.raw_config.to_dataclass(SyncConfig, 'adapter.asset_sync')
logger.debug(f'sync_config loaded: {sync_config}')
# all resources in the adapter use the same res_syncer
syncer = pctx.asset_sync_manager_v1(f'ResourceSyncer-{prog_config.adapter.name}')
res_syncer = ResourceAssetSyncer(syncer, sync_config)
await res_syncer.initialize()
# create instances of resources for this adapter
resource = VWorksResource(
pctx.alabPyBase,
lab_id=prog_config.artificial.labId,
adapter_id=prog_config.adapter.name,
resource_id=plugin_conf.resource.id,
name=plugin_conf.resource.name,
res_syncer=res_syncer,
)
if resource: # hook up action modules and event handlers
resource.set_driver(driver_config=plugin_conf.resource.driver, simulator=Simulator())
await resource.set_health_monitors(pctx.lab.health)
self.add_module(VWorksActions(resource))
logger.debug('base action module added.')
# subscribe the events
event_handler = VWorksEventHandler(resource)
resource.add_event_handler(event_handler)
Add the required Actors#
Add the following actors to the list of actors in adapter/main/__main__.py
.
adapter/main/__main__.py
#actors = [
ActorConfig(id='bravo', abilities={'run_protocol': 1}),
]
Publish and run a test Workflow#
This workflow will run a method of your choosing and log a message in the UI upon successful completion. You will define which method to run in the request UI by inputting the method name with its full path (e.g., C://Methods//mymethod.med
).
Note
Update the variable params to reflect the needs of your protocol. If your protocol does not require variables, set params to an empty list ([]
).
from typing import List
from artificial.workflows.decorators import parameter, workflow
from artificial.workflows.runtime import show_info
from stubs.stubs_actions import VariableType, run_protocol_to_completion
@workflow('Simple Bravo Connectivity Test Workflow', 'simple_bravo_connectivity_test_workflow')
@parameter('vworks_protocol_name', {'required': True, 'uiTitle': 'VWorks Protocol Name'})
async def simple_vworks_connectivity_test_workflow(vworks_protocol_name: str) -> None:
params: List[VariableType] = [
VariableType(var_name='run_now', var_value='true', var_type='TrueFalse'),
VariableType(var_name='nplates', var_value='2', var_type='Numeric'),
VariableType(var_name='run_count', var_value='3', var_type='Numeric'),
]
await run_protocol_to_completion(vworks_protocol_name, params)
await show_info('Congratulations, you successfully ran your hardware!', 'Hardware Success')