{"id":16190677,"url":"https://github.com/tiagocoutinho/xia-pfcu","last_synced_at":"2025-10-24T12:15:00.473Z","repository":{"id":62589916,"uuid":"294410276","full_name":"tiagocoutinho/xia-pfcu","owner":"tiagocoutinho","description":"XIA PFCU python library with optional simulator and tango device","archived":false,"fork":false,"pushed_at":"2022-11-04T09:15:57.000Z","size":473,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T15:08:57.275Z","etag":null,"topics":["pfcu","python","simulator","tango","tango-server","xia"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tiagocoutinho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-10T12:58:13.000Z","updated_at":"2022-11-30T22:40:35.000Z","dependencies_parsed_at":"2023-01-23T12:45:12.581Z","dependency_job_id":null,"html_url":"https://github.com/tiagocoutinho/xia-pfcu","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiagocoutinho%2Fxia-pfcu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiagocoutinho%2Fxia-pfcu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiagocoutinho%2Fxia-pfcu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiagocoutinho%2Fxia-pfcu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiagocoutinho","download_url":"https://codeload.github.com/tiagocoutinho/xia-pfcu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243965723,"owners_count":20375920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pfcu","python","simulator","tango","tango-server","xia"],"created_at":"2024-10-10T07:43:53.354Z","updated_at":"2025-10-24T12:15:00.386Z","avatar_url":"https://github.com/tiagocoutinho.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XIA PFCU library\n\n\u003cimg align=\"right\" alt=\"XIA PF4\" height=\"300\" src=\"docs/pf4.png\" /\u003e\n\nThis library is used to control basic features of XIA PFCU equipment.\nIt is composed of a core library, an optional simulator and an optional\n[tango](https://tango-controls.org/) device server.\n\nIt has been tested with PF4 model, but should work with\nother models too.\n\nIt can be used with either with a direct serial line (read below\non the recommended way to setup a serial line connection) or remotely\nthrough TCP socket (either raw socket or rfc2217). In the latter case\nthe master device to which the Julabo serial line is connected must\nprovide a raw socket or rfc2217 interface.\n\n## Installation\n\nFrom within your favorite python environment type:\n\n`$ pip install xia-pfcu`\n\n## Library\n\nThe core of the library consists of PFCU object.\nTo create a PFCU object you need to pass a connection object.\nA compatible connection object can be created using the companion\n[connio](https://github.com/tiagocoutinho/connio) library which\nshould already be installed as a dependency.\n\nHere is how to connect to a PFCU through a local serial line:\n\n```python\nfrom connio import connection_for_url\nfrom xia_pfcu import PFCU\n\n\nasync def main():\n    conn = connection_for_url(\"serial://dev/ttyS0\")\n    dev = PFCU(conn)\n\n    raw_status = await dev.raw_status()\n    print(raw_status)\n\n    status = await dev.status()\n    if status['shutter_enabled']:\n        shutter_status = (await dev.shutter_status()).name\n    else:\n        shutter_status = \"Disabled\"\n    print(f\"Shutter status: {shutter_status}\")\n\n    # open shutter\n    await dev.open_shutter()\n\n\nasyncio.run(main())\n```\n\n#### Serial line\n\nTo access a serial line based PFCU device it is strongly recommended you spawn\na serial to tcp bridge using [ser2net](https://linux.die.net/man/8/ser2net),\n[ser2sock](https://github.com/tiagocoutinho/ser2sock) or\n[socat](https://linux.die.net/man/1/socat)\n\nAssuming your device is connected to `/dev/ttyS0` and the baudrate is set to 9600,\nhere is how you could use socat to expose your device on the machine port 5000:\n\n`socat -v TCP-LISTEN:5000,reuseaddr,fork file:/dev/ttyS0,rawer,b9600,cs8,eol=10,icanon=1`\n\nIt might be worth considering starting socat, ser2net or ser2sock as a service using\n[supervisor](http://supervisord.org/) or [circus](https://circus.rtfd.io/).\n\n### Simulator\n\nA PFCU simulator is provided.\n\nBefore using it, make sure everything is installed with:\n\n`$ pip install xia-pfcu[simulator]`\n\nThe [sinstruments](https://pypi.org/project/sinstruments/) engine is used.\n\nTo start a simulator you need to write a YAML config file where you define\nhow many devices you want to simulate and which properties they hold.\n\nThe following example exports 1 hardware device with a minimal configuration\nusing default values:\n\n```yaml\n# config.yml\n\ndevices:\n- class: PFCU\n  package: xia_pfcu.simulator\n  transports:\n  - type: serial\n    url: /tmp/pfcu-1\n```\n\nTo start the simulator type:\n\n```terminal\n$ sinstruments-server -c ./config.yml --log-level=DEBUG\n2020-09-14 10:42:27,592 INFO  simulator: Bootstraping server\n2020-09-14 10:42:27,592 INFO  simulator: no backdoor declared\n2020-09-14 10:42:27,592 INFO  simulator: Creating device PFCU ('PFCU')\n2020-09-14 10:42:27,609 INFO  simulator: Created symbolic link \"/tmp/pfcu-1\" to simulator pseudo terminal '/dev/pts/3'\n2020-09-14 10:42:27,609 INFO  simulator.PFCU[/tmp/pfcu-1]: listening on /tmp/pfcu-1 (baud=None)\n```\n\n(To see the full list of options type `sinstruments-server --help`)\n\nYou can access it as you would a real hardware. Here is an example using python\nserial library on the same machine as the simulator:\n\n```python\n$ python\n\u003e\u003e\u003e from connio import connection_for_url\n\u003e\u003e\u003e from xia_pfcu import PFCU\n\u003e\u003e\u003e conn = connection_for_url(\"serial:///tmp/pfcu-cf31\", concurrency=\"syncio\")\n\u003e\u003e\u003e dev = PFCU(conn)\n\u003e\u003e\u003e conn.open()\n\u003e\u003e\u003e print(dev.status())\n%PFCU15 OK PFCU v1.0 (c) XIA 1999 All Rights Reserved\nCHANNEL IN/OUT (FPanel   TTL  RS232) Shorted? Open?\n    1     OUT     OUT    OUT   OUT      NO      NO\n    2     OUT     OUT    OUT   OUT      NO      NO\n    3      IN     OUT    OUT    IN      NO      NO\n    4     OUT     OUT    OUT   OUT      NO      NO\nRS232 Control Enabled: YES\nRS232 Control Only: NO\nShutter Mode Enabled: NO\nExposure Decimation:     1\n```\n\n### Tango server\n\nA [tango](https://tango-controls.org/) device server is also provided.\n\nMake sure everything is installed with:\n\n`$ pip install xia-pfcu[tango]`\n\nRegister a PFCU tango server in the tango database:\n```\n$ tangoctl server add -s PFCU/test -d PFCU test/pfcu/1\n$ tangoctl device property write -d test/pfcu/1 -p address -v \"tcp://controls.lab.org:17890\"\n```\n\n(the above example uses [tangoctl](https://pypi.org/project/tangoctl/). You would need\nto install it with `pip install tangoctl` before using it. You are free to use any other\ntango tool like [fandango](https://pypi.org/project/fandango/) or Jive)\n\nLaunch the server with:\n\n```terminal\n$ PFCU test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiagocoutinho%2Fxia-pfcu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiagocoutinho%2Fxia-pfcu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiagocoutinho%2Fxia-pfcu/lists"}