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

WindhoverLabs / phoebus / #77

03 Sep 2023 05:01PM UTC coverage: 16.544% (-0.02%) from 16.566%
#77

push

web-flow
Merge pull request #87 from WindhoverLabs/param_export

Param export

50 of 50 new or added lines in 3 files covered. (100.0%)

17740 of 107229 relevant lines covered (16.54%)

0.17 hits per line

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

0.0
/core/commander-core/src/main/java/com/windhoverlabs/pv/yamcs/YamcsPV.java
1
/*******************************************************************************
2
 * Copyright (c) 2014-2018 Oak Ridge National Laboratory.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 ******************************************************************************/
8
package com.windhoverlabs.pv.yamcs;
9

10
import com.windhoverlabs.yamcs.core.YamcsObjectManager;
11
import com.windhoverlabs.yamcs.core.YamcsServer;
12
import java.util.ArrayList;
13
import java.util.List;
14
import java.util.Objects;
15
import java.util.logging.Level;
16
import java.util.logging.Logger;
17
import org.epics.vtype.VInt;
18
import org.epics.vtype.VType;
19
import org.phoebus.pv.PV;
20
import org.phoebus.pv.loc.ValueHelper;
21
import org.yamcs.protobuf.Yamcs.NamedObjectId;
22

23
/**
24
 * Yamcs Process Variable Syntax: "ServerName:instance-name://path/to/pv/item"
25
 *
26
 * @author lgomez, based on similar code in org.csstudio.utility.pv
27
 */
28
@SuppressWarnings("nls")
29
public class YamcsPV extends PV {
30
  private volatile Class<? extends VType> type;
31
  private final List<String> initial_value;
32
  private YamcsAware yamcsListener;
33

34
  public static final Logger log = Logger.getLogger(YamcsServer.class.getPackageName());
×
35

36
  protected YamcsPV(
37
      final String actual_name,
38
      final Class<? extends VType> type,
39
      final List<String> initial_value) {
40
    super(actual_name);
×
41
    this.type = type;
×
42
    this.initial_value = initial_value;
×
43

44
    init(type, initial_value);
×
45
  }
×
46

47
  protected YamcsPV(final String actual_name, final Class<? extends VType> type) {
48
    super(actual_name);
×
49
    this.type = type;
×
50

51
    initial_value = new ArrayList<String>();
×
52

53
    init(type, initial_value);
×
54
  }
×
55

56
  protected void checkInitializer(
57
      final Class<? extends VType> type, final List<String> initial_value) {
58
    if (type != this.type || !Objects.equals(initial_value, this.initial_value))
×
59
      logger.log(
×
60
          Level.WARNING,
61
          "PV "
62
              + getName()
×
63
              + " was initialized as "
64
              + formatInit(this.type, this.initial_value)
×
65
              + " and is now requested as "
66
              + formatInit(type, initial_value));
×
67
  }
×
68

69
  private void init(final Class<? extends VType> type, final List<String> initial_value) {
70
    notifyListenersOfPermissions(true);
×
71

72
    yamcsListener =
×
73
        new YamcsAware() {
×
74
          public void onYamcsDisconnected() {
75
            try {
76
              notifyListenersOfDisconnect();
×
77
            } catch (Exception e) {
×
78
              // TODO Auto-generated catch block
79
              e.printStackTrace();
×
80
            }
×
81
          }
×
82

83
          public void changeProcessor(String instance, String processor) {
84
            try {
85
              notifyListenersOfDisconnect();
×
86
              //               this.not
87
            } catch (Exception e) {
×
88
              // TODO Auto-generated catch block
89
              e.printStackTrace();
×
90
            }
×
91
          }
×
92
        };
93

94
    YamcsObjectManager.addYamcsListener(yamcsListener);
×
95
  }
×
96

97
  private String formatInit(final Class<? extends VType> type, final List<String> value) {
98
    final StringBuilder buf = new StringBuilder();
×
99
    buf.append('<').append(type.getSimpleName()).append('>');
×
100
    if (value != null) {
×
101
      buf.append('(');
×
102
      for (int i = 0; i < value.size(); ++i) {
×
103
        if (i > 0) buf.append(",");
×
104
        buf.append(value.get(i));
×
105
      }
106
      buf.append(')');
×
107
    }
108
    return buf.toString();
×
109
  }
110

111
  @Override
112
  protected void close() {
113
    super.close();
×
114
  }
×
115

116
  public void updateValue() throws Exception {
117
    ArrayList<String> values = new ArrayList<String>();
×
118
    VType value = ValueHelper.getInitialValue(values, VInt.class);
×
119

120
    this.notifyListenersOfValue(value);
×
121
  }
×
122

123
  public void updateValue(VType value) throws Exception {
124
    this.notifyListenersOfValue(value);
×
125
  }
×
126

127
  public void onInvalidIdentification(NamedObjectId id) {
128
    System.out.println("onInvalidIdentification:" + id);
×
129
  }
×
130
}
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