RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题

全部问题

Martin Hope
Xelo
Asked: 2025-04-08 10:36:49 +0000 UTC

mpf 和 plt 图表在时间尺度上不匹配

  • 5

我试图显示沿 x 轴链接的 4 个图形,其中 1 个使用 mpf 显示,其余的是 plt,但由于某些我无法理解的原因,它们无法及时匹配,输入数据来自同一来源。以下是代码:

    fig, (ax1,ap1,ap2,ap3) = plt.subplots(4, 1, sharex=True)
    mpf.plot(df_1m,type='candle',style='sas',ax=ax1,volume=False)
    ap1.plot(df_1m['rsi'], label= '1m')
    ap2.plot(df_5m['rsi'], label = '5m')
    ap3.plot(df_h1['rsi'], label = '1h')
    ap1.legend()
    ap2.legend()
    ap3.legend()
    mpf.show()

图中显示如下,只显示一个时间戳 在此处输入图片描述

提前感谢您的回答

matplotlib
  • 1 个回答
  • 25 Views
Martin Hope
Escator
Asked: 2025-04-07 15:43:10 +0000 UTC

在 PlatformIO VS Code 中编译单元测试时,编译器看不到 .cpp 实现文件

  • 5

我正在pod上开展一个项目Arduino C++,当我决定对逻辑进行测试时遇到了一个问题。问题的本质如下:整个项目被分成带有头文件()和实现()的类。这些文件正如预期的那样位于各自的文件夹中 - 标题在,实现在,测试在。PlatformIOVS Code.h.cppincludesrctest

项目结构(这是一个用于演示问题的示例项目):

项目结构

我运行测试并收到链接错误:

Linking .pio/build/native/program
/usr/bin/ld: .pio/build/native/test/mtest.o: в функции «test()»:
mtest.cpp:(.text+0x39): неопределённая ссылка на «MyClass::MyClass()»
/usr/bin/ld: mtest.cpp:(.text+0x4a): неопределённая ссылка на «MyClass::calc(int)»
/usr/bin/ld: .pio/build/native/test/mtest.o: в функции «test2()»:
mtest.cpp:(.text+0xa9): неопределённая ссылка на «MyClass::MyClass()»
/usr/bin/ld: mtest.cpp:(.text+0xe1): неопределённая ссылка на «MyClass::getString(char*)»

很明显,编译器没有从文件夹中找到文件src。如果MyClass.cpp将实现文件移动到文件夹test,则所有内容都会编译并运行。但对于一个有几十个类的项目来说,采取这样的举措是不可行的。请告诉我如何修复此问题,以便文件来自src。已编译并链接。

这是我的platformio.ini(我已经尝试过的选项已被注释)

[env:uno]
platform = atmelavr
board = uno
framework = arduino

[env:native]
platform = native
build_src_filter = 
    +<src/*>     # Все файлы из папки src
    +<test/*>    # Все файлы из папки test
    ; src/MyClass.cpp
    ; test/mtest.cpp
    ; src/MyClass.cpp    # Путь к исходнику
    ; test/*.cpp         # Тесты
build_flags = 
    -std=c++11
lib_deps = 
    throwtheswitch/Unity@^2.6.0
    ArduinoFake

为了以防万一,以下是源代码: MyClass.h

#ifdef TEST
#include <ArduinoFake.h>
#else
#include<Arduino.h>
#endif // TEST

class MyClass
{
private:
    /* data */
public:
    MyClass();
    int calc(int a);
    char* getString(char* src);
};

MyClass.cpp

#include "MyClass.h"

MyClass::MyClass()
{
}

int MyClass::calc(int a) {
    return a * a;
}

char* MyClass::getString(char* src) {
    return src + 3;
}

mtest.cpp

#define TEST
#include <unity.h>
#include "MyClass.h"

void setUp() {}
void tearDown() {}

void test() {
    MyClass clazz;
    TEST_ASSERT_EQUAL_INT16(clazz.calc(2), 4);
}

void test2() {
    MyClass clazz;
    char src[] = {"123456789"};
    char expected[] = {"456789"};
    char* actual = clazz.getString(src);
    TEST_ASSERT_EQUAL_STRING(expected, actual);
}

int main() {
    UNITY_BEGIN();
    RUN_TEST(test);
    RUN_TEST(test2);
    return UNITY_END();
}
c++
  • 1 个回答
  • 35 Views
Martin Hope
Robot Programmer
Asked: 2025-04-07 14:17:43 +0000 UTC

请检查我的代码的编程质量

  • 2
#include <stdio.h>
#include <time.h>
#include <unistd.h>

int main(){
    char command[50]; // массив для ввода комманды
    char* time_start;                                                               
    time_t t = time(NULL);                                                        
    time_start = ctime(&t);               

    printf("************************   Welcome to danyOS   *************************\n");
    
    while (1 == 1){
        printf("~user$ ");
        scanf("%s", command);
        if ((command[0] == 't') &&(command[1] == 'e') && (command[2] == 's') && (command[3] == 't')){
            printf("System is OK\n");
        }
        else if ((command[0] == 'd') &&(command[1] == 'a') && (command[2] == 't') && (command[3] == 'e') && (command[4] == 't') && (command[5] == 'i') && (command[6] == 'm') && (command[7] == 'e')){                                       
            t = time(NULL);
            time_start = ctime(&t);                                                                     
            printf("%s", time_start);       
        }
        /*
        else if((command[0] == "N") && (command[1] == "I") && (command[2] == "P")){ // работа с NIP
            printf("package NIP readding...\n");

            FILE *nip_file;
            nip_file = fopen("NIP.txt","r");            
            scanf("%s", command);
            if ()
        }
        */
        else if((command[0] == 'c') &&(command[1] == 'a') && (command[2] == 'l') && (command[3] == 'c')){
            long long int number1 = 0;
            long long int number2 = 0;
            char calc_command[1];
            printf("Input first number: ");
            scanf("%d", &number1);
            printf("Input second number:");
            scanf("%d", &number2);
            printf("Input command (+, -, /, *): ");
            scanf("%s", calc_command);
            if (calc_command[0] == '+'){
                printf("Result = %d\n", number1 + number2);
            }
            else if (calc_command[0] == '-'){
                printf("Result = %d\n", number1 - number2);
            }
            else if (calc_command[0] == '*'){
                printf("Result = %d\n", number1 * number2);
            }
            else if (calc_command[0] == '/'){
                printf("Result = %d\n", number1 / number2);
            }   
            else{
                printf("Wrong command!\n");
            }   
        }
        else if((command[0] == 't') &&(command[1] == 'i') && (command[2] == 'm') && (command[3] == 'e') && (command[4] == 'r')){
            int timer_time = 0;
            printf("Timer successfully!\n");
            printf("Input time in minutes: ");
            scanf("%d", &timer_time);
            timer_time = timer_time * 60;       
            printf("To continue, press any key\n");
            getchar();
            getchar();  
            printf("Timer start!\n");           
            for (int i = 0; i < timer_time; i++){                                               
                timer_time = timer_time - 1;
                printf("Timer: %d\n",timer_time);
                sleep(1);
            }
            printf("\nTime is up!\n");
        }                                    
        else{
            printf("No such command!\n");
        }       
    }   
    return 0;
}   
c
  • 1 个回答
  • 30 Views
Martin Hope
Alex Fiks
Asked: 2025-04-07 13:22:59 +0000 UTC

如何在 BASH 中将子进程附加到新的父进程

  • 6

关于任务的一些信息:我们在 Linux(Astra,再次是 OS)中工作。有壳。一个程序从其下启动,该 shell 是该程序的父级。 shell 源已关闭、未知且无法更改。在这个程序内部,调用了一个 bash 脚本,该程序本身是该脚本的父级。脚本决定需要重新启动程序,但是如果您愚蠢地执行此操作(终止该进程并创建一个新进程),则原始 shell 将无法直接查看它启动的程序,并且其进一步的操作将无法预测。重新启动 shell 是一种可行但不是理想的解决方案(除非我找到更好的方法,否则我会坚持使用这个解决方案)。除其他外,还需要shell来处理程序工作的结果,因此单独运行该程序也不是最好的选择。

问题出现了:有没有办法将衍生的或已经运行的进程绑定到另一个父进程?有没有针对 bash 的解决方案,或者最好尝试用 C 做一些事情?

linux
  • 2 个回答
  • 28 Views
Martin Hope
Макс Тимашков
Asked: 2025-04-07 03:36:58 +0000 UTC

Unity中的距离计算和物体移动

  • 6

图片示例

再会。需要幫助。理解向量及其计算非常困难。在这个例子中,我需要找到哪个红球最接近绿球并将它移动到它那里。我理解这个逻辑,你需要检查所有物体之间的距离,取最小的物体并沿着这个向量移动。我只是不明白如何在代码中实现这一点。

c#
  • 1 个回答
  • 39 Views
上一页
下一页

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5