• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

WindhoverLabs / yamcs-cfs / #157

25 Nov 2024 11:22PM UTC coverage: 0.0%. Remained the same
#157

push

web-flow
Merge 096a65ddf into e64813ef2

0 of 18 new or added lines in 13 files covered. (0.0%)

1 existing line in 1 file now uncovered.

0 of 6640 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/windhoverlabs/yamcs/tctm/ccsds/StreamTmFrameLink.java
1
package com.windhoverlabs.yamcs.tctm.ccsds;
2

3
import org.yamcs.ConfigurationException;
4
import org.yamcs.TmPacket;
5
import org.yamcs.YConfiguration;
6
import org.yamcs.logging.Log;
7
import org.yamcs.tctm.TcTmException;
8
import org.yamcs.tctm.ccsds.AbstractTmFrameLink;
9
import org.yamcs.yarch.ColumnDefinition;
10
import org.yamcs.yarch.DataType;
11
import org.yamcs.yarch.Stream;
12
import org.yamcs.yarch.StreamSubscriber;
13
import org.yamcs.yarch.Tuple;
14
import org.yamcs.yarch.TupleDefinition;
15
import org.yamcs.yarch.YarchDatabase;
16
import org.yamcs.yarch.YarchDatabaseInstance;
17

18
/**
19
 * Receives telemetry fames via UDP. One UDP datagram = one TM frame.
20
 *
21
 * <p>This is a TEMPORARY fix. The proper fix is adding the logic of removing the 4 bytes in
22
 * simlink.
23
 *
24
 * @author nm
25
 */
26
public class StreamTmFrameLink extends AbstractTmFrameLink implements StreamSubscriber {
×
27
  private volatile int invalidDatagramCount = 0;
×
28

29
  protected Log log;
30

31
  String packetPreprocessorClassName;
32
  Object packetPreprocessorArgs;
33
  Thread thread;
34
  protected Stream stream;
35
  protected int frameLength;
36

37
  static TupleDefinition gftdef;
38

39
  static final String RECTIME_CNAME = "rectime";
40
  static final String DATA_CNAME = "data";
41

42
  static {
43
    gftdef = new TupleDefinition();
×
44
    gftdef.addColumn(new ColumnDefinition(RECTIME_CNAME, DataType.TIMESTAMP));
×
45
    gftdef.addColumn(new ColumnDefinition(DATA_CNAME, DataType.BINARY));
×
46
  }
×
47

48
  /**
49
   * Creates a new UDP Frame Data Link
50
   *
51
   * @throws ConfigurationException if port is not defined in the configuration
52
   */
53
  public void init(String instance, String name, YConfiguration config)
54
      throws ConfigurationException {
55
    super.init(instance, name, config);
×
56
    String streamName = config.getString("stream");
×
57
    this.frameLength = config.getInt("frameLength");
×
58

59
    YarchDatabaseInstance ydb = YarchDatabase.getInstance(instance);
×
60
    this.stream = getStream(ydb, streamName);
×
61

62
    log = new Log(getClass(), instance);
×
63
    log.setContext(name);
×
64

65
    this.stream.addSubscriber(this);
×
66
  }
×
67

68
  private static Stream getStream(YarchDatabaseInstance ydb, String streamName) {
69
    Stream stream = ydb.getStream(streamName);
×
70
    if (stream == null) {
×
71
      try {
72
        ydb.execute("create stream " + streamName + gftdef.getStringDefinition());
×
73
      } catch (Exception e) {
×
74
        throw new ConfigurationException(e);
×
75
      }
×
76
      stream = ydb.getStream(streamName);
×
77
    }
78

79
    return stream;
×
80
  }
81

82
  @Override
83
  public void doStart() {
84
    notifyStarted();
×
85
  }
×
86

87
  @Override
88
  public void doStop() {
89
    notifyStopped();
×
90
  }
×
91

92
  /** returns statistics with the number of datagram received and the number of invalid datagrams */
93
  @Override
94
  public String getDetailedStatus() {
95
    if (isDisabled()) {
×
96
      return "DISABLED";
×
97
    } else {
98
      return String.format(
×
99
          "OK %nValid datagrams received: %d%nInvalid datagrams received: %d",
NEW
100
          validFrameCount.get(), invalidDatagramCount);
×
101
    }
102
  }
103

104
  @Override
105
  protected Status connectionStatus() {
106
    if (isDisabled()) {
×
107
      return Status.DISABLED;
×
108
    } else {
109
      return Status.OK;
×
110
    }
111
  }
112

113
  @Override
114
  public void onTuple(Stream arg0, Tuple tuple) {
115
    if (isRunning()) {
×
116
      byte[] pktData = tuple.getColumn(DATA_CNAME);
×
117
      long recTime = tuple.getColumn(RECTIME_CNAME);
×
118
      if (pktData == null) {
×
119
        throw new ConfigurationException("no column named '%s' in the tuple", DATA_CNAME);
×
120
      } else {
121
        if (pktData.length != this.frameLength) {
×
122
          /* This is not the correct size.  Reject it. */
123
          log.error(
×
124
              "Packet incorrect length. Expected {}.  Received {}",
125
              this.frameLength,
×
126
              pktData.length);
×
127
        } else {
128
          TmPacket tmPacket = new TmPacket(recTime, pktData);
×
129

130
          tmPacket.setEarthRceptionTime(timeService.getHresMissionTime());
×
131

132
          try {
133
            frameHandler.handleFrame(timeService.getHresMissionTime(), pktData, 0, pktData.length);
×
134
          } catch (TcTmException e) {
×
135
            e.printStackTrace();
×
136
          }
×
137
        }
138
      }
139
    }
140
  }
×
141
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc