{"id":19835371,"url":"https://github.com/equinor/opc-stream","last_synced_at":"2025-05-01T17:33:37.025Z","repository":{"id":148634410,"uuid":"428206007","full_name":"equinor/opc-stream","owner":"equinor","description":"Command-line utility to stream data from CSV-files into OPC DA-servers","archived":false,"fork":false,"pushed_at":"2024-01-10T08:25:04.000Z","size":1776,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-02-06T10:35:10.638Z","etag":null,"topics":["acceptance-testing","mpc","opc-da"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/equinor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.MD","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-11-15T09:49:15.000Z","updated_at":"2024-01-19T09:57:14.000Z","dependencies_parsed_at":"2023-03-30T07:09:20.995Z","dependency_job_id":null,"html_url":"https://github.com/equinor/opc-stream","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/equinor%2Fopc-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/equinor%2Fopc-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/equinor%2Fopc-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/equinor%2Fopc-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/equinor","download_url":"https://codeload.github.com/equinor/opc-stream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224270270,"owners_count":17283649,"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":["acceptance-testing","mpc","opc-da"],"created_at":"2024-11-12T12:07:46.873Z","updated_at":"2024-11-12T12:07:47.510Z","avatar_url":"https://github.com/equinor.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![overview](articles/images/opc-stream-overview.png)\n\n# opc-stream\nA windows console application that streams data from a Comma-Separated-Variable(or \"CSV\") file into a DA OPC-server. \n\nCSV-files are \"plain-text tables\" and are almost the de facto standard format for exchanging time-series data between different programs,\nas they are human-readable and creating drivers to read and write such files is usually quite easy to implement.\n\nThe intended use-case for this program is creating \"test benches\" for [\"acceptance testing\"](https://www.agilealliance.org/glossary/acceptance/) OPC-based applications like MPC. \n\n## Roadmap/development status\n\nThe program is stable/production ready. As ``opc-stream`` is intended as a simple utility, there is no active development planned beside fixing any bugs that may arise or adding small feature improvements if they improve convenience. \n\n## Syntax\n\nThe program will get settings from the accompanying ``opc-stream.exe.config``, so the program can also be called as\n```\nopc-stream.exe\n```\nwithout any command-line argument as long as ``CsvFile`` is set.\n\nThe name of the csv-file can also be given as a command line option:\n```\nopc-stream.exe exampleCSV.csv\n```\nTo set the server address, set ``DaOpcServerURI``  and to set the update frequency set ``SampleTime_ms`` in ``opc-stream.exe.config``.\n\n### Custom start- and/or end-date\n\nBy using the command line argument ``-s \"[datestring]\"`` and ``-e \"[datestring]\"`` it possible to run customizable portions of \nthe csv-file, for example\n\n```\nopc-stream.exe -s \"2021-09-24 20:42:00\" -e \"2021-11-15 01:38:58\"\n```\nwill stream only between those two dates from a csv-file that span much longer.\n\n### Mapping CSV-variable names to other names on the server\n\nBy using the command line argument ``-m \"[mappingCSVFilename]\"`` it is possible to define mappings that \nchange the names of the tags on the OPC-server relative to what they are in the CSV-server.\n\nThe CSV-file of mappings should have just two columns and no header, the first column is the variable name in \nthe CSV-file and the second column is the variable name to map to on the OPC-server, like so:\n```\ncsvName1;opcName1\ncsvName2;opcName2\n```\n\n*Syntax example:*\n```\nopc-stream.exe -m \"mappingFile.csv\"\n```\n*If a mapping file is given, unmapped signals are not added to the tag server.*\n\n### Editing opc-stream.exe.config\n\nThe entire ``opc-stream.exe.config`` will look something like this:\n```XML\n  \u003cappSettings\u003e\n    \u003c!-- the name of the csv-file can also be given as a command line input: --\u003e\n    \u003cadd key=\"CsvFile\" value=\"\"/\u003e\n    \u003cadd key=\"DaOpcServerURI\" value=\"localhost/Statoil.OPC.Server\"/\u003e\n    \u003cadd key=\"SampleTime_ms\" value=\"50\"/\u003e\n    \u003c!-- see valid formats: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings--\u003e\n    \u003cadd key=\"TimeStringFormat\" value=\"yyyy-MM-dd HH:mm:ss\"/\u003e\n    \u003c!-- if \"1\" then one line is outputted on screen for each time step, to disable set \"0\" --\u003e\n    \u003cadd key=\"BeVerbose\" value=\"1\"/\u003e\n    \u003cadd key=\"CsvSeparator\" value=\";\"/\u003e\n    \u003cadd key=\"TimeToSubtractFromEachWait_ms\" value=\"0\"/\u003e\n  \u003c/appSettings \u003e\n```\n\n## Trying it out: Test dataset\n\nThe repo comes with a test dataset in the folder ``TestData`` called ``minSelect.csv`` that can be used to test-run the program. \nNote that you need to have an OPC-server with the tags of the test dataset registered in order to run the example. \n\nPeaking into the ``minSelect.csv`` to see how the ``opc-stream`` expects the file to be formatted:\n- first row is the names of each variable, divided by separator ``CsvSeparator`` (in this case ``\";\"``)\n- first column is timestamps in string according to the ``TimeStringFormat``(in this case ``\"yyyy-MM-dd HH:mm:ss\"``)\n- each row below the first represents the values of each variable at that timestamp, separtor by the separator ``CsvSeparator``\n\n``minSelect.csv``: \n```CSV\nTime;PID1-Setpoint_Yset;PID2-Setpoint_Yset;Process-Disturbance_D;minSelect-SelectorOut;Process-Output_Y_sim;PID1-PID_U;PID2-PID_U\n2021-01-01 00:00:00;50;70;0;50;50;50;51\n2021-01-01 00:00:01;50;70;0.62668;50;50.628;50;51\n2021-01-01 00:00:02;50;70;1.2434;49.685;51.216;49.685;51\n2021-01-01 00:00:03;50;70;1.8406;49.39;51.759;49.39;50.685\n(and so on)\n```\n\n## Write speeds\n\nIn tests against the LightOPC server, the program is able to stream 100 tags at 50 Hz  (``SampleTime_ms==20``).\n\n## Timing \n\nBy setting ``SampleTime_ms`` it is possible to control the frequency at which new values from the CSV are written to the OPC-server.\n\nThe program tries to time each write operation and \"sleep\" for a appropriate amount for each so that it is able to maintain this write frequency.\n\n## Time-tags\n\nThe programs adds three timing-related tags to the OPC-server :\n\n``_Time_SecondsInMinute`` is an integer goes from 0 to 59 indicating the seconds in the date.\n\n``_Time_SecondsInHour`` is an integer that goes from 0 to 3599 indicating the seconds on the hour of the date.\n\n``_Time_System`` shows the total number of seconds since January 1 1970.\n\nIf you use other programs such as MPC to read data from the OPC server, and wish to run through at dataset at faster-than-realtime speeds, \nread either of these timing tags to determine how much time has elapsed between samples and synchronize. \n\n## Reading different kinds of CSV-formats\n\nThe format of the time-string in the first column can be specified by the string ``TimeStringFormat``.\nDefault is ``\"yyyy-MM-dd HH:mm:ss\"``, for valid formatting see:\nhttps://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings\n\nIt is possible to change what the \"separator\" in the CSV-file is to be, the two most typical are \";\" or \",\". \n\n## Dependencies/interface with other programs\n\nOne frequently used program to observe tag values on OPC servers is \"Matrikon OPC Explorer\".\n\nNote that when given a CSV-file, the program automatically spits out a ``opc-stream-taglist.txt`` which is suitable for \nregistering tags in the ``LightOPC server``.\n\n## Compatability\n\nNote that the program *must* be complied as x86, otherwise it will give an error when connecting to OPC-servers, because .NET interop COM assemblies are only 32-bit. \n\n## License and support\n\nWritten by Steinar Elgsæter for Equinor, the program and code is made open-source under the MIT license. \nIf there are any questions, please share them at the community discussion page https://github.com/equinor/opc-stream/discussions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fequinor%2Fopc-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fequinor%2Fopc-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fequinor%2Fopc-stream/lists"}