123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- // MainDlg.cpp : implementation of the CMainDlg class
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "resource.h"
-
- #include <vector>
- #include <string>
- #include <json/json.h>
- #include <json/writer.h>
- #include <fstream>
- #include <array>
-
- #include "../common/comm.h"
- #include "RenderWindow.h"
- #include "FishEyeWindow.h"
- #include "MainDlg.h"
-
- LRESULT CMainDlg::OnInitDialog(HWND, LPARAM)
- {
- // center the dialog on the screen
- CenterWindow();
- // set icons
- HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
- SetIcon(hIcon, TRUE);
- HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
- SetIcon(hIconSmall, FALSE);
- _control = GetEgoController(this);
- std::array<IRender*, RenderPosition::ALL> _array;
- for (int32_t i = 0; i < RenderPosition::ALL; i++)
- {
- auto p = std::make_unique<CRenderWindow>();
- p->Start();
- _array[i] = p.get();
- _WindowArray.push_back(std::move(p));
- }
- _control->Start(_array);
- _fishWindow = std::make_unique<CFishEyeWindow>();
- _fishWindow->Start("192.168.1.64");
- Json::Value root;
- Json::Reader jsonReader;
- std::ifstream ifile("Config.json");
- std::string ip;
- if (jsonReader.parse(ifile, root))
- {
- _name = root["name"].asString();
- _account = root["account"].asString();
- _password = root["password"].asString();
- _control->Login(_account, _password);
- }
- //SetTimer(10002,10);
- return TRUE;
- }
- void CMainDlg::OnDestroy()
- {
- }
- void CMainDlg::OnNotifyConnected(bool bRet)
- {
- }
- void CMainDlg::OnNotifySigin(bool ret)
- {
-
- }
- void CMainDlg::OnCarConnect(WORD, WORD, HWND)
- {
- if (_carpeer != -1) return;
- CListViewCtrl box;
- box.Attach(GetDlgItem(IDC_CARLIST));
- int32_t cursel = box.GetSelectedIndex();
- if (cursel == -1) return;
-
- _carpeer = box.GetItemData(cursel);
- _control->OnCarConnect(_carpeer);
- }
- void CMainDlg::OnCarLeave(WORD, WORD, HWND)
- {
-
- _control->OnCarLeave();
- _carpeer = -1;
- }
- void CMainDlg::OnNotifyLeave(int32_t peer)
- {
- }
- void CMainDlg::OnNotifyMoveEnd(int32_t rid, WorkArea area, int32_t n)
- {
- }
- void CMainDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND)
- {
-
- EndDialog(wID);
-
- }
- void CMainDlg::OnSigin(bool bRet)
- {
- PostMessage(WM_NOTIFYSIGIN, (WPARAM)bRet);
- }
- void CMainDlg::OnRobot(std::unique_ptr<UserCamera>& node)
- {
- CListViewCtrl box;
- box.Attach(GetDlgItem(IDC_CARLIST));
- std::string info = node->name;
- switch (node->state)
- {
- case UserState::Idle:
- info += " (Idle)";
- break;
- case UserState::Offline:
- info += " (offline)";
- break;
- case UserState::Remote:
- info += " (Remote)";
- break;
- case UserState::Automotive:
- info += "(automotive)";
- break;
- }
- int32_t index = box.AddItem(0, 0, info.c_str());
- //box.SetItemText(index, 1, robot.type() == EgoType::Car ? "Car" : "Cave");
- auto users = std::make_unique<UserCamera>();
- users->uid = node->uid;
- users->name = info;
- users->type = static_cast<EgoType>(node->type);
- users->state = static_cast<UserState>(node->state);
- // for (int32_t i = 0; i < robot.info().size(); i++)
- // {
- // auto& node = robot.info(i);
- // CameraInfo camera;
- // camera.index = static_cast<RenderPosition>(node.pos());
- // camera.label = node.label();
- // camera.solution = static_cast<DisplayResolution>(node.solution());
- // users->info.push_back(camera);
- // }
- box.SetItemData(index, users->uid);
- _userInfo.push_back(std::move(users));
- }
- void CMainDlg::OnNotifyDel(int32_t peer)
- {
- CListViewCtrl box;
- box.Attach(GetDlgItem(IDC_CARLIST));
- int32_t Count = box.GetItemCount();
- for (int32_t i = 0; i < Count; i++)
- {
- auto id = box.GetItemData(i);
- if (id == peer)
- {
- box.DeleteItem(i);
- break;
- }
- }
- for (auto it = _userInfo.begin(); it != _userInfo.end(); ++it)
- {
- if ((*it)->uid == peer)
- {
- _userInfo.erase(it);
- break;
- }
- }
- }
- void CMainDlg::OnNotifyPing(int32_t value)
- {
- }
- void CMainDlg::OnNotifyRadar(int32_t r0, int32_t r1, int32_t r2, int32_t r3, int32_t r4, int32_t r5)
- {
- }
- void CMainDlg::OnNotifyKickOff()
- {
- }
- /*
- void CMainDlg::OnEmergency(bool enable, bool motor, bool gear, bool turnl, bool turnR)
- {
- _enable = enable;
- _motor = motor;
- _gear = gear;
- _turnL = turnl;
- _turnR = turnR;
- }
- void CMainDlg::OnAccel(int16_t accel, bool onoff)
- {
-
- _accel = accel;
- _onoff = onoff;
- }
- void CMainDlg::OnSteer(uint64_t steer)
- {
- _steer = steer;
- std::string ret = std::string("steer :")+std::to_string(_steer);
- ret += "\n";
- OutputDebugString(ret.c_str());
- }
- */
- void CMainDlg::OnTimer(UINT idEvent)
- {
-
- SetDlgItemInt(IDC_ENABLE, _enable);
-
-
- SetDlgItemInt(IDC_MOTOR, _motor);
-
- SetDlgItemInt(IDC_GEAR, _gear);
-
- SetDlgItemInt(IDC_TURNL, _turnL);
-
- SetDlgItemInt(IDC_TURNR, _turnR);
- SetDlgItemInt(IDC_STEER, _steer);
- SetDlgItemInt(IDC_ACCEL, _accel);
-
- }
- /*
- void CMainDlg::OnArm(int16_t flip, int16_t armL, int16_t armR, bool onoff)
- {
- SetDlgItemInt(IDC_FLIP, flip);
- SetDlgItemInt(IDC_ARML, armL);
- SetDlgItemInt(IDC_ARMR, armR);
-
- SetDlgItemInt(IDC_ONOFF, onoff);
- }
- */
- void CMainDlg::OnLidarData(bool isLeft, bool isDense, int32_t seq, PointXYZI* data, int32_t length)
- {
- }
- void CMainDlg::OnNotifyFeed(const FeedData& data)
- {
- }
|