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

nasa / trick / 25456501308

06 May 2026 07:29PM UTC coverage: 55.935% (-0.8%) from 56.7%
25456501308

Pull #2011

github

web-flow
Merge 7ad262960 into 7054e405e
Pull Request #2011: Single-file CI and code style adoption

14612 of 26123 relevant lines covered (55.94%)

462107.16 hits per line

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

0.0
/trick_source/sim_services/MonteCarlo/MonteVarCalculated.cpp
1
#include <iostream>
2
#include <sstream>
3

4
#include "trick/MonteVarCalculated.hh"
5
#include "trick/memorymanager_c_intf.h"
6
#include "trick/message_proto.h"
7
#include "trick/message_type.h"
8

9
Trick::MonteVarCalculated::MonteVarCalculated(std::string in_name, std::string in_unit) {
×
10
    this->name = in_name;
×
11
    this->unit = in_unit;
×
12

13
    ref2 = ref_attributes(name.c_str());
×
14
    if (ref2 == NULL) {
×
15
        message_publish(MSG_ERROR, "Monte : MonteVarCalculated could not find parameter %s.\n", name.c_str()) ;
×
16
    }
17
}
×
18

19
// Composite the various properties of this MonteVarCalculated.
20
std::string Trick::MonteVarCalculated::describe_variable()
×
21
{
22
    std::stringstream ss;
×
23

24
    ss << "#NAME:\t" << this->name << "\n"
×
25
       << "#TYPE:\tCALCULATED\n" 
26
       << "#UNIT:\t" << this->unit << "\n";
×
27

28
    return ss.str();
×
29
}
×
30

31
std::string Trick::MonteVarCalculated::get_next_value() {
×
32
    char buffer[128];
33
    if (ref2 != NULL) {
×
34
        switch (ref2->attr->type) {
×
35
            case TRICK_CHARACTER:
×
36
            case TRICK_UNSIGNED_CHARACTER:
37
                snprintf(buffer, sizeof(buffer), "%d", *(char *)ref2->address);
×
38
                value = buffer;
×
39
                break;
×
40
            case TRICK_SHORT:
×
41
            case TRICK_UNSIGNED_SHORT:
42
                snprintf(buffer, sizeof(buffer), "%d", *(short *)ref2->address);
×
43
                value = buffer;
×
44
                break;
×
45
            case TRICK_INTEGER:
×
46
            case TRICK_UNSIGNED_INTEGER:
47
                snprintf(buffer, sizeof(buffer), "%d", *(int *)ref2->address);
×
48
                value = buffer;
×
49
                break;
×
50
            case TRICK_LONG:
×
51
            case TRICK_UNSIGNED_LONG:
52
                snprintf(buffer, sizeof(buffer), "%ld", *(long *)ref2->address);
×
53
                value = buffer;
×
54
                break;
×
55
            case TRICK_LONG_LONG:
×
56
            case TRICK_UNSIGNED_LONG_LONG:
57
                snprintf(buffer, sizeof(buffer), "%lld", *(long long *)ref2->address);
×
58
                value = buffer;
×
59
                break;
×
60
            case TRICK_FLOAT:
×
61
                snprintf(buffer, sizeof(buffer), "%.15g", *(float *)ref2->address);
×
62
                value = buffer;
×
63
                break;
×
64
            case TRICK_DOUBLE:
×
65
                snprintf(buffer, sizeof(buffer), "%.15g", *(double *)ref2->address);
×
66
                value = buffer;
×
67
                break;
×
68
            default:
×
69
                snprintf(buffer, sizeof(buffer), "#Unsupported value type %d", ref2->attr->type) ;
×
70
                break ;
×
71
        }
72

73
        if (unit.empty()) {
×
74
            return name + std::string(" = ") + value;
×
75
        } else {
76
            return name + std::string(" = trick.attach_units(\"") + unit + std::string("\", ") + value + std::string(")");
×
77
        }
78
    }
79
    return NULL;
×
80
}
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