我有一个需要一个国家的地址实体.在相关的表格中,我使用的是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) 我开发了一个服务器和客户端应用程序,用于使用RTSP将视频帧从一端流式传输到另一端.现在,为了收集有助于我改进应用程序的统计数据,我需要测量发送帧和接收帧之间经过的时间.
目前我正在使用以下公式:
Client_Receive_Timestamp - Server_Send_Timestamp = Elapsed_Time
Run Code Online (Sandbox Code Playgroud)
问题
在我看来,经过的时间大约是100-200ms.我认为原因是服务器时钟和客户端时钟不同步,差异大约为100-200ms.
题
如何准确测量两个mashines之间的经过时间?
主题准确测量机器之间的经过时间建议计算往返延迟.但是,我不能使用此解决方案,因为客户端不请求帧.它只是通过RTSP接收帧.
我绝望地试图在Symfony2中包含LEVENSHTEIN功能,但是,我仍然会收到错误.规格+到目前为止我做了什么:
通过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)我目前正在尝试使用 Boost::Asio 创建一个服务器应用程序,该应用程序执行两个简单的操作:
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)