小编chr*_*isp的帖子

Easy Admin - 在Show Action中显示完整的国家/地区名称

我有一个需要一个国家的地址实体.在相关的表格中,我使用的是Symfony的CountryType,它显示了一个用户友好的国家选择,并将其缩写存储在实体中(例如德国的DE或瑞士的CH).

要在管理面板的show动作中显示地址'country,我在以下行中使用以下行easy_admin.yaml:

- { property: country, label: 'address.entity.country' }
Run Code Online (Sandbox Code Playgroud)

问题:

这仅显示缩写而不是国家的实际名称.我怎么能改变呢?

国家地址实体:

/**
 * @ORM\Column(type="string", length=255)
 */
private $country;
Run Code Online (Sandbox Code Playgroud)

symfony symfony2-easyadmin easyadmin

8
推荐指数
1
解决办法
179
查看次数

测量网络上的经过时间

我开发了一个服务器和客户端应用程序,用于使用RTSP将视频帧从一端流式传输到另一端.现在,为了收集有助于我改进应用程序的统计数据,我需要测量发送帧和接收帧之间经过的时间.

目前我正在使用以下公式:

Client_Receive_Timestamp - Server_Send_Timestamp = Elapsed_Time
Run Code Online (Sandbox Code Playgroud)

问题

在我看来,经过的时间大约是100-200ms.我认为原因是服务器时钟和客户端时钟不同步,差异大约为100-200ms.

如何准确测量两个mashines之间的经过时间?

主题准确测量机器之间的经过时间建议计算往返延迟.但是,我不能使用此解决方案,因为客户端不请求帧.它只是通过RTSP接收帧.

c++ time

6
推荐指数
1
解决办法
990
查看次数

Symfony2 - 自定义DQL函数已注册但不存在

我绝望地试图在Symfony2中包含LEVENSHTEIN功能,但是,我仍然会收到错误.规格+到目前为止我做了什么:

  • PostgreSQL 9.3
  • LEVENSHTEIN包含在fuzzystrmatch扩展中
  • 通过shell执行测试函数.完美无缺:

    postgres=# SELECT levenshtein('test', 'text');
     levenshtein
    -------------
               1
    (1 row)
    
    Run Code Online (Sandbox Code Playgroud)
  • 在DQL中添加了该功能:

    <?php
    
    namespace AppBundle\DQL;
    
    use Doctrine\ORM\Query\AST\Functions\FunctionNode;
    use Doctrine\ORM\Query\Lexer;
    use Doctrine\ORM\Query\Parser;
    use Doctrine\ORM\Query\SqlWalker;
    
    class LevenshteinFunction extends FunctionNode {
    
        public $firstStringExpression = null;
    
        public $secondStringExpression = null;
    
        public function getSql(SqlWalker $sqlWalker) {
            return 'LEVENSHTEIN(' . $this->firstStringExpression->dispatch($sqlWalker) . ', ' . $this->secondStringExpression->dispatch($sqlWalker) . ')';
        }
    
        public function parse(Parser $parser) {
            // levenshtein(str1, str2)
            $parser->match(Lexer::T_IDENTIFIER);
            $parser->match(Lexer::T_OPEN_PARENTHESIS);
            $this->firstStringExpression = $parser->StringPrimary();
            $parser->match(Lexer::T_COMMA);
            $this->secondStringExpression = $parser->StringPrimary();
            $parser->match(Lexer::T_CLOSE_PARENTHESIS);
        }
    }
    
    Run Code Online (Sandbox Code Playgroud)

    Config.yml

    orm:
        auto_generate_proxy_classes: "%kernel.debug%" …
    Run Code Online (Sandbox Code Playgroud)

php postgresql doctrine dql symfony

5
推荐指数
1
解决办法
719
查看次数

Boost::Asio - async_accept 处理程序中的 async_wait 导致应用程序崩溃

我目前正在尝试使用 Boost::Asio 创建一个服务器应用程序,该应用程序执行两个简单的操作:

  1. 接受客户端的传入连接
  2. 一旦客户被接受,就开始一个boost::asio::deadline_timer重复的过程

以下代码显示了我当前的尝试:

#define BOOST_ASIO_ENABLE_HANDLER_TRACKING

#include <WinSock2.h>
#include <Mswsock.h>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

using namespace boost::asio;
using namespace boost::asio::ip;

void timerHandler(const boost::system::error_code& errorCode, deadline_timer* timer) {
    timer->expires_at(timer->expires_at() + boost::posix_time::seconds(1));
    timer->async_wait(boost::bind(timerHandler, _1, timer));
}

void acceptHandler(const boost::system::error_code &errorCode, io_service *ioService) {
    deadline_timer timer(*ioService, boost::posix_time::seconds(1));
    timer.async_wait(boost::bind(timerHandler, _1, &timer));
}

int main(int argc, char** argv) {
    io_service ioService;
    tcp::socket socket(ioService);
    tcp::acceptor acceptor{ ioService, tcp::endpoint{ tcp::v4(), 12345 } };
    acceptor.listen();
    acceptor.async_accept(socket, boost::bind(acceptHandler, _1, &ioService));
    ioService.run(); …
Run Code Online (Sandbox Code Playgroud)

c++ boost-asio

0
推荐指数
1
解决办法
1422
查看次数