mainwindow.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <iostream>
  4. MainWindow::MainWindow(QWidget *parent) :
  5. QMainWindow(parent),
  6. ui(new Ui::MainWindow)
  7. {
  8. ui->setupUi(this);
  9. mpa = iv::modulecomm::RegisterSend(gstrmemname.data(),1000,1);
  10. setWindowTitle("sample1");
  11. givlog->info("sample1 start ok");
  12. givfault->SetFaultState(0,0,"Started OK");
  13. }
  14. MainWindow::~MainWindow()
  15. {
  16. delete ui;
  17. }
  18. void MainWindow::on_horizontalSlider_valueChanged(int value)
  19. {
  20. iv::samplemsg xsam;
  21. xsam.set_mvalue(value);
  22. xsam.set_msendtime(QDateTime::currentMSecsSinceEpoch());
  23. int ndatasize = xsam.ByteSize();
  24. char * str = new char[ndatasize];
  25. std::shared_ptr<char> pstr;pstr.reset(str);
  26. if(!xsam.SerializeToArray(str,ndatasize))
  27. {
  28. std::cout<<"MainWindow::on_horizontalSlider_valueChanged serialize error."<<std::endl;
  29. return;
  30. }
  31. iv::modulecomm::ModuleSendMsg(mpa,str,ndatasize);
  32. givlog->debug("send slider value %d",xsam.mvalue());
  33. givfault->SetFaultState(0,0,"Run OK");
  34. }