Appending CSV file with externalized properties? #1784
Unanswered
seiedsalad
asked this question in
Q&A
Replies: 2 comments 16 replies
-
Use Subjects and recycle the value. I don't have serial devices with me, so I couldn't test it. Workflow (Copy+Paste me)<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:port="clr-namespace:Bonsai.IO.Ports;assembly=Bonsai.System"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:io="clr-namespace:Bonsai.IO;assembly=Bonsai.System"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
<Expression xsi:type="rx:Defer">
<Name>FooDevice</Name>
<Workflow>
<Nodes>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Value" DisplayName="Name" />
</Expression>
<Expression xsi:type="PropertySource" TypeArguments="port:CreateSerialPort,sys:String">
<MemberName>Name</MemberName>
<Value>FooDevice</Value>
</Expression>
<Expression xsi:type="rx:AsyncSubject">
<Name>Name</Name>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="Name" />
</PropertyMappings>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Value" DisplayName="PortName" />
</Expression>
<Expression xsi:type="PropertySource" TypeArguments="port:CreateSerialPort,sys:String">
<MemberName>PortName</MemberName>
<Value>COM5</Value>
</Expression>
<Expression xsi:type="rx:AsyncSubject">
<Name>PortName</Name>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="PortName" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="port:CreateSerialPort">
<port:Name>Test</port:Name>
<port:PortName>COM5</port:PortName>
<port:BaudRate>9600</port:BaudRate>
<port:NewLine>\r\n</port:NewLine>
<port:Parity>None</port:Parity>
<port:ParityReplace>63</port:ParityReplace>
<port:DataBits>8</port:DataBits>
<port:StopBits>One</port:StopBits>
<port:Handshake>None</port:Handshake>
<port:DiscardNull>false</port:DiscardNull>
<port:DtrEnable>false</port:DtrEnable>
<port:RtsEnable>false</port:RtsEnable>
<port:ReadBufferSize>4096</port:ReadBufferSize>
<port:WriteBufferSize>2048</port:WriteBufferSize>
<port:ReceivedBytesThreshold>1</port:ReceivedBytesThreshold>
</Combinator>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>Name</Name>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="PortName" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="port:SerialReadLine">
<port:PortName>Test</port:PortName>
</Combinator>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>Name</Name>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:WithLatestFrom" />
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="2" To="3" Label="Source1" />
<Edge From="3" To="8" Label="Source1" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="6" To="7" Label="Source1" />
<Edge From="7" To="8" Label="Source2" />
<Edge From="9" To="10" Label="Source1" />
<Edge From="10" To="11" Label="Source1" />
<Edge From="11" To="13" Label="Source1" />
<Edge From="12" To="13" Label="Source2" />
<Edge From="13" To="14" Label="Source1" />
</Edges>
</Workflow>
</Expression>
<Expression xsi:type="rx:Defer">
<Name>BarDevice</Name>
<Workflow>
<Nodes>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Value" DisplayName="Name" />
</Expression>
<Expression xsi:type="PropertySource" TypeArguments="port:CreateSerialPort,sys:String">
<MemberName>Name</MemberName>
<Value>BarDevice</Value>
</Expression>
<Expression xsi:type="rx:AsyncSubject">
<Name>Name</Name>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="Name" />
</PropertyMappings>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Value" DisplayName="PortName" />
</Expression>
<Expression xsi:type="PropertySource" TypeArguments="port:CreateSerialPort,sys:String">
<MemberName>PortName</MemberName>
<Value>COM5</Value>
</Expression>
<Expression xsi:type="rx:AsyncSubject">
<Name>PortName</Name>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="PortName" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="port:CreateSerialPort">
<port:BaudRate>9600</port:BaudRate>
<port:NewLine>\r\n</port:NewLine>
<port:Parity>None</port:Parity>
<port:ParityReplace>63</port:ParityReplace>
<port:DataBits>8</port:DataBits>
<port:StopBits>One</port:StopBits>
<port:Handshake>None</port:Handshake>
<port:DiscardNull>false</port:DiscardNull>
<port:DtrEnable>false</port:DtrEnable>
<port:RtsEnable>false</port:RtsEnable>
<port:ReadBufferSize>4096</port:ReadBufferSize>
<port:WriteBufferSize>2048</port:WriteBufferSize>
<port:ReceivedBytesThreshold>1</port:ReceivedBytesThreshold>
</Combinator>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>Name</Name>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="PortName" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="port:SerialReadLine" />
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>Name</Name>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:WithLatestFrom" />
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="2" To="3" Label="Source1" />
<Edge From="3" To="8" Label="Source1" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="6" To="7" Label="Source1" />
<Edge From="7" To="8" Label="Source2" />
<Edge From="9" To="10" Label="Source1" />
<Edge From="10" To="11" Label="Source1" />
<Edge From="11" To="13" Label="Source1" />
<Edge From="12" To="13" Label="Source2" />
<Edge From="13" To="14" Label="Source1" />
</Edges>
</Workflow>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Merge" />
</Expression>
<Expression xsi:type="io:CsvWriter">
<io:Append>false</io:Append>
<io:Overwrite>false</io:Overwrite>
<io:Suffix>None</io:Suffix>
<io:IncludeHeader>false</io:IncludeHeader>
</Expression>
</Nodes>
<Edges>
<Edge From="0" To="2" Label="Source1" />
<Edge From="1" To="2" Label="Source2" />
<Edge From="2" To="3" Label="Source1" />
</Edges>
</Workflow>
</WorkflowBuilder> |
Beta Was this translation helpful? Give feedback.
9 replies
-
Ok, I'm getting a new error saying: "The given port name does not start with COM/com or does not resolve to a valid serial port" although I have already confirmed that these two ports are the correct ones. |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to do this? Currently, my CSVWriter is outputting only values coming from different serial ports (SerialReadLine) and timestamps from those values, but it's imperative that I know which serial port the values are coming from! I've spent a lot of time trying to figure this out so any help is appreciated! My most recent idea was externalizing the PortName from each SerialReadLine node and somehow appending them onto the resulting csv file but that doesn't seem to be working out. Attached existing workflow here.
Beta Was this translation helpful? Give feedback.
All reactions