示例#1
0
void IntrospectBase::ServerInfoHandler(const pa_server_info& info)
{ DEBUGLOG(("IntrospectBase(%p)::ServerInfoHandler(%p)\n", this, info));
  if (!&info)
  { InfoOp->Cancel();
    PostMsg(UM_UPDATE_SERVER, MPFROMLONG(Context.Errno()), 0);
  } else
  { Server = info;
    if (InfoOp->GetState() == PA_OPERATION_DONE)
      PostMsg(UM_UPDATE_SERVER, 0, 0);
  }
}
示例#2
0
U0 KeyMapFamily2(U8 **entries,U8 *family,CTask *task,I64 scf)
{
  I64 i,p2,p1;
  U8 *st,*st2;
  CTask *old_hash=Fs->hash_table;
  Fs->hash_table=task->hash_table;
  for (i=0;i<256;i++) {
    p2=scf|i|SCF_KEY_DESC;
    p1=ScanCode2A(p2);
    *key_desc=0;
    key_handler=NULL;
    if (task==Fs)
      PutKey(p1,p2);
    else if (TaskValidate(task)) {
      PostMsg(task,MSG_KEY_DOWN,p1,p2);
      while (!key_handler)
	Yield;
    }
    if (*key_desc && StrNCmp(key_desc,"Char/",5)) {
      st=ScanCode2KeyName(p2&~(SCF_CTRL|SCF_ALT|SCF_SHIFT));
      st2=MSPrintF("%s%s",family,st);
      Free(st);
      st=SrcEdLink(key_handler,256);
      entries[i]=MSPrintF("%20s$$LK,\"%s\",\"%s\"$$\n",
	  st2,key_desc,st);
      Free(st);
      Free(st2);
    }
  }
  Fs->hash_table=old_hash;
}
示例#3
0
文件: Server.cpp 项目: chaixun/robot
int On_VS_ConnectionLost(Aris::Core::CONN *pConn)
{
    CGait::IsVisionWalk = false;
    CGait::IsWalkAvoidRegistered = false;
    PostMsg(Aris::Core::MSG(VS_Lost));
    return 0;
}
示例#4
0
void CPanel::OnArrowWithShift()
{
  if (!_mySelectMode)
    return;
  int focusedItem = _listView.GetFocusedItem();
  if (focusedItem < 0)
    return;
  int realIndex = GetRealItemIndex(focusedItem);
  
  if (_selectionIsDefined)
  {
    if (realIndex != kParentIndex)
      _selectedStatusVector[realIndex] = _selectMark;
  }
  else
  {
    if (realIndex == kParentIndex)
    {
      _selectionIsDefined = true;
      _selectMark = true;
    }
    else
    {
      _selectionIsDefined = true;
      _selectMark = !_selectedStatusVector[realIndex];
      _selectedStatusVector[realIndex] = _selectMark;
    }
  }
  
  _prevFocusedItem = focusedItem;
  PostMsg(kShiftSelectMessage);
  _listView.RedrawItem(focusedItem);
}
示例#5
0
public U0 PressKeyHelp(CTask *task=NULL)
{
  I64 p1=0,p2=0;
  Bool old_preempt=Preempt(OFF);
  CTask *old_hash=Fs->hash_table;
  if (!task) task=Fs;

//This feat is a burden in code.
//It would be nice to lst key
//cmds for all applications,
//but it makes the code too ugly.
//
task=Fs;

  Fs->hash_table=task->hash_table;
  "Press keys to show handler code.\n"
  "<SHIFT-ESC> to exit.\n"
  "Do not press <CTRL-ALT-keys>.\n";
  while (p1!=CH_ESC && p1!=CH_SHIFT_ESC) {
    GetMsg(&p1,&p2,1<<MSG_KEY_DOWN);
    *key_desc=0;
    key_handler=NULL;
    if (task==Fs)
      PutKey(p1,p2|SCF_KEY_DESC);
    else if (TaskValidate(task)) {
      PostMsg(task,MSG_KEY_DOWN,p1,p2|SCF_KEY_DESC);
      while (!key_handler)
	Yield;
    }
    if (*key_desc)
      E(key_handler,512);
  }
  Fs->hash_table=old_hash;
  Preempt(old_preempt);
}
示例#6
0
int CDebug::Putchar(int ch)
{
	tagDebugMsg	msg;
	msg.Data.nChar = ch;
	msg.Cmd = DebugCmd_PrintChar;
	PostMsg(&msg);
	return ch;
}
示例#7
0
文件: Server.cpp 项目: chaixun/robot
int On_CS_CMD_Received(Aris::Core::MSG &msg)
{
    MSG Command(msg);
    Command.SetMsgID(GetControlCommand);
    PostMsg(Command);
    MSG data(0,0);
    ControlSystem.SendData(data);
    return 0;
}
示例#8
0
void CDebug::Puts(const char *pString)
{
	tagDebugMsg	msg;

	strncpy(msg.Data.aString, pString, DEDUG_STR_MAXSIZE);
	msg.Data.aString[DEDUG_STR_MAXSIZE-1] = '\0';	// 添加字符串结束符,以防没加所致字串溢出。
	
	msg.Cmd = DebugCmd_PrintString;
	PostMsg(&msg);
}
示例#9
0
文件: Server.cpp 项目: chaixun/HexIII
int On_VS_ConnectionReceived(Aris::Core::CONN *pConn, const char* addr,int port)
{
    Aris::Core::MSG msg;
    msg.SetMsgID(VS_Connected);
    msg.SetLength(sizeof(port));
    msg.Copy(&port,sizeof(port));
    msg.CopyMore(addr,strlen(addr));
    PostMsg(msg);
    return 0;
}
示例#10
0
文件: Server.cpp 项目: chaixun/robot
int On_CS_DataReceived(Aris::Core::CONN *pConn, Aris::Core::MSG &data)
{
    int cmd=data.GetMsgID();
    MSG CMD=CS_CMD_Received;
    CMD.SetLength(sizeof(int));
    CMD.Copy(&cmd,sizeof(int));
    cout<<"received CMD is "<<cmd<<endl;
    PostMsg(CMD);
    return 0;
}
示例#11
0
文件: Server.cpp 项目: chaixun/HexIII
int On_CS_CMD_Received(Aris::Core::MSG &msg)
{
    int Command_Gait;
    msg.Paste(&Command_Gait,sizeof(int));
    Aris::Core::MSG Gait=Command_Gait;
    cout<<"Gait Needed is: "<<Gait.GetMsgID()<<endl;
    PostMsg(Gait);
    Aris::Core::MSG data(0,0);
    ControlSystem.SendData(data);
    return 0;
}
示例#12
0
文件: Server.cpp 项目: chaixun/HexIII
int On_CS_DataReceived(Aris::Core::CONN *pConn,Aris::Core::MSG &data)
{
    int cmd=data.GetMsgID()+100;
    Aris::Core::MSG CMD=CS_CMD_Received;
    CMD.SetLength(sizeof(int));
    bool IsCMDExecutable=true;
    CMD.Copy(&cmd,sizeof(int));
    cout<<"received CMD is"<<cmd<<endl;
    PostMsg(CMD);
    LastCMD=data.GetMsgID();
    return 0;
}
示例#13
0
void LoadWizard::SourceInfoHandler(const PASourceInfoOperation::Args& args)
{ DEBUGLOG(("LoadWizard(%p)::SinkInfoHandler({%p, %i})\n", this, args.Info, args.Error));
  if (args.Info)
  { Sources.append() = new PASourceInfo(*args.Info);
    return;
  }
  if (args.Error)
    ServerInfoOp.Cancel();
  else if (ServerInfoOp.GetState() != PA_OPERATION_DONE)
    return;
  PostMsg(UM_UPDATE_SERVER, MPFROMLONG(args.Error), 0);
}
示例#14
0
	Bool CApp::PostMsg(const XID& sXid, CMsg* pMsg)
	{
		CMsg* pRealMsg = (CMsg*)pMsg;
		if (pRealMsg && sXid.IsValid())
		{
			pRealMsg->Target = sXid;
			return PostMsg(pRealMsg);
		}
		
		g_MsgManager->FreeMsg(pRealMsg);
		return false;
	}
inline void NetMsgBusToLocalMsgBus(const std::string& netmsgbus_msgcontent)
{
    std::string msgid;
    if(CheckMsgId(netmsgbus_msgcontent, msgid))
    {
        boost::shared_array<char> msgparam;
        uint32_t param_len;
        if(GetMsgParam(netmsgbus_msgcontent, msgparam, param_len))
        {
            PostMsg(msgid, msgparam, param_len);
        }
    }
}
示例#16
0
	Bool HawkAppFrame::BroadcastMsg(ObjMan* pObjMan, HawkMsg* pMsg)
	{
		if (pObjMan && pMsg)
		{
			XIDVector vXID;
			pObjMan->CollectObjKey(vXID);

			if (vXID.size())
				PostMsg(vXID, pMsg);

			return true;
		}		
		return false;
	}
//----------
// MsgClose \
//---------------------------------------------------------------------------
// Event:	WM_CLOSE
// Cause:	Issued by OS when window is closed
//
void *C_WINDOW_MAIN::MsgClose( void *mp1, void *mp2 )
{
	char	szString[80];
	int		iX;
	int		iY;
	int		iW;
	int		iL;


	// Get all of the saveable parameters
	GetSizePosition( &iX, &iY, &iW, &iL );

	// Save parameters into the INI file
	C_INI_USER xcIni( "BookNews" );
	xcIni.Open();
	sprintf( szString, "%d", iX );
	xcIni.Write( "MainX", szString );
	sprintf( szString, "%d", iY );
	xcIni.Write( "MainY", szString );
	xcIni.Close();

	// Debug
	pxcLog->Write( "NEWS:WM_CLOSE:Start" );

	// If there is a groups window open, close it and destroy
	if( pxcGroups )
		pxcGroups->SendMsg( WM_CLOSE, 0, 0 );

	// If there is a subscriptions window open, close it and destroy
	if( pxcSubs )
		pxcSubs->SendMsg( WM_CLOSE, 0, 0 );

	// If there is a message window open, close it and destroy
	if( pxcMsg )
		pxcMsg->SendMsg( WM_CLOSE, 0, 0 );

	// If there is an article window open, close it and destroy
	if( pxcArticle )
		pxcArticle->SendMsg( WM_CLOSE, 0, 0 );

	// Applcation was told to close, so post a QUIT message to the OS
	PostMsg( WM_QUIT, 0, 0 );

	// Debug
	pxcLog->Write( "NEWS:WM_CLOSE:End" );
	return FALSE;
}
示例#18
0
int CDebug::Printf(const char *pFormat, ...)
{
	tagDebugMsg	msg;
	va_list	argp;
	int	ret = 0 ;

	va_start(argp,pFormat);
	ret = vsnprintf(msg.Data.aString, DEDUG_STR_MAXSIZE, pFormat, argp);
	va_end(argp);

	msg.Data.aString[DEDUG_STR_MAXSIZE-1] = '\0';	// 添加字符串结束符,以防没加所致字串溢出。
	
	msg.Cmd = DebugCmd_PrintString;
	PostMsg(&msg);

	return ret;
}
示例#19
0
	Bool HsGame::OnSessionClose(SID iSid, const AString& sAddr)
	{
		if (m_mSidAddr.Find(iSid))
		{
			//注: 此处有可能在未绑定对象SID之前调用造成消息漏发
			//因: 协议通过线程池处理, 有可能在绑定协议投递而未处理时引发此处调用
			XID sXid = GetXidBySid(iSid);
			if (sXid.IsValid())
			{
				HawkMsg* pMsg = P_MsgManager->GetMsg(HSM_DISCONNECT);
				if (pMsg)
				{
					pMsg->Target = sXid;
					pMsg->Params.Push<SID>(iSid);
					PostMsg(pMsg);
				}
			}
		}

		return HawkAppFrame::OnSessionClose(iSid, sAddr);
	}
示例#20
0
static void MonitorLoopThread (void *args) {

  DosSetPriority(PRTYS_THREAD,
                 PRTYC_TIMECRITICAL,
                 PRTYD_MAXIMUM,
                 0);
  while(!amclosing &&
        !closethreads) {

    ULONG msecs,msecs2,cntr,last,this;

    DosQuerySysInfo(QSV_MS_COUNT,
                    QSV_MS_COUNT,
                    &msecs,
                    sizeof(msecs));
    last = IdleCounter;
    DosSleep(MilliSecs);
    this = IdleCounter;
    DosQuerySysInfo(QSV_MS_COUNT,
                    QSV_MS_COUNT,
                    &msecs2,
                    sizeof(msecs2));

    if(msecs != msecs2 &&
       last < this) {
      cntr = (ULONG)(((double)(this - last) * 1000) /
                     ((double)msecs2 - msecs));
      MaxCount = max(MaxCount,cntr);
      if(CPUHwnd &&
         !closethreads)
        PostMsg(CPUHwnd,
                UM_REFRESH,
                MPFROMLONG(cntr),
                MPVOID);
    }
  }
  MonTID = 0;
}
示例#21
0
MRESULT IntrospectBase::DlgProc(ULONG msg, MPARAM mp1, MPARAM mp2)
{
  switch (msg)
  {case WM_INITDLG:
    { MRESULT ret = DialogBase::DlgProc(msg, mp1, mp2);
      do_warpsans(GetHwnd());
      // Populate MRU list
      ComboBox cb(GetCtrl(CB_SERVER));
      if (Configuration.SinkServer)
        cb.InsertItem(Configuration.SinkServer);
      char key[] = "Server1";
      do
      { xstring url;
        ini_query(key, url);
        if (!url)
          break;
        cb.InsertItem(url);
      } while (++key[sizeof key -2] <= '9');
      return ret;
    }

   case WM_COMMAND:
    DEBUGLOG(("IntrospectBase::DlgProc:WM_COMMAND(%i,%i, %p)\n", SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), mp2));
    switch (SHORT1FROMMP(mp1))
    {case PB_UPDATE:
      PostMsg(UM_CONNECT, 0,0);
      return 0;
     case DID_OK:
      { ComboBox cb(GetCtrl(CB_SERVER));
        const xstring& server = cb.Text();
        // update MRU list
        if (server.length())
        { char key[] = "Server1";
          int i = 0;
          int len = 0;
          xstring url;
          do
          { if (len >= 0)
            {skip:
              url.reset();
              len = (SHORT)SHORT1FROMMR(WinSendMsg(cb.Hwnd, LM_QUERYITEMTEXTLENGTH, MPFROMSHORT(i), 0));
              if (len >= 0)
              { WinSendMsg(cb.Hwnd, LM_QUERYITEMTEXT, MPFROM2SHORT(i, len+1), MPFROMP(url.allocate(len)));
                DEBUGLOG(("IntrospectBase::DlgProc: save MRU %i: (%i) %s\n", i, len, url.cdata()));
                ++i;
                if (url == server)
                  goto skip;
              }
            }
            ini_write(key, url);
          } while (++key[sizeof key -2] <= '9');
        }
        Configuration.Save();
      }
      break;
    }
    break;

   case WM_CONTROL:
    switch (SHORT1FROMMP(mp1))
    {case CB_SERVER:
      switch (SHORT2FROMMP(mp1))
      {case CBN_ENTER:
        PostMsg(UM_CONNECT, 0,0);
        break;
      }
      break;
     case CB_SINKSRC:
      switch (SHORT2FROMMP(mp1))
      {case CBN_ENTER:
        PostMsg(UM_UPDATE_PORT, 0,0);
        break;
      }
    }
    break;

   case UM_CONNECT:
    { DEBUGLOG(("IntrospectBase::DlgProc:UM_CONNECT\n"));
      // destroy any old connection
      Cleanup();
      const xstring& server = WinQueryDlgItemXText(GetHwnd(), CB_SERVER);
      if (!server.length())
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, "enter server name above");
        return 0;
      }
      // open new connection
      try
      { Context.Connect("PM123", server);
      } catch (const PAException& ex)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, ex.GetMessage());
      }
      return 0;
    }

   case UM_STATE_CHANGE:
    { pa_context_state_t state = (pa_context_state_t)LONGFROMMP(mp1);
      DEBUGLOG(("IntrospectBase::DlgProc:UM_STATE_CHANGE %u\n", state));
      const char* text = "";
      switch (state)
      {case PA_CONTEXT_CONNECTING:
        text = "Connecting ...";
        break;
       case PA_CONTEXT_AUTHORIZING:
        text = "Authorizing ...";
        break;
       case PA_CONTEXT_SETTING_NAME:
        text = "Set name ...";
        break;
       case PA_CONTEXT_READY:
        text = "Connected";
        PostMsg(UM_DISCOVER_SERVER, 0,0);
        break;
       case PA_CONTEXT_FAILED:
        WinSetDlgItemText(GetHwnd(), ST_STATUS, PAConnectException(Context.GetContext()).GetMessage());
        return 0;
       case PA_CONTEXT_TERMINATED:
        text = "Closed";
        break;
       case PA_CONTEXT_UNCONNECTED:;
      }
      WinSetDlgItemText(GetHwnd(), ST_STATUS, text);
      return 0;
    }
  }
  return DialogBase::DlgProc(msg, mp1, mp2);
}
示例#22
0
文件: Server.cpp 项目: chaixun/robot
int OnGetControlCommand(MSG &msg)
{
    int CommandID;
    msg.Paste(&CommandID,sizeof(int));
    Aris::Core::MSG data;

    switch(CommandID)
    {
    case 1:
        data.SetMsgID(POWEROFF);
        cs.NRT_PostMsg(data);
        break;
    case 2:
        data.SetMsgID(STOP);
        cs.NRT_PostMsg(data);
        break;
    case 3:
        data.SetMsgID(ENABLE);
        cs.NRT_PostMsg(data);
        break;
    case 4:
        data.SetMsgID(RUNNING);
        cs.NRT_PostMsg(data);
        break;
    case 5:
        data.SetMsgID(GOHOME_1);
        cs.NRT_PostMsg(data);
        break;
    case 6:
        data.SetMsgID(GOHOME_2);
        cs.NRT_PostMsg(data);
        break;
    case 7:
        data.SetMsgID(HOME2START_1);
        cs.NRT_PostMsg(data);
        break;
    case 8:
        data.SetMsgID(HOME2START_2);
        cs.NRT_PostMsg(data);
        break;
    case 9:
        data.SetMsgID(FORWARD);
        cs.NRT_PostMsg(data);
        break;
    case 10:
        data.SetMsgID(BACKWARD);
        cs.NRT_PostMsg(data);
        break;
    case 11:
        data.SetMsgID(TURNLEFT);
        cs.NRT_PostMsg(data);
        break;
    case 12:
        data.SetMsgID(TURNRIGHT);
        cs.NRT_PostMsg(data);
        break;
    case 13:
        data.SetMsgID(LEGUP);
        cs.NRT_PostMsg(data);
        break;
    case 14:
    {
        CGait::IsVisionWalk = true;
        Vision_Msg visioncmd = Vision_UpperControl;
        Aris::Core::MSG visionmsg;
        visionmsg.SetMsgID(VS_Capture);
        visionmsg.SetLength(sizeof(visioncmd));
        visionmsg.Copy(&visioncmd, sizeof(visioncmd));
        PostMsg(visionmsg);
    }
        break;
    case 15:
    {
        CGait::IsWalkAvoidRegistered = true;
        Vision_Msg visioncmd = Walk_Avoid;
        Aris::Core::MSG visionmsg;
        visionmsg.SetMsgID(VS_Capture);
        visionmsg.SetLength(sizeof(visioncmd));
        visionmsg.Copy(&visioncmd, sizeof(visioncmd));
        PostMsg(visionmsg);
    }
        break;
    default:
        cout<<"Do Not Get Validate CMD"<<endl;
        break;
    }
    return CommandID;
}
示例#23
0
void IntrospectBase::StateChangeHandler(const pa_context_state_t& args)
{ DEBUGLOG(("IntrospectBase(%p)::StateChangeHandler(%i)\n", this, args));
  PostMsg(UM_STATE_CHANGE, MPFROMLONG(args), 0);
}
示例#24
0
文件: Server.cpp 项目: chaixun/HexIII
int On_CS_ConnectionLost(Aris::Core::CONN *pConn)
{
    PostMsg(Aris::Core::MSG(CS_Lost));
    return 0;
}
示例#25
0
MRESULT LoadWizard::DlgProc(ULONG msg, MPARAM mp1, MPARAM mp2)
{
  switch (msg)
  {case WM_INITDLG:
    { MRESULT ret = IntrospectBase::DlgProc(msg, mp1, mp2);
      SetTitle(Title);
      if (Configuration.SourceServer)
      { ComboBox(+GetCtrl(CB_SERVER)).Text(Configuration.SourceServer);
        PostMsg(UM_CONNECT, 0, 0);
      }
      if (Configuration.Source)
        PMRASSERT(WinSetDlgItemText(GetHwnd(), CB_SINKSRC, Configuration.Source));
      if (Configuration.SourcePort)
        PMRASSERT(WinSetDlgItemText(GetHwnd(), CB_PORT, Configuration.SourcePort));
      // Init rate spin button
      { SpinButton sb(GetCtrl(SB_RATE));
        sb.SetArray(SamplingRates, sizeof SamplingRates/sizeof *SamplingRates);
        size_t pos;
        if ( !binary_search<const char,const int>(Configuration.SourceRate, pos, &SamplingRates[0], sizeof SamplingRates/sizeof *SamplingRates, &SamplingRateCmp)
          && ( pos == sizeof SamplingRates/sizeof *SamplingRates
            || (pos && 2*Configuration.SourceRate < atoi(SamplingRates[pos]) + atoi(SamplingRates[pos-1])) ))
          --pos;
        sb.Value(pos);
      }
      WinCheckButton(GetHwnd(), Configuration.SourceChannels == 1 ? RB_MONO : RB_STEREO, TRUE);
      return ret;
    }

   case WM_COMMAND:
    DEBUGLOG(("LoadWizard::DlgProc:WM_COMMAND(%i,%i, %p)\n", SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), mp2));
    switch (SHORT1FROMMP(mp1))
    {case DID_OK:
      { Configuration.SourceServer = WinQueryDlgItemXText(GetHwnd(), CB_SERVER);
        const xstring& source = WinQueryDlgItemXText(GetHwnd(), CB_SINKSRC);
        Configuration.Source = source.length() && !source.startsWithI("default") ? source : xstring();
        const xstring& port = WinQueryDlgItemXText(GetHwnd(), CB_PORT);
        Configuration.SourcePort = port.length() && !port.startsWithI("default") ? port : xstring();
        Configuration.SourceRate = atoi(SamplingRates[SpinButton(GetCtrl(SB_RATE)).Value()]);
        Configuration.SourceChannels = WinQueryButtonCheckstate(GetHwnd(), RB_MONO) ? 1 : 2;
      }
      break;
    }
    break;

   case UM_DISCOVER_SERVER:
    { DEBUGLOG(("LoadWizard::DlgProc:UM_DISCOVER_SERVER\n"));
      try
      { Context.GetServerInfo(ServerInfoOp);
        Sources.clear();
        Context.GetSourceInfo(SourceInfoOp);
      } catch (const PAException& ex)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, ex.GetMessage());
      }
      return 0;
    }

   case UM_UPDATE_SERVER:
    { int error = LONGFROMMP(mp1);
      DEBUGLOG(("LoadWizard::DlgProc:UM_UPDATE_SERVER %i\n", error));
      if (error)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, PAConnectException(Context.GetContext(), error).GetMessage());
        return 0;
      }
      WinSetDlgItemText(GetHwnd(), ST_STATUS, "Success");
      ComboBox cb(GetCtrl(CB_SINKSRC));
      // save old value
      const xstring& oldsink = cb.Text();
      // delete old list
      cb.DeleteAll();
      SelectedSource = -1;
      // insert new list and restore old value if reasonable.
      xstring def;
      def.sprintf("default (%s)", Server.default_sink_name.cdata());
      cb.InsertItem(def);
      if (Sources.size() != 0)
      { int defsink = -1;
        for (unsigned i = 0; i < Sources.size(); ++i)
        { PASourceInfo& source = *Sources[i];
          cb.InsertItem(source.name);
          if (SelectedSource < 0 && source.name.compareToI(oldsink) == 0)
            SelectedSource = i;
          if (defsink < 0 && source.name.compareToI(Server.default_sink_name) == 0)
            defsink = i;
        }
        cb.Select(SelectedSource+1);
        if (SelectedSource < 0)
          SelectedSource = defsink;
      }
    }
   case UM_UPDATE_PORT:
    { DEBUGLOG(("LoadWizard::DlgProc:UM_UPDATE_PORT %i\n", SelectedSource));
      ComboBox cb(GetCtrl(CB_PORT));
      // save old value
      const xstring& oldport = cb.Text();
      // delete old list
      cb.DeleteAll();
      // insert new list and restore old value if reasonable.
      xstring def;
      int selected = -1;
      if ((unsigned)SelectedSource < Sources.size())
      { PASourceInfo& source = *Sources[SelectedSource];
        if (source.active_port)
          def.sprintf("default (%s)", source.active_port->name.cdata());
        for (unsigned i = 0; i < source.ports.size(); ++i)
        { PAPortInfo& port = source.ports[i];
          cb.InsertItem(port.name);
          if (selected < 0 && port.name.compareToI(oldport) == 0)
            selected = i;
        }
      }
      cb.InsertItem(def ? def.cdata() : "default", 0);
      cb.Select(selected+1);
      return 0;
    }
  }
  return IntrospectBase::DlgProc(msg, mp1, mp2);
}
示例#26
0
MRESULT ConfigDialog::DlgProc(ULONG msg, MPARAM mp1, MPARAM mp2)
{
  switch (msg)
  {case WM_INITDLG:
    { MRESULT ret = IntrospectBase::DlgProc(msg, mp1, mp2);
      if (Configuration.Sink)
        PMRASSERT(WinSetDlgItemText(GetHwnd(), CB_SINKSRC, Configuration.Sink));
      if (Configuration.SinkPort)
        PMRASSERT(WinSetDlgItemText(GetHwnd(), CB_PORT, Configuration.SinkPort));
      // Set current value
      if (Configuration.SinkServer)
      { ComboBox(+GetCtrl(CB_SERVER)).Text(Configuration.SinkServer);
        PostMsg(UM_CONNECT, 0, 0);
      }
      SpinButton sb(GetCtrl(SB_MINLATENCY));
      sb.SetLimits(0, 5000, 4);
      sb.Value(Configuration.SinkMinLatency);
      sb = SpinButton(GetCtrl(SB_MAXLATENCY));
      sb.SetLimits(100, 10000, 4);
      sb.Value(Configuration.SinkMaxLatency);
      return ret;
    }

   case WM_COMMAND:
    DEBUGLOG(("ConfigDialog::DlgProc:WM_COMMAND(%i,%i, %p)\n", SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), mp2));
    switch (SHORT1FROMMP(mp1))
    {case DID_OK:
      { Configuration.SinkServer = WinQueryDlgItemXText(GetHwnd(), CB_SERVER);
        const xstring& sink = WinQueryDlgItemXText(GetHwnd(), CB_SINKSRC);
        Configuration.Sink = sink.length() && !sink.startsWithI("default") ? sink : xstring();
        const xstring& port = WinQueryDlgItemXText(GetHwnd(), CB_PORT);
        Configuration.SinkPort = port.length() && !port.startsWithI("default") ? port : xstring();
        Configuration.SinkMinLatency = SpinButton(GetCtrl(SB_MINLATENCY)).Value();
        Configuration.SinkMaxLatency = SpinButton(GetCtrl(SB_MAXLATENCY)).Value();
      }
      break;
    }
    break;

   case UM_DISCOVER_SERVER:
    { DEBUGLOG(("ConfigDialog::DlgProc:UM_DISCOVER_SERVER\n"));
      try
      { Context.GetServerInfo(ServerInfoOp);
        Sinks.clear();
        Context.GetSinkInfo(SinkInfoOp);
      } catch (const PAException& ex)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, ex.GetMessage());
      }
      return 0;
    }

   case UM_UPDATE_SERVER:
    { int error = LONGFROMMP(mp1);
      DEBUGLOG(("ConfigDialog::DlgProc:UM_UPDATE_SERVER %i\n", error));
      if (error)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, PAConnectException(Context.GetContext(), error).GetMessage());
        return 0;
      }
      WinSetDlgItemText(GetHwnd(), ST_STATUS, "Success");
      ComboBox cb(GetCtrl(CB_SINKSRC));
      // save old value
      const xstring& oldsink = cb.Text();
      // delete old list
      cb.DeleteAll();
      SelectedSink = -1;
      // insert new list and restore old value if reasonable.
      xstring def;
      def.sprintf("default (%s)", Server.default_sink_name.cdata());
      cb.InsertItem(def);
      if (Sinks.size() != 0)
      { int defsink = -1;
        for (unsigned i = 0; i < Sinks.size(); ++i)
        { PASinkInfo& sink = *Sinks[i];
          cb.InsertItem(sink.name);
          if (SelectedSink < 0 && sink.name.compareToI(oldsink) == 0)
            SelectedSink = i;
          if (defsink < 0 && sink.name.compareToI(Server.default_sink_name) == 0)
            defsink = i;
        }
        cb.Select(SelectedSink+1);
        if (SelectedSink < 0)
          SelectedSink = defsink;
      }
    }
   case UM_UPDATE_PORT:
    { DEBUGLOG(("ConfigDialog::DlgProc:UM_UPDATE_PORT %i\n", SelectedSink));
      ComboBox cb(GetCtrl(CB_PORT));
      // save old value
      const xstring& oldport = cb.Text();
      // delete old list
      cb.DeleteAll();
      // insert new list and restore old value if reasonable.
      xstring def;
      int selected = -1;
      if ((unsigned)SelectedSink < Sinks.size())
      { PASinkInfo& sink = *Sinks[SelectedSink];
        if (sink.active_port)
          def.sprintf("default (%s)", sink.active_port->name.cdata());
        for (unsigned i = 0; i < sink.ports.size(); ++i)
        { PAPortInfo& port = sink.ports[i];
          cb.InsertItem(port.name);
          if (selected < 0 && port.name.compareToI(oldport) == 0)
            selected = i;
        }
      }
      cb.InsertItem(def ? def.cdata() : "default", 0);
      cb.Select(selected+1);
      return 0;
    }
  }
  return IntrospectBase::DlgProc(msg, mp1, mp2);
}
示例#27
0
 void PostMsg(CDB_Exception* ex) const
 {
     PostMsg(ex, string());
 }
示例#28
0
MRESULT EXPENTRY SwapProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {

  static HWND hwndMenu = (HWND)0;

  switch(msg) {
    case WM_CREATE:
      {
        MRESULT mr = PFNWPStatic(hwnd,msg,mp1,mp2);

        WinSendMsg(hwnd,
                   UM_SETUP,
                   MPVOID,
                   MPVOID);
        return mr;
      }

    case WM_MOUSEMOVE:

      break;

    case WM_PRESPARAMCHANGED:
      {
        char *rootname = "SwapMon";

        switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
          case CLOCK_FRAME:
            rootname = "Clock";
            break;
          case HARD_FRAME:
            rootname = "Hard";
            break;
          case CPU_FRAME:
            rootname = "CPU";
            break;
          case CLP_FRAME:
            rootname = "ClipMon";
            break;
          case MEM_FRAME:
            rootname = "Mem";
            break;
          case TSK_FRAME:
            rootname = "Task";
            break;
        }
        PresParamChanged(hwnd,
                         rootname,
                         mp1,
                         mp2);
        PostMsg(hwnd,
                UM_TIMER,
                MPVOID,
                MPVOID);
        PostMsg(hwnd,
                UM_REFRESH,
                MPVOID,
                MPFROMSHORT(TRUE));
      }
      break;

    case WM_APPTERMINATENOTIFY:
      if(WinQueryWindowUShort(hwnd,QWS_ID) == CPU_FRAME) {
        if(!StartCPUThreads())
          WinDestroyWindow(hwnd);
      }
      break;

    case WM_BUTTON1MOTIONSTART:
      {
        POINTL ptl;

        ptl.x = SHORT1FROMMP(mp1);
        ptl.y = SHORT2FROMMP(mp1);
        WinMapWindowPoints(hwnd,
                           HWND_DESKTOP,
                           &ptl,
                           1L);
        PostMsg(hwndConfig,
                UM_SHOWME,
                MPFROM2SHORT((USHORT)ptl.x,(USHORT)ptl.y),
                mp2);
      }
      return MRFROMSHORT(TRUE);

    case WM_BUTTON2MOTIONSTART:
      {
        TRACKINFO TrackInfo;
        SWP       Position;

        memset(&TrackInfo,0,sizeof(TrackInfo));
        TrackInfo.cxBorder   = 1 ;
        TrackInfo.cyBorder   = 1 ;
        TrackInfo.cxGrid     = 1 ;
        TrackInfo.cyGrid     = 1 ;
        TrackInfo.cxKeyboard = 8 ;
        TrackInfo.cyKeyboard = 8 ;
        WinQueryWindowPos(hwnd,&Position);
        TrackInfo.rclTrack.xLeft   = Position.x ;
        TrackInfo.rclTrack.xRight  = Position.x + Position.cx ;
        TrackInfo.rclTrack.yBottom = Position.y ;
        TrackInfo.rclTrack.yTop    = Position.y + Position.cy ;
        WinQueryWindowPos(HWND_DESKTOP,&Position);
        TrackInfo.rclBoundary.xLeft   = Position.x ;
        TrackInfo.rclBoundary.xRight  = Position.x + Position.cx ;
        TrackInfo.rclBoundary.yBottom = Position.y ;
        TrackInfo.rclBoundary.yTop    = Position.y + Position.cy ;
        TrackInfo.ptlMinTrackSize.x = 0 ;
        TrackInfo.ptlMinTrackSize.y = 0 ;
        TrackInfo.ptlMaxTrackSize.x = Position.cx ;
        TrackInfo.ptlMaxTrackSize.y = Position.cy ;
        TrackInfo.fs = TF_MOVE | TF_STANDARD | TF_ALLINBOUNDARY ;
        if(WinTrackRect(HWND_DESKTOP,
                        (HPS)0,
                        &TrackInfo)) {
          WinSetWindowPos(hwnd,
                          HWND_TOP,
                          TrackInfo.rclTrack.xLeft,
                          TrackInfo.rclTrack.yBottom,
                          0,
                          0,
                          SWP_MOVE);
          switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
            case SWAP_FRAME:
              WinQueryWindowPos(hwnd,&swpSwap);
              SavePrf("SwapSwp",
                      &swpSwap,
                      sizeof(SWP));
              break;
            case CLOCK_FRAME:
              WinQueryWindowPos(hwnd,&swpClock);
              SavePrf("ClockSwp",
                      &swpClock,
                      sizeof(SWP));
              break;
            case HARD_FRAME:
              WinQueryWindowPos(hwnd,&swpHard);
              SavePrf("HardSwp",
                      &swpHard,
                      sizeof(SWP));
              break;
            case CPU_FRAME:
              WinQueryWindowPos(hwnd,&swpCPU);
              SavePrf("CPUSwp",
                      &swpCPU,
                      sizeof(SWP));
              break;
            case CLP_FRAME:
              WinQueryWindowPos(hwnd,&swpClip);
              SavePrf("ClipSwp",
                      &swpClip,
                      sizeof(SWP));
              break;
            case MEM_FRAME:
              WinQueryWindowPos(hwnd,&swpMem);
              SavePrf("MemSwp",
                      &swpMem,
                      sizeof(SWP));
              break;
            case TSK_FRAME:
              WinQueryWindowPos(hwnd,&swpTask);
              SavePrf("TaskSwp",
                      &swpTask,
                      sizeof(SWP));
              break;
          }
        }
      }
      return MRFROMSHORT(TRUE);

    case WM_BUTTON1DOWN:
      WinSetWindowPos(hwnd,
                      HWND_TOP,
                      0,
                      0,
                      0,
                      0,
                      SWP_ZORDER | SWP_DEACTIVATE);
      return MRFROMSHORT(TRUE);

    case WM_BUTTON1DBLCLK:
    case WM_BUTTON1CLICK:
      if((!fNoMonClick &&
          msg == WM_BUTTON1CLICK) ||
         (fNoMonClick &&
          msg == WM_BUTTON1DBLCLK)) {
        switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
          case HARD_FRAME:
            {
              ULONG ulDriveNum,ulDriveMap,x;

              ulDriveMon = min(ulDriveMon,26);
              if(!DosQCurDisk(&ulDriveNum,
                              &ulDriveMap)) {
                for(x = ulDriveMon + 1;x < 26;x++) {
                  if(ulDriveMap & (1 << x)) {
                    ulDriveMon = x;
                    break;
                  }
                }
                if(x >= 26) {
                  for(x = 3;x < ulDriveMon - 1;x++) {
                    if(ulDriveMap & (1 << x)) {
                      ulDriveMon = x;
                      break;
                    }
                  }
                }
                SavePrf("MonDrive",
                        &ulDriveMon,
                        sizeof(ULONG));
              }
              PostMsg(hwnd,
                      UM_TIMER,
                      MPVOID,
                      MPVOID);
            }
            break;

          case CLP_FRAME:
          case MEM_FRAME:
          case TSK_FRAME:
          case SWAP_FRAME:
          case CLOCK_FRAME:
          case CPU_FRAME:
            {
              USHORT cmd = CPU_PULSE;

              switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
                case MEM_FRAME:
                  cmd = CLOCK_CMDLINE;
                  break;
                case TSK_FRAME:
                  cmd = CPU_KILLPROC;
                  break;
                case CLP_FRAME:
                  cmd = CLOCK_CLIPBOARD;
                  break;
                case SWAP_FRAME:
                  cmd = SWAP_LAUNCHPAD;
                  break;
                case CLOCK_FRAME:
                  cmd = CLOCK_SETTINGS;
                  if((WinGetKeyState(HWND_DESKTOP,VK_SHIFT) & 0x8000) != 0)
                    cmd = CLOCK_CLOCK;
                  break;
              }
              PostMsg(hwnd,
                      WM_COMMAND,
                      MPFROM2SHORT(cmd,0),
                      MPVOID);
            }
            break;
        }
        return MRFROMSHORT(TRUE);
      }
      else
        PostMsg(hwnd,
                UM_TIMER,
                MPVOID,
                MPVOID);
      break;

    case WM_CONTEXTMENU:
      WinInvalidateRect(hwnd,
                        NULL,
                        FALSE);
      WinSendMsg(hwnd,
                 UM_TIMER,
                 MPVOID,
                 MPVOID);
      WinSetWindowPos(hwnd,
                      HWND_TOP,
                      0,
                      0,
                      0,
                      0,
                      SWP_ZORDER | SWP_DEACTIVATE);
      {
        USHORT id;

        id = WinQueryWindowUShort(hwnd,QWS_ID);
        hwndMenu = WinLoadMenu(HWND_DESKTOP,
                               0,
                               id);
        if(hwndMenu) {

          POINTL   ptl;
          SWP      swp;
          ULONG    ulDriveNum,ulDriveMap,x;
          MENUITEM mi;
          char     s[80];

          SetPresParams(hwndMenu,
                        -1,
                        -1,
                        -1,
                        helvtext);
          switch(id) {
            case CLP_FRAME:
              WinSendMsg(hwndMenu,
                         MM_SETITEMATTR,
                         MPFROM2SHORT(CLP_APPEND,FALSE),
                         MPFROM2SHORT(MIA_CHECKED,
                                      ((fClipAppend) ? MIA_CHECKED : 0)));
              break;

            case HARD_FRAME:
              if(!DosQCurDisk(&ulDriveNum,
                              &ulDriveMap)) {
                mi.iPosition = 0;
                mi.hwndSubMenu = (HWND)0;
                mi.hItem = 0L;
                mi.afStyle = MIS_TEXT | MIS_STATIC;
                mi.afAttribute = MIA_FRAMED;
                mi.id = -1;
                sprintf(s,
                        "Current drive is %c:",
                        (char)(ulDriveMon + '@'));
                WinSendMsg(hwndMenu,
                           MM_INSERTITEM,
                           MPFROMP(&mi),
                           MPFROMP(s));
                mi.iPosition = MIT_END;
                for(x = 2;x < 26;x++) {
                  if(ulDriveMap & (1 << x)) {
                    if(x != ulDriveMon - 1) {
                      mi.afStyle = MIS_TEXT;
                      mi.afAttribute = 0;
                      mi.id = HARD_C + (x - 2);
                      if(fShowFreeInMenus)
                        SetDriveText(x + 1,
                                     s);
                      else
                        sprintf(s,
                                "%c:",
                                (char)(x + 'A'));
                      WinSendMsg(hwndMenu,
                                 MM_INSERTITEM,
                                 MPFROMP(&mi),
                                 MPFROMP(s));
                    }
                  }
                }
              }
              break;

            case CLOCK_FRAME:
              WinEnableMenuItem(hwndMenu,
                                CLOCK_VIRTUAL,
                                fDesktops);
              WinEnableMenuItem(hwndMenu,
                                CLOCK_CLIPBOARD,
                                (ClipHwnd != (HWND)0));
              break;

            default:
              break;
          }
          WinQueryWindowPos(hwnd,
                            &swp);
          ptl.x = SHORT1FROMMP(mp1);
          ptl.y = SHORT2FROMMP(mp1);
          WinMapWindowPoints(hwnd,
                             HWND_DESKTOP,
                             &ptl,
                             1L);
          ptl.y = max(ptl.y,swp.y + swp.cy + 4);
          if(!WinPopupMenu(HWND_DESKTOP,
                           hwnd,
                           hwndMenu,
                           ptl.x - 4,
                           ptl.y - 4,
                           0,
                           PU_HCONSTRAIN | PU_VCONSTRAIN |
                           PU_KEYBOARD   | PU_MOUSEBUTTON1)) {
            WinDestroyWindow(hwndMenu);
            hwndMenu = (HWND)0;
          }
        }
      }
      return MRFROMSHORT(TRUE);

    case WM_MENUEND:
      WinSetFocus(HWND_DESKTOP,
                  HWND_DESKTOP);
      WinDestroyWindow((HWND)mp2);
      if(hwndMenu == (HWND)mp2)
        hwndMenu = (HWND)0;
      return 0;

    case UM_SETUP:
      {
        char *rootname = "SwapMon";

        switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
          case SWAP_FRAME:
            SwapHwnd = hwnd;
            swaptick = 0;
            break;
          case CLOCK_FRAME:
            ClockHwnd = hwnd;
            rootname = "Clock";
            break;
          case TSK_FRAME:
            TaskHwnd = hwnd;
            rootname = "Task";
            break;
          case MEM_FRAME:
            MemHwnd = hwnd;
            rootname = "Mem";
            break;
          case HARD_FRAME:
            HardHwnd = hwnd;
            rootname = "Hard";
            break;
          case CPU_FRAME:
            CPUHwnd = hwnd;
            rootname = "CPU";
            PostMsg(hwnd,
                    UM_REFRESH,
                    MPVOID,
                    MPFROMSHORT(TRUE));
            break;
          case CLP_FRAME:
            ClipMonHwnd = hwnd;
            rootname = "ClipMon";
            PostMsg(hwnd,
                    UM_REFRESH,
                    MPVOID,
                    MPFROMSHORT(TRUE));
            break;
        }
        if(!RestorePresParams(hwnd,rootname))
          SetPresParams(hwnd,
                        RGB_WHITE,
                        RGB_BLACK,
                        RGB_BLACK,
                        helvtext);
      }
      PostMsg(hwnd,
              UM_TIMER,
              MPVOID,
              MPVOID);
      return 0;

    case UM_REFRESH:
      switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
        case CLP_FRAME:
          {
            char  s[] = " Clip: [TtBbMmP] + ",*p;
            ULONG fmt[] = {CF_TEXT,CF_DSPTEXT,
                           CF_BITMAP,CF_DSPBITMAP,
                           CF_METAFILE,CF_DSPMETAFILE,
                           CF_PALETTE,0};
            ULONG x,ret;

            if(WinOpenClipbrd(WinQueryAnchorBlock(hwnd))) {
              p = s + 8;
              for(x = 0;fmt[x];x++) {
                ret = WinQueryClipbrdData(WinQueryAnchorBlock(hwnd),
                                          fmt[x]);
                if(!ret)
                  *p = '-';
                p++;
              }
              p += 2;
              if(!fClipAppend)
                *p = 0;
              WinCloseClipbrd(WinQueryAnchorBlock(hwnd));
            }
            else
              strcpy(s + 7,
                     "Can't open. ");
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpClip,
                           s);
          }
          break;

        case CPU_FRAME:
          {
            char        s[32];
            ULONG       percent,lastaverage;
            static BOOL lastavgset = 0;

            *s = 0;
            if(mp2) {
              strcpy(s," CPU: -% ");
              if(fAverage)
                strcat(s,"Avg: -%) ");
            }
            else {
              percent = ((MaxCount - (ULONG)mp1) * 100) / MaxCount;
              lastaverage = AveCPU;
              AveCPU = (((AveCPU * NumAveCPU) + percent) /
                        ((ULONG)NumAveCPU + 1));
              NumAveCPU++;
              if(!NumAveCPU)
                NumAveCPU = 65535;
              if(percent != LastPercent ||
                 (AveCPU != lastaverage &&
                  fAverage) ||
                 NumAveCPU == 1 ||
                 lastavgset != fAverage) {
                lastavgset = fAverage;
                LastPercent = percent;
                sprintf(s,
                        " CPU: %lu%% ",
                        percent);
                if(fAverage)
                  sprintf(s + strlen(s),
                          "(Avg: %lu%%) ",
                          AveCPU);
              }
            }
            if(*s)
              SetMonitorSize(hwnd,
                             hwndMenu,
                             &swpCPU,
                             s);
          }
          break;
      }
      return 0;

    case WM_TIMER:
      if(fSwapFloat &&
         !hwndMenu)
        WinSetWindowPos(hwnd,
                        HWND_TOP,
                        0,
                        0,
                        0,
                        0,
                        SWP_ZORDER | SWP_SHOW);
      if(WinQueryWindowUShort(hwnd,QWS_ID) == CLP_FRAME) {
        if(!ClipHwnd)
          WinDestroyWindow(hwnd);
        else
          TakeClipboard();
      }
      return 0;

    case UM_TIMER:
      switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
        case CLP_FRAME:
          ClipMonHwnd = hwnd;
          WinSendMsg(hwnd,
                     WM_TIMER,
                     MPVOID,
                     MPVOID);
          break;

        case CPU_FRAME:
          CPUHwnd = hwnd;
          WinSendMsg(hwnd,
                     WM_TIMER,
                     MPVOID,
                     MPVOID);
          break;

        case HARD_FRAME:
          {
            char s[80];

            HardHwnd = hwnd;
            SetDriveText(ulDriveMon,
                         s);
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpHard,
                           s);
          }
          break;

        case SWAP_FRAME:
          {
            FILEFINDBUF3 ffb;
            ULONG        nm = 1,fl = SWP_SIZE | SWP_SHOW | SWP_MOVE,
                         sh,sl,nh;
            HDIR         hdir = HDIR_CREATE;
            FSALLOCATE   fsa;
            char         s[128],ss[8],sss[8],mb,smb;
            static ULONG lastcbFile = 0;
            static BOOL  warned = FALSE;
            static char  SwapperDat[CCHMAXPATH] = "";

            strcpy(s,
                   " Unable to locate SWAPPER.DAT. ");
            SwapHwnd = hwnd;
            if(!*SwapperDat)
              FindSwapperDat(SwapperDat);
            if(*SwapperDat) {
              DosError(FERR_DISABLEHARDERR);
              if(!DosFindFirst(SwapperDat,
                               &hdir,
                               FILE_NORMAL | FILE_HIDDEN |
                               FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY,
                               &ffb,
                               sizeof(ffb),
                               &nm,
                               FIL_STANDARD)) {
                DosFindClose(hdir);
                if(ffb.cbFile != lastcbFile && lastcbFile)
                  swaptick = 9;
                lastcbFile = ffb.cbFile;
                DosError(FERR_DISABLEHARDERR);
                if(!DosQueryFSInfo(toupper(*SwapperDat) - '@',
                                   FSIL_ALLOC,
                                   &fsa,
                                   sizeof(FSALLOCATE)))
                  nm = fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector);
                else
                  nm = 0;
                if(nm <= 32768 * 1024) {
                  swaptick = 10;
                  if(!warned) {
                    SetPresParams(hwnd,
                                  RGB_RED,
                                  -1,
                                  -1,
                                  NULL);
                    warned = TRUE;
                    DosBeep(250,15);
                  }
                }
                else if(warned) {
                  PostMsg(hwnd,
                          UM_SETUP,
                          MPVOID,
                          MPVOID);
                  warned = FALSE;
                }
                mb = MakeNumber(nm,
                                &nh,
                                &sl);
                *sss = 0;
                if(sl)
                  sprintf(sss,
                          ".%02lu",
                          sl);
                smb = MakeNumber(ffb.cbFile,
                                 &sh,
                                 &sl);
                *ss = 0;
                if(sl)
                  sprintf(ss,
                          ".%02lu",
                          sl);
                sprintf(s,
                        " Swap: %lu%s%cb ",
                        sh,
                        ss,
                        smb);
                if(fShowSwapFree)
                  sprintf(s + strlen(s),
                          "(%lu%s%cb free) ",
                          nh,
                          sss,
                          mb);
              }
            }
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpSwap,
                           s);
          }
          break;

        case TSK_FRAME:
          {
            PROCESSINFO  *ppi;
            BUFFHEADER   *pbh = NULL;
            MODINFO      *pmi;
            long          numprocs = -1,numthreads = -1;
            char          s[80];

            if(!DosAllocMem((PVOID)&pbh,
                            USHRT_MAX + 4096,
                            PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) {
              if(!DosQProcStatus(pbh,
                                 USHRT_MAX)) {
                numprocs = numthreads = 0;
                ppi = pbh->ppi;
                while(ppi->ulEndIndicator != PROCESS_END_INDICATOR ) {
                  pmi = pbh->pmi;
                  while(pmi &&
                        ppi->hModRef != pmi->hMod)
                    pmi = pmi->pNext;
                  if(pmi) {
                    numprocs++;
                    numthreads += ppi->usThreadCount;
                  }
                  ppi = (PPROCESSINFO)(ppi->ptiFirst + ppi->usThreadCount);
                }
              }
              DosFreeMem(pbh);
              sprintf(s,
                      " Procs: %ld  Thrds: %ld ",
                      numprocs,
                      numthreads);
              SetMonitorSize(hwnd,
                             hwndMenu,
                             &swpTask,
                             s);
            }
          }
          break;

        case MEM_FRAME:
          {
            ULONG sh,sl,nh,amem;
            char  s[128],ss[8],sss[8],mb,smb;

            strcpy(s,
                   "Can't check virtual memory.");
            MemHwnd = hwnd;
            if(!DosQuerySysInfo(QSV_TOTAVAILMEM,
                                QSV_TOTAVAILMEM,
                                &amem,
                                sizeof(amem))) {
              mb = MakeNumber(amem,
                              &nh,
                              &sl);
              *ss = 0;
              if(sl)
                sprintf(ss,
                        ".%02lu",
                        sl);
              sprintf(s,
                      " VMem: %lu%s%cb ",
                      nh,
                      ss,
                      mb);
            }
            if(fShowPMem) {
              if(!Dos16MemAvail(&amem)) {
                mb = MakeNumber(amem,
                                &nh,
                                &sl);
                *ss = 0;
                if(sl)
                  sprintf(ss,
                          ".%02lu",
                          sl);
                sprintf(s + strlen(s),
                        " PMem: %lu%s%cb ",
                        nh,
                        ss,
                        mb);
              }
            }
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpMem,
                           s);
          }
          break;

        case CLOCK_FRAME:
          {
            char      s[80];
            DATETIME  dt;

            ClockHwnd = hwnd;
            if(!DosGetDateTime(&dt)) {
              sprintf(s,
                      " %0*u:%02u%s ",
                      ((ampm) ? 0 : 2),
                      (dt.hours % ((ampm) ? 12 : 24)) +
                       ((ampm && !(dt.hours % 12)) ? 12 : 0),
                      dt.minutes,
                      ((ampm) ? (dt.hours > 11) ? "pm" : "am" : ""));
              if(showdate)
                sprintf(s + strlen(s),
                        "%02u/%02u ",
                        dt.month,
                        dt.day);
            }
            else
              strcpy(s,"Unknown time");
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpClock,
                           s);
          }
          break;
      }
      return 0;

    case WM_COMMAND:
      {
        BOOL ctrl,shift;

        ctrl = ((WinGetKeyState(HWND_DESKTOP,VK_CTRL) & 0x8000) != 0);
        shift = ((WinGetKeyState(HWND_DESKTOP,VK_SHIFT) & 0x8000) != 0);

        switch(SHORT1FROMMP(mp1)) {
          case CLP_CLEAR:
            if(WinOpenClipbrd(WinQueryAnchorBlock(hwnd))) {
              WinEmptyClipbrd(WinQueryAnchorBlock(hwnd));
              WinCloseClipbrd(WinQueryAnchorBlock(hwnd));
              PostMsg(hwnd,
                      UM_REFRESH,
                      MPVOID,
                      MPVOID);
            }
            break;

          case CLP_APPEND:
            fClipAppend = (fClipAppend) ? FALSE : TRUE;
            SavePrf("ClipAppend",
                    &fClipAppend,
                    sizeof(BOOL));
            PostMsg(hwnd,
                    UM_REFRESH,
                    MPVOID,
                    MPVOID);
            if(ClipSetHwnd)
              PostMsg(ClipSetHwnd,
                      UM_REFRESH,
                      MPVOID,
                      MPVOID);
            break;

          case MSE_HELP:
            ViewHelp(hwnd,
                     "Monitors page");
            break;

          case CPU_PULSE:
            {
              PROGDETAILS pgd;

              WinSetWindowPos(hwnd,
                              HWND_TOP,
                              0,
                              0,
                              0,
                              0,
                              SWP_ACTIVATE | SWP_FOCUSACTIVATE);
              memset(&pgd,
                     0,
                     sizeof(pgd));
              pgd.Length = sizeof(pgd);
              pgd.swpInitial.fl = SWP_ACTIVATE | SWP_ZORDER;
              pgd.swpInitial.hwndInsertBehind = HWND_TOP;
              pgd.progt.fbVisible = SHE_VISIBLE;
              pgd.progt.progc = PROG_DEFAULT;
              pgd.pszExecutable = "PULSE.EXE";
              if(WinStartApp(CPUHwnd,
                             &pgd,
                             NULL,
                             NULL,
                             0)) {
                if(CPUHwnd) {
                  closethreads = 1;
                  DosSleep(1);
                  PostMsg(CPUHwnd,
                          UM_REFRESH,
                          MPVOID,
                          MPFROMSHORT(TRUE));
                }
              }
            }
            break;

          case CPU_RESET:
            AveCPU = 0;
            NumAveCPU = 0;
            break;

          case CLOCK_VIRTUAL:
          case CLOCK_SWITCHLIST:
          case CLOCK_CMDLINE:
          case CLOCK_CLIPBOARD:
          case CLOCK_CALCULATOR:
          case HARD_FM2:
          case MSE_FRAME:
            {
              ULONG msg2 = UM_SHOWME;
              MPARAM mp12 = 0,mp22 = 0;
              HWND   hwndP = hwndConfig;

              switch(SHORT1FROMMP(mp1)) {
                case CLOCK_CMDLINE:
                  mp12 = MPFROMLONG(((WinGetKeyState(HWND_DESKTOP,VK_CTRL) & 0x8000) != 0));
                  msg2 = UM_CMDLINE;
                  break;
                case CLOCK_CLIPBOARD:
                  msg2 = UM_CLIPMGR;
                  hwndP = ObjectHwnd3;
                  break;
                case CLOCK_SWITCHLIST:
                  msg2 = UM_SWITCHLIST;
                  break;
                case CLOCK_VIRTUAL:
                  msg2 = UM_VIRTUAL;
                  break;
                case CLOCK_CALCULATOR:
                  msg2 = UM_CALC;
                  break;
                case HARD_FM2:
                  msg2 = UM_STARTWIN;
                  mp12 = MPFROM2SHORT(C_STARTFM2,0);
                  break;
              }
              PostMsg(hwndP,
                      msg2,
                      mp12,
                      mp22);
            }
            break;

          case CLOCK_SETTINGS:
          case CLOCK_CLOCK:
          case SWAP_LAUNCHPAD:
          case SWAP_WARPCENTER:
          case SWAP_CONNECTIONS:
          case SWAP_INFO:
          case SWAP_SETTINGS:
          case SWAP_SYSTEM:
          case SWAP_TEMPS:
          case SWAP_FM2:
          case HARD_OPEN:
          case CVR_COLORPALETTE:
          case CVR_HICOLORPALETTE:
          case CVR_FONTPALETTE:
          case CPU_KILLPROC:
          case CPU_HARDWARE:
            {
              char *p = "<WP_CLOCK>",*pp = defopen;
              char s[8];

              switch(SHORT1FROMMP(mp1)) {
                case HARD_OPEN:
                  sprintf(s,
                          "%c:\\",
                          (char)(ulDriveMon + '@'));
                  p = s;
                  break;
                case SWAP_FM2:
                  p = "<FM3_Folder>";
                  break;
                case SWAP_TEMPS:
                  p = "<WP_TEMPS>";
                  break;
                case SWAP_SYSTEM:
                  p = "<WP_OS2SYS>";
                  break;
                case SWAP_SETTINGS:
                  p = "<WP_CONFIG>";
                  break;
                case SWAP_INFO:
                  p = "<WP_INFO>";
                  break;
                case SWAP_CONNECTIONS:
                  p = "<WP_CONNECTIONSFOLDER>";
                  break;
                case SWAP_WARPCENTER:
                  p = "<WP_WARPCENTER>";
                  break;
                case SWAP_LAUNCHPAD:
                  p = "<WP_LAUNCHPAD>";
                  break;
                case CLOCK_SETTINGS:
                  pp = setopen;
                  break;
                case CVR_COLORPALETTE:
                  p = "<WP_LORESCLRPAL>";
                  break;
                case CVR_HICOLORPALETTE:
                  p = "<WP_HIRESCLRPAL>";
                  break;
                case CVR_FONTPALETTE:
                  p = "<WP_FNTPAL>";
                  break;
                case CPU_KILLPROC:
                  p = "<FM/2_KILLPROC>";
                  break;
                case CPU_HARDWARE:
                  p = "<WP_HWMGR>";
                  break;
              }
              OpenObject(p,
                         pp);
            }
            break;

          case HARD_VDIR:
            {
              PROGDETAILS pgd;
              char        s[36];

              sprintf(s,
                      "/C VDIR.CMD %c:\\",
                      (char)(ulDriveMon + '@'));
              memset(&pgd,
                     0,
                     sizeof(pgd));
              pgd.Length = sizeof(pgd);
              pgd.swpInitial.fl = SWP_MINIMIZE | SWP_ACTIVATE | SWP_ZORDER;
              pgd.swpInitial.hwndInsertBehind = HWND_TOP;
              pgd.progt.fbVisible = SHE_VISIBLE;
              pgd.progt.progc = PROG_DEFAULT;
              pgd.pszExecutable = "CMD.EXE";
              WinStartApp((HWND)0,
                          &pgd,
                          s,
                          NULL,
                          0);
            }
            break;

          case HARD_CHKDSK:
            {
              PROGDETAILS pgd;
              char        s[8];

              WinSetWindowPos(hwnd,
                              HWND_TOP,
                              0,
                              0,
                              0,
                              0,
                              SWP_ACTIVATE | SWP_FOCUSACTIVATE);
              sprintf(s,
                      "%c:",
                      (char)(ulDriveMon + '@'));
              memset(&pgd,
                     0,
                     sizeof(pgd));
              pgd.Length = sizeof(pgd);
              pgd.swpInitial.fl = SWP_ACTIVATE | SWP_ZORDER;
              pgd.swpInitial.hwndInsertBehind = HWND_TOP;
              pgd.progt.fbVisible = SHE_VISIBLE;
              pgd.progt.progc = PROG_DEFAULT;
              pgd.pszExecutable = "PMCHKDSK.EXE";
              WinStartApp((HWND)0,
                          &pgd,
                          s,
                          NULL,
                          0);
            }
            break;

          default:
            if(SHORT1FROMMP(mp1) >= HARD_C &&
               SHORT1FROMMP(mp1) <= HARD_C + 24) {
              ulDriveMon = (SHORT1FROMMP(mp1) - HARD_C) + 3;
              PostMsg(hwnd,
                      UM_TIMER,
                      MPVOID,
                      MPVOID);
              if(ctrl)
                PostMsg(hwnd,
                        WM_COMMAND,
                        MPFROM2SHORT(HARD_OPEN,0),
                        MPVOID);
              else if(shift)
                PostMsg(hwnd,
                        WM_COMMAND,
                        MPFROM2SHORT(HARD_VDIR,0),
                        MPVOID);
            }
            break;
        }
      }
      return 0;

    case WM_DESTROY:
      switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
        case SWAP_FRAME:
          SwapHwnd = (HWND)0;
          break;
        case CLOCK_FRAME:
          ClockHwnd = (HWND)0;
          break;
        case HARD_FRAME:
          HardHwnd = (HWND)0;
          break;
        case CPU_FRAME:
          closethreads = 1;
          DosSleep(1);
          CPUHwnd = (HWND)0;
          break;
        case CLP_FRAME:
          ClipMonHwnd = (HWND)0;
          break;
        case MEM_FRAME:
          MemHwnd = (HWND)0;
          break;
        case TSK_FRAME:
          TaskHwnd = (HWND)0;
          break;
      }
      break;
  }
  return PFNWPStatic(hwnd,msg,mp1,mp2);
}
示例#29
0
文件: Client.cpp 项目: chaixun/HexIII
int OnConnectLost(Aris::Core::CONN *pConn)
{
    PostMsg(Aris::Core::MSG(SystemLost));
    return 0;
}
示例#30
0
文件: Control.cpp 项目: chaixun/robot
int tg(CMachineData& machineData,RT_MSG& msg)
{
    const int MapAbsToPhy[18]=
    {
        10,	11,	9,
        12,	14,	13,
        17,	15,	16,
        6,	8,	7,
        3,	5,	4,
        0,	2,	1
    };
    const int MapPhyToAbs[18]=
    {
        15,	17,	16,
        12,	14,	13,
        9,	11,	10,
        2,	0,	1,
        3,	5,	4,
        7,	8,	6
    };

    int CommandID;
    CommandID=msg.GetMsgID();

    switch(CommandID)
    {
    case NOCMD:
        for(int i=0;i<18;i++)
        {
            machineData.motorsCommands[i]=EMCMD_NONE;
        }
        rt_printf("NONE Command Get in NRT\n" );
        break;
    case ENABLE:
        for(int i=0;i<18;i++)
        {
            machineData.motorsCommands[i]=EMCMD_ENABLE;
        }
        rt_printf("ENABLE Command Get in NRT\n" );
        break;
    case POWEROFF:
        for(int i=0;i<18;i++)
        {
            machineData.motorsCommands[i]=EMCMD_POWEROFF;
            gait.IfReadytoSetGait(false,i);
        }
        rt_printf("POWEROFF Command Get in NRT\n" );
        break;
    case STOP:
        for(int i=0;i<18;i++)
        {
            machineData.motorsCommands[i]=EMCMD_STOP;
        }
        rt_printf("STOP Command Get in NRT\n" );
        break;
    case RUNNING:
        for(int i=0;i<18;i++)
        {
            machineData.motorsCommands[i]=EMCMD_RUNNING;
            gait.IfReadytoSetGait(true,i);
        }
        rt_printf("RUNNING Command Get in NRT\n" );
        break;
    case GOHOME_1:
        machineData.motorsCommands[MapAbsToPhy[0]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[1]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[2]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[6]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[7]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[8]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[12]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[13]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[14]]=EMCMD_GOHOME;

        gaitcmd[MapAbsToPhy[0]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[1]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[2]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[6]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[7]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[8]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[12]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[13]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[14]]=EGAIT::GAIT_HOME;

        rt_printf("GOHOME_1 Command Get in NRT\n" );
        break;
    case GOHOME_2:
        machineData.motorsCommands[MapAbsToPhy[3]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[4]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[5]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[9]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[10]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[11]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[15]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[16]]=EMCMD_GOHOME;
        machineData.motorsCommands[MapAbsToPhy[17]]=EMCMD_GOHOME;

        gaitcmd[MapAbsToPhy[3]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[4]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[5]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[9]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[10]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[11]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[15]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[16]]=EGAIT::GAIT_HOME;
        gaitcmd[MapAbsToPhy[17]]=EGAIT::GAIT_HOME;

        rt_printf("GOHOME_2 Command Get in NRT\n" );
        break;
    case HOME2START_1:
        if(gait.m_gaitState[MapAbsToPhy[0]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
            }
            gaitcmd[MapAbsToPhy[0]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[1]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[2]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[6]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[7]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[8]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[12]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[13]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[14]]=EGAIT::GAIT_HOME2START;

            rt_printf("HOME2START_1 Command Get in NRT\n" );
        }
        break;
    case HOME2START_2:
        if(gait.m_gaitState[MapAbsToPhy[3]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
            }
            gaitcmd[MapAbsToPhy[3]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[4]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[5]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[9]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[10]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[11]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[15]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[16]]=EGAIT::GAIT_HOME2START;
            gaitcmd[MapAbsToPhy[17]]=EGAIT::GAIT_HOME2START;

            rt_printf("HOME2START_2 Command Get in NRT\n" );
        }
        break;
    case FORWARD:
        if(gait.m_gaitState[MapAbsToPhy[0]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_MOVE;
                rt_printf("FORWARD Command Get in NRT\n" );
            }
        }
        break;
    case BACKWARD:
        if(gait.m_gaitState[MapAbsToPhy[0]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_MOVE_BACK;
                rt_printf("BACKWARD Command Get in NRT\n" );
            }
        }
        break;
    case TURNLEFT:
        if(gait.m_gaitState[MapAbsToPhy[0]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_TURN_LEFT;
                rt_printf("TURNLEFT Command Get in NRT\n" );
            }
        }
        break;
    case TURNRIGHT:
        if(gait.m_gaitState[MapAbsToPhy[0]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_TURN_RIGHT;
                rt_printf("TURNRIGHT Command Get in NRT\n" );
            }
        }
        break;
    case LEGUP:
        if(gait.m_gaitState[MapAbsToPhy[0]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_LEGUP;
                rt_printf("LEGUP Command Get in NRT\n" );

            }
        }
        break;
    case MOVE:
        if(gait.m_gaitState[MapAbsToPhy[0]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_MOVE_MAP;
                rt_printf("MOVE_MAP Command Get in NRT\n" );

            }
        }
        break;
    case TURN:
        if(gait.m_gaitState[MapAbsToPhy[0]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_TURN_MAP;
                rt_printf("TURN_MAP Command Get in NRT\n" );

            }
        }
        break;
    case BEGINDISCOVER:
        if(gait.m_gaitState[MapAbsToPhy[0]]==GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_BEGIN_DISCOVER;
                rt_printf("BEGINDISCOVER Command Get in NRT\n" );
            }
        }
        break;
    case ENDDISCOVER:
        if(gait.m_gaitState[MapAbsToPhy[0]]== GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_END_DISCOVER;
                rt_printf("ENDDISCOVER Command Get in NRT\n" );
            }
        }
        break;
    case STEPUP:
        if(gait.m_gaitState[MapAbsToPhy[0]]== GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_STEPUP_MAP;
                rt_printf("STEPUP_MAP Command Get in NRT\n" );
            }
        }
        break;
    case STEPDOWN:
        if(gait.m_gaitState[MapAbsToPhy[0]]== GAIT_STOP)
        {
            for(int i=0;i<18;i++)
            {
                machineData.motorsModes[i]=EOperationMode::OM_CYCLICVEL;
                gaitcmd[MapAbsToPhy[i]]=EGAIT::GAIT_STEPDOWN_MAP;
                rt_printf("STEPDOWN_MAP Command Get in NRT\n" );
            }
        }
        break;
    default:
        break;
    }

    gait.RunGait(gaitcmd,machineData);

    if(gait.IsGaitFinished())
    {
        if(CGait::IsMove == true&&CGait::IsMoveEnd == true)
        {
            CGait::IsMove = false;
            CGait::IsMoveEnd = false;
            cout<<"MOVE FINISHED!"<<endl;
            Vision_Msg visioncmd = Vision_UpperControl;
            Aris::Core::MSG visionmsg;
            visionmsg.SetMsgID(VS_Capture);
            visionmsg.SetLength(sizeof(visioncmd));
            visionmsg.Copy(&visioncmd, sizeof(visioncmd));
            PostMsg(visionmsg);
        }

        if(CGait::IsTurn == true&&CGait::IsTurnEnd == true)
        {
            CGait::IsTurn = false;
            CGait::IsTurnEnd = false;
            cout<<"TURN FINISHED!"<<endl;
            Vision_Msg visioncmd = Vision_UpperControl;
            Aris::Core::MSG visionmsg;
            visionmsg.SetMsgID(VS_Capture);
            visionmsg.SetLength(sizeof(visioncmd));
            visionmsg.Copy(&visioncmd, sizeof(visioncmd));
            PostMsg(visionmsg);
        }

        if(CGait::IsBeginDiscoverStart == true && CGait::IsBeginDiscoverEnd == true)
        {
            cout<<"BEGINDISCOVER FINISHED!"<<endl;
            Vision_Msg visioncmd = Vision_StepUp;
            Aris::Core::MSG visionmsg;
            visionmsg.SetMsgID(VS_Capture);
            visionmsg.SetLength(sizeof(visioncmd));
            visionmsg.Copy(&visioncmd, sizeof(visioncmd));
            PostMsg(visionmsg);
            CGait::IsBeginDiscoverStart = false;
            CGait::IsBeginDiscoverStart = false;
        }

        if(CGait::IsEndDiscoverStart == true && CGait::IsEndDiscoverEnd == true)
        {
            cout<<"ENDDISCOVER FINISHED!"<<endl;
            Vision_Msg visioncmd = Vision_UpperControl;
            Aris::Core::MSG visionmsg;
            visionmsg.SetMsgID(VS_Capture);
            visionmsg.SetLength(sizeof(visioncmd));
            visionmsg.Copy(&visioncmd, sizeof(visioncmd));
            PostMsg(visionmsg);
            CGait::IsEndDiscoverStart = false;
            CGait::IsEndDiscoverStart = false;
        }

        if(CGait::IsStepUp == true&&CGait::IsStepUpstep == true)
        {
            CGait::IsStepUpstep = false;
            Vision_Msg visioncmd = Vision_StepUp;
            Aris::Core::MSG visionmsg;
            visionmsg.SetMsgID(VS_Capture);
            visionmsg.SetLength(sizeof(visioncmd));
            visionmsg.Copy(&visioncmd, sizeof(visioncmd));
            PostMsg(visionmsg);
        }

        if(CGait::IsStepDown == true&&CGait::IsStepDownstep == true)
        {
            CGait::IsStepDownstep = false;
            Vision_Msg visioncmd = Vision_StepDown;
            Aris::Core::MSG visionmsg;
            visionmsg.SetMsgID(VS_Capture);
            visionmsg.SetLength(sizeof(visioncmd));
            visionmsg.Copy(&visioncmd, sizeof(visioncmd));
            PostMsg(visionmsg);
        }
        if(CGait::IsStepOver == true&&CGait::IsStepOverstep == true)
        {
            CGait::IsStepOverstep = false;
            Vision_Msg visioncmd = Vision_StepOver;
            Aris::Core::MSG visionmsg;
            visionmsg.SetMsgID(VS_Capture);
            visionmsg.SetLength(sizeof(visioncmd));
            visionmsg.Copy(&visioncmd, sizeof(visioncmd));
            PostMsg(visionmsg);
        }
    }

    return 0;
}