Ejemplo n.º 1
0
void MainScreen::onMessageListViewReviseSubItemMessage(MessageListView* pSender, string mainTitle, string subTitle)
{
	short mainType = XmlParser::GetMainType(U2A(mainTitle.c_str()));

	short subType = XmlParser::GetSubType(U2A(subTitle.c_str()));
	string subName = XmlParser::GetNoFBTypeToSubName(U2A(subTitle.c_str()));
	short fbm = XmlParser::getInstance()->getSubElementFBM(mainType, subType);
	short fbs = XmlParser::getInstance()->getSubElementFBS(mainType, subType);
	
	char cFbm[15];
	char cFbs[15];
	char cSubType[15];
	_itoa(fbm, cFbm, 10);
	_itoa(fbs, cFbs, 10);
	_itoa(subType, cSubType, 10);

	ReviseSubMessageDialog* pReviseSubMessageDialog = ReviseSubMessageDialog::create(mainType, subType);
	pReviseSubMessageDialog->setPosition(SCREEN_CENTER_POS);
	pReviseSubMessageDialog->setEditBoxFbm(cFbm);
	pReviseSubMessageDialog->setEditBoxFbs(cFbs);
	pReviseSubMessageDialog->setEditBoxSubName(A2U(subName.c_str()));
	pReviseSubMessageDialog->setEditBoxSubType(cSubType);
	m_pWindow->addChild(pReviseSubMessageDialog);
	pReviseSubMessageDialog->setDelegate(this);
}
Ejemplo n.º 2
0
void MainScreen::onNewFileDialogDelegateSaveMessage(NewFileDialog* pSender, string pathAndFileName)
{
	FILE* isHave = fopen(U2A(pathAndFileName.c_str()).c_str(), "r");
	if (isHave != NULL)
	{
		MessageBox(NULL, L"当前文件已经存在", L"", 0);
		fclose(isHave);
		return;
	}

	XmlParser::getInstance()->newFile(U2A(pathAndFileName.c_str()).c_str());

	isHave = fopen(U2A(pathAndFileName.c_str()).c_str(), "r");
	if (isHave == NULL)
	{
		MessageBox(NULL, L"文件创建失败: 请输入合法的文件名", L"", 0);
	}
	else
	{
		fclose(isHave);

		FileView* pFileView = (FileView*)this->getViewByID(ID_FILE_VIEW);
		pFileView->setText(pathAndFileName.c_str());

		onFileViewOpenFileMessage(pathAndFileName);
	}
}
Ejemplo n.º 3
0
// read observation data rinex ----------------------------------------------
int __fastcall TPlot::ReadObsRnx(TStrings *files, obs_t *obs, nav_t *nav,
                                 sta_t *sta)
{
    AnsiString s;
    gtime_t ts,te;
    double tint;
    int i;
    char obsfile[1024],navfile[1024],*p,*opt=RnxOpts.c_str();
    
    trace(3,"ReadObsRnx\n");
    
    TimeSpan(&ts,&te,&tint);
    
    for (i=0;i<files->Count;i++) {
        strcpy(obsfile,U2A(files->Strings[i]).c_str());
        
        ShowMsg(s.sprintf("reading obs data... %s",obsfile));
        Application->ProcessMessages();
        
        if (readrnxt(obsfile,1,ts,te,tint,opt,obs,nav,sta)<0) {
            ShowMsg("error: insufficient memory");
            return -1;
        }
    }
    ShowMsg("reading nav data...");
    Application->ProcessMessages();
    
    for (i=0;i<files->Count;i++) {
        strcpy(navfile,U2A(files->Strings[i]).c_str());
        
        if (!(p=strrchr(navfile,'.'))) continue;
        
        if (!strcmp(p,".obs")||!strcmp(p,".OBS")) {
            strcpy(p,".nav" ); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p,".gnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p,".hnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p,".qnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p,".lnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
        }
        else if (!strcmp(p+3,"o" )||!strcmp(p+3,"d" )||
                 !strcmp(p+3,"O" )||!strcmp(p+3,"D" )) {
            strcpy(p+3,"N"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"G"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"H"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"Q"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"L"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"P"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
        }
    }
    if (obs->n<=0) {
        ShowMsg(s.sprintf("no observation data: %s...",files->Strings[0].c_str()));
        freenav(nav,0xFF);
        return 0;
    }
    uniqnav(nav);
    return sortobs(obs);
}
Ejemplo n.º 4
0
void MainScreen::onMessageListViewReviseMainItemMessage(MessageListView* pSender, string mainTitle)
{
	short mainType = XmlParser::GetMainType(U2A(mainTitle.c_str()));
	string mainName = XmlParser::GetMainName(U2A(mainTitle.c_str()));

	ReviseMainMessageDialog* pReviseMainMessageDialog = ReviseMainMessageDialog::create(mainType, A2U(mainName.c_str()));
	pReviseMainMessageDialog->setDelegate(this);
	pReviseMainMessageDialog->setPosition(SCREEN_CENTER_POS);
	m_pWindow->addChild(pReviseMainMessageDialog);
}
Ejemplo n.º 5
0
void MainScreen::onAttributeListViewSelectedItemMessage(AttributeListView* pSender, string attributeName)
{
	string attName = XmlParser::GetAttName(U2A(attributeName.c_str()));
	string attType = XmlParser::GetAttType(U2A(attributeName.c_str()));
	string attData = XmlParser::GetAttData(U2A(attributeName.c_str()));
	//全局
	m_attName = attName;

	AttributeEditView* pAttributeEditView = (AttributeEditView*)getViewByID(ID_ATTRIBUTE_EDIT_VIEW);
	pAttributeEditView->setAttName(A2U(attName.c_str()));
	pAttributeEditView->setTypeName(A2U(attType.c_str()));
	pAttributeEditView->setData(A2U(attData.c_str()));
	pAttributeEditView->setEnabled(true);
}
Ejemplo n.º 6
0
// read solution status -----------------------------------------------------
void __fastcall TPlot::ReadSolStat(TStrings *files, int sel)
{
    AnsiString s;
    gtime_t ts,te;
    double tint;
    int i,n=0;
    char *paths[MAXNFILE],id[32];
    
    trace(3,"ReadSolStat\n");
    
    freesolstatbuf(SolStat+sel);
    
    for (i=0;i<MAXNFILE;i++) paths[i]=path_str[i];
    
    TimeSpan(&ts,&te,&tint);
    
    for (i=0;i<files->Count&&n<MAXNFILE;i++) {
        strcpy(paths[n++],U2A(files->Strings[i]).c_str());
    }
    ShowMsg(s.sprintf("reading %s...",paths[0]));
    ShowLegend(NULL);
    
    readsolstatt(paths,n,ts,te,tint,SolStat+sel);
    
    UpdateSatList();
}
Ejemplo n.º 7
0
// disconnect from external sources -----------------------------------------
void __fastcall TPlot::Disconnect(void)
{
    AnsiString s;
    char *cmd,caption[1024];
    int i;
    
    trace(3,"Disconnect\n");
    
    if (!ConnectState) return;
    
    ConnectState=0;
    
    for (i=0;i<2;i++) {
        if (StrCmdEna[i][1]) {
            cmd=StrCmds[i][1].c_str();
            strwrite(Stream+i,(unsigned char *)cmd,strlen(cmd));
        }
        strclose(Stream+i);
    }
    strcpy(caption,U2A(Caption).c_str());
    
    if (strstr(caption,"CONNECT")) {
        Caption=s.sprintf("DISCONNECT%s",caption+7);
    }
    UpdateTime();
    UpdatePlot();
}
Ejemplo n.º 8
0
void CslUDP::OnSocketEvent(wxSocketEvent& event)
{
    if (event.GetSocketEvent()!=wxSOCKET_INPUT)
        return;

    wxIPV4address addr;
    wxUint32 size;
    CslUDPPacket *packet=new CslUDPPacket(CSL_MAX_PACKET_SIZE);

    m_socket->RecvFrom(addr,packet->Data(),CSL_MAX_PACKET_SIZE);

    if (m_socket->Error())
    {
        packet->FreeData();
#ifndef __WXMSW__
        LOG_DEBUG("Error receiving packet: %s\n",U2A(GetSocketError(m_socket->LastError())));
#endif
    }

    size=m_socket->LastCount();
    packet->SetAddr(addr);
    packet->SetSize(size);
    m_bytesIn+=size;
    m_packetsIn++;

    wxCommandEvent evt(wxCSL_EVT_PING);
    evt.SetClientData(packet);
    wxPostEvent(m_evtHandler,evt);
}
bool CslIrcSession::SendRawCommand(const wxString& command)
{
    if (!CslIrcEngine::GetThread() || m_state!=STATE_CONNECTED)
        return false;

    return irc_send_raw(m_context.Session,U2A(command))==0;
}
Ejemplo n.º 10
0
void MainScreen::onNewAttributeDialogSaveMessage(NewAttributeDialog* pSender, string attName, string typeName, string data)
{
	XmlParser::getInstance()->addAttributeElement(m_mainType, m_subType, U2A(attName.c_str()).c_str(), U2A(typeName.c_str()).c_str(), U2A(data.c_str()).c_str());
	
	AttributeListView* pAttributeListView= (AttributeListView*)getViewByID(ID_ATTRIBUTE_LIST_VIEW);
	pAttributeListView->updateDataResouse();
}
Ejemplo n.º 11
0
void MainScreen::onFileViewOpenFileMessage(string strFilePathName)
{
	//载入XML文件
	bool isCorrectLoad = XmlParser::getInstance()->loadFile(U2A(strFilePathName.c_str()).c_str());
	if (!isCorrectLoad)
	{
		MessageBox(NULL, L"加载XML失败", L"错误", 0);
		m_isLoadConfigFile = false;
		return;
	}

	m_isLoadConfigFile = true;

	LogView* pClientLogView = (LogView*)getViewByID(ID_CLIENT_LOG_VIEW);
	pClientLogView->log(A2U("配置文件加载成功"));

	//更新MessageListView数据源
	MessageListView* pMessageListView = (MessageListView*)getViewByID(ID_MESSAGE_LIST_VIEW);
	pMessageListView->updateDataResouse();

	AttributeListView* pAttributeListView = (AttributeListView*)getViewByID(ID_ATTRIBUTE_LIST_VIEW);
	pAttributeListView->setTitle("");
	pAttributeListView->clear();

	FKCW_UIWidget_Button* pAddMessageButton = (FKCW_UIWidget_Button*)getViewByID(ID_ADD_MAIN_MESSAGE_BUTTON);
	pAddMessageButton->setEnabled(true);
}
Ejemplo n.º 12
0
void MainScreen::onNewSubMessageDialogSaveMessage( NewSubMessageDialog* pSender, short mainType, short subType, string subName, short fbm, short fbs )
{
	XmlParser::getInstance()->addSubElement(mainType, U2A(subName.c_str()).c_str(), subType, fbm, fbs);
	
	MessageListView* pMessageListView = (MessageListView*)getViewByID(ID_MESSAGE_LIST_VIEW);
	pMessageListView->updateDataResouse();
}
Ejemplo n.º 13
0
void MainScreen::onMessageListViewAddSubItemMessage(MessageListView* pSender, string mainTitle)
{
	short mainType = XmlParser::GetMainType(U2A(mainTitle.c_str()));
	NewSubMessageDialog* pNewSubMessageDialog = NewSubMessageDialog::create(mainType);
	pNewSubMessageDialog->setDelgate(this);
	pNewSubMessageDialog->setPosition(SCREEN_CENTER_POS);
	m_pWindow->addChild(pNewSubMessageDialog);
}
bool CslIrcSession::JoinChannel(const wxString& name,const wxString& password)
{
    if (m_state!=STATE_CONNECTED)
        return false;

    CslIrcChannel *channel;

    if ((channel=FindChannel(name)))
    {
        if (channel->Connected)
            return false;
    }
    else
        m_channels.Add(new CslIrcChannel(name,password));

    return irc_cmd_join(m_context.Session,U2A(name),U2A(password))==0;
}
Ejemplo n.º 15
0
void MainScreen::onReviseMainMessageDialogSaveMessage(ReviseMainMessageDialog* pSender, short oldMainType, short mainType, string mainName)
{
	XmlParser::getInstance()->setMainElementName(oldMainType, U2A(mainName.c_str()));
	XmlParser::getInstance()->setMainElementType(oldMainType, mainType);

	MessageListView* pMessageListView = (MessageListView*)getViewByID(ID_MESSAGE_LIST_VIEW);
	pMessageListView->updateDataResouse();
}
Ejemplo n.º 16
0
void MainScreen::onReviseSubMessageDialogSaveMessage(ReviseSubMessageDialog* pSender, short mainType, short subType)
{
	XmlParser::getInstance()->setSubElementFBM(mainType, subType, pSender->getFbm());
	XmlParser::getInstance()->setSubElementFBS(mainType, subType, pSender->getFbs());
	XmlParser::getInstance()->setSubElementName(mainType, subType, U2A(pSender->getSubName().c_str()));
	XmlParser::getInstance()->setSubElementType(mainType, subType, pSender->getSubType());

	MessageListView* pMessageListView = (MessageListView*)getViewByID(ID_MESSAGE_LIST_VIEW);
	pMessageListView->updateDataResouse();
}
bool CslIrcSession::SendTextMessage(const wxString& channel,const wxString& text)
{
    if (m_state!=STATE_CONNECTED)
        return false;

    wxCharBuffer buffer;
    if (ConvertToChannelEncoding(channel,text,buffer))
        return irc_cmd_msg(m_context.Session,U2A(channel),buffer)==0;

    return false;
}
Ejemplo n.º 18
0
// read observation data ----------------------------------------------------
void __fastcall TPlot::ReadObs(TStrings *files)
{
    obs_t obs={0};
    nav_t nav={0};
    sta_t sta={0};
    AnsiString s;
    char file[1024];
    int i,nobs;
    
    trace(3,"ReadObs\n");
    
    if (files->Count<=0) return;
    
    ReadWaitStart();
    ShowLegend(NULL);
    
    if ((nobs=ReadObsRnx(files,&obs,&nav,&sta))<=0) {
        ReadWaitEnd();
        return;
    }
    ClearObs();
    Obs=obs;
    Nav=nav;
    Sta=sta;
    SimObs=0;
    UpdateObs(nobs);
    UpdateMp();
    
    if (ObsFiles!=files) {
        ObsFiles->Assign(files);
    }
    NavFiles->Clear();
    
    strcpy(file,U2A(files->Strings[0]).c_str());
    
    Caption=s.sprintf("%s%s",file,files->Count>1?"...":"");
    
    BtnSol1->Down=true;
    time2gpst(Obs.data[0].time,&Week);
    SolIndex[0]=SolIndex[1]=ObsIndex=0;
    
    if (PlotType<PLOT_OBS||PLOT_DOP<PlotType) {
        UpdateType(PLOT_OBS);
    }
    else {
        UpdatePlotType();
    }
    FitTime();
    
    ReadWaitEnd();
    UpdateObsType();
    UpdateTime();
    UpdatePlot();
}
bool CslIrcSession::SendCtcpAction(const wxString& channel,const wxString& text)
{
    if (!CslIrcEngine::GetThread() || m_state!=STATE_CONNECTED)
        return false;

    wxCharBuffer buffer;
    if (ConvertToChannelEncoding(channel,text,buffer))
        return irc_cmd_me(m_context.Session,U2A(channel),buffer)==0;

    return false;
}
bool CslIrcSession::ChangeNick(const wxString& nick)
{
    if (!CslIrcEngine::GetThread())
        return false;

    if (m_state==STATE_DISCONNECTED)
    {
        m_context.Server->Network->Nick=nick;
        return true;
    }

    return irc_cmd_nick(m_context.Session,U2A(nick))==0;
}
Ejemplo n.º 21
0
void MainScreen::onMessageListViewSelectedSubItemMessage(MessageListView* pSender, string mainTitle, string subTitle)
{
	//为全局变量赋值
	m_mainType = XmlParser::GetMainType(U2A(mainTitle.c_str()));
	m_subType = XmlParser::GetSubType(U2A(subTitle.c_str()));

	short fbm = XmlParser::getInstance()->getSubElementFBM(m_mainType, m_subType);
	short fbs = XmlParser::getInstance()->getSubElementFBS(m_mainType, m_subType);

	char cFbm[26];
	char cFbs[26];
	_itoa(fbm, cFbm, 10);
	_itoa(fbs, cFbs, 10);

	AttributeListView* pAttributeListView = (AttributeListView*)getViewByID(ID_ATTRIBUTE_LIST_VIEW);
	pAttributeListView->setTitle(subTitle);
	pAttributeListView->setSubTitle(A2U(" 反馈主类型:") + cFbm + A2U(" 反馈子类型:") + cFbs);
	pAttributeListView->updateDataResouse();

	FKCW_UIWidget_Button* pSendMessageButton = (FKCW_UIWidget_Button*)getViewByID(ID_SEND_MESSAGE_BUTTON);
	pSendMessageButton->setEnabled(true);
}
Ejemplo n.º 22
0
void MainScreen::onSaveMessage(AttributeEditView* pAttributeEditView, string attName, string typeName, string data)
{
	XmlParser::getInstance()->setAttributeElementDataType(m_mainType, m_subType, m_attName, typeName);
	XmlParser::getInstance()->setAttributeElementValue(m_mainType, m_subType, m_attName, U2A(data.c_str()));
	XmlParser::getInstance()->setAttributeElementName(m_mainType, m_subType, m_attName, U2A(attName.c_str()));

	AttributeListView* pAttibuteListView = (AttributeListView*)getViewByID(ID_ATTRIBUTE_LIST_VIEW);
	pAttibuteListView->updateDataResouse();

	pAttributeEditView->setAttName("");
	pAttributeEditView->setTypeName("");
	pAttributeEditView->setData("");
}
void event_ctcp_request(irc_session_t *session,const char* WXUNUSED(event),const char *origin,
                        const char **params,unsigned int WXUNUSED(count))
{
    char nick[128];

    irc_target_get_nick(origin,nick,sizeof(nick));

    if (!strcasecmp(params[0],"VERSION"))
    {
        wxString s;
        s<<wxT("VERSION ")<<CSL_NAME_STR<<wxT(" ")<<CSL_VERSION_LONG_STR<<CSL_WEBADDRFULL_STR;
        irc_cmd_ctcp_reply(session,nick,U2A(s));
    }
}
void irc_auto_rename_nick(irc_session_t *session)
{
    static int tries=0;
    CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session);

    if (++tries<2)
    {
        //context->Server->Network->Nick+=wxT("'");
        context->Server->Network->Nick=context->Server->Network->AltNick;
        irc_cmd_nick(session,U2A(context->Server->Network->AltNick));
    }
    else
        irc_cmd_quit(session,NULL);
}
Ejemplo n.º 25
0
// read navigation data -----------------------------------------------------
void __fastcall TPlot::ReadNav(TStrings *files)
{
    AnsiString s;
    gtime_t ts,te;
    double tint;
    char navfile[1024],*opt=RnxOpts.c_str();
    int i;
    
    trace(3,"ReadNav\n");
    
    if (files->Count<=0) return;
    
    ReadWaitStart();
    ShowLegend(NULL);
    
    TimeSpan(&ts,&te,&tint);
    
    freenav(&Nav,0xFF);
    
    ShowMsg("reading nav data...");
    Application->ProcessMessages();
    
    for (i=0;i<files->Count;i++) {
        strcpy(navfile,U2A(files->Strings[i]).c_str());
        readrnxt(navfile,1,ts,te,tint,opt,NULL,&Nav,NULL);
    }
    uniqnav(&Nav);
    
    if (Nav.n<=0&&Nav.ng<=0&&Nav.ns<=0) {
        ShowMsg(s.sprintf("no nav message: %s...",files->Strings[0].c_str()));
        ReadWaitEnd();
        return;
    }
    if (NavFiles!=files) {
        NavFiles->Assign(files);
    }
    UpdateObs(NObs);
    UpdateMp();
    ReadWaitEnd();
    
    UpdatePlot();
}
bool CslIrcSession::Disconnect(const wxString& message)
{
    if (!CslIrcEngine::GetThread() || m_state==STATE_DISCONNECTED)
        return false;

    wxString s;

    if (message.IsEmpty())
        s<<CSL_NAME_STR<<wxT(" ")<<CSL_VERSION_LONG_STR<<CSL_WEBADDRFULL_STR;
    else
        s=message;

    m_state=STATE_DISCONNECTED;

    irc_cmd_quit(m_context.Session,U2A(s));

    CslIrcEngine::GetThread()->Disconnect(m_context);

    return true;
}
Ejemplo n.º 27
0
bool CslUDP::SendPing(CslUDPPacket *packet)
{
    wxInt32 size=packet->Size();

    m_socket->SendTo(packet->Address(),packet->Data(),size);

    packet->SetSize(0);
    delete packet;

    if (m_socket->Error())
    {
        LOG_DEBUG("Error sending packet: %s\n",U2A(GetSocketError(m_socket->LastError())));
        return false;
    }

    m_bytesOut+=size;
    m_packetsOut++;

    return true;
}
Ejemplo n.º 28
0
void MainScreen::onMessageListViewRemoveSubItemMessage(MessageListView* pSender, string mainTitle, string subTitle)
{
	short mainType = XmlParser::GetMainType(U2A(mainTitle.c_str()));
	short subType = XmlParser::GetSubType(U2A(subTitle.c_str()));
	XmlParser::getInstance()->removeSubElement(mainType, subType);
}
Ejemplo n.º 29
0
void MainScreen::onAttributeListViewRemoveItemMessage(AttributeListView* pSender, string attributeName)
{
	string attName = XmlParser::GetAttName(U2A(attributeName.c_str()));
	XmlParser::getInstance()->removeAttributeElement(m_mainType, m_subType, attName);
}
wxThread::ExitCode CslIrcThread::Entry()
{
    int maxfd,error;
    struct timeval timeout;
    fd_set readSet,writeSet;
    CslIrcContext *context=NULL;
    wxInt32 pos=0,count=0,termcount=10;

    m_mutex.Lock();

    while (termcount)
    {
        if (m_terminate)
            termcount--;

        m_section.Enter();
        count=m_contexts.GetCount();
        if (count)
            context=m_contexts.Item((pos=pos+1>=count ? 0:pos+1));
        else
            context=NULL;
        m_section.Leave();

        if (!context)
        {
            if (!m_terminate)
                m_condition->Wait();
            continue;
        }

        if (!context->Disconnecting && !irc_is_connected(context->Session))
        {
            if (irc_connect(context->Session,U2A(context->Server->Address),
                            context->Server->Port,NULL,U2A(context->Server->Network->Nick),
                            U2A(CSL_NAME_SHORT_STR),NULL))
            {
                LibIrcError(context,irc_errno(context->Session));
                continue;
            }
        }

        FD_ZERO(&readSet);
        FD_ZERO(&writeSet);
        timeout.tv_sec=0;
        timeout.tv_usec=max(50000,200000/count);
        maxfd=0;

        irc_add_select_descriptors(context->Session,&readSet,&writeSet,&maxfd);

        if (select(maxfd+1,&readSet,&writeSet,NULL,&timeout)<0)
        {
            LOG_DEBUG("select failed: %s\n",strerror(errno));
            if (errno==EINTR)
                continue;
        }

        if (irc_process_select_descriptors(context->Session,&readSet,&writeSet))
            if ((error=irc_errno(context->Session)))
                LibIrcError(context,error);
    }

    m_mutex.Unlock();

    return 0;
}