让我们使用伪代码推理:
>>> aa = [[1,2,3],
[4,5,6]].T
>>> aa
[[1,4],
[2,5],
[3,6]]
>>> bb = [0,1,1].T
>>> b
[0,
1,
1]
>>> cc = zeros(2, 2)
>>> cc
[[0,0],
[0,0]]
下一个指令是一个分配,该分配在第一个索引 cc
带有 bb
值。在这里,我们使用 bb
中的索引从 cc
选择整个行。由于 bb
中有三行,因此结果张量将由 cc [bb [0]]
, cc [bb [1]]
组成。 ,and cc [bb [2]]
但 bb [1]
and bb [2]
是相等的 cc [0]
和 cc [1]
。
右侧操作数为 aa
,由三行组成: [1,4]
, [2,5]
和 [3,6]
。这意味着执行的最终操作将等同于(行和行):
cc[0] += [1,4]
cc[1] += [3,6]
由于 cc
以零值初始化,我们可以总结到:
>>> cc[0] = [1,4]
>>> cc[1] = [3,6]
这意味着:
>>> cc
[[1,4],
[3,6]]
好的,我找到了解决方案。 express-fileupload
使用 busbboy 在引擎盖下。您可以传递Busboy选项,其中之一是 defparamcharset
:
“对于多部分表单,默认字符设置用于用于值的值
未扩展的部分标题参数(例如文件名)
参数(其中包含一个明确的字符集)。”
文档状态默认值:'latin1'。
,但在我的情况下,它取决于运行的OS!,
如果您初始化了中间件如以下内容,它应该正确地编码文件名:
app.use(fileUpload({
defCharset: 'utf8',
defParamCharset: 'utf8'
}));
共享指针是问题。 bind<>
模板参数不能是指针或参考类型
有一些有关为什么在
bind<>
中禁止指针的信息: https://github.com/boost-ext/di/issues/317
我想出了一种工作方式来绑定依赖性:
const auto injector =
di::make_injector(di::bind<ioperation>().to(
[=, &use_sum](const auto& injector) -> op_ptr
{
return use_sum
? sum_creator()
: dot_product_creator(sum_creator());
}) //
);
请注意,只要存在注射器,通过值捕获工厂功能就可以保持DLL。这比参考捕获更安全。
通过参考突出显示喷油器是动态的,捕获use_sum
。如果不需要,那么我将用:替换整个喷油器
const auto inector = di :: make_injector(di :: bind&lt; ioperation&gt;()。 use_sum? sum_creator():dot_product_creator(sum_creator())// );
完整演示
另请参见GitHub: https ://github.com/sehe/boost-plugins-prework
-
文件
ioperation.hpp
#pragma一次 #include&lt; boost/shared_ptr.hpp&gt; #include&lt; string&gt; 结构ioperation { 虚拟std :: string name()const = 0; 虚拟浮点计算(float x,float y)= 0; Virtual〜ioperation()=默认值; }; 使用op_ptr = boost :: shared_ptr&lt; ioperation&gt;;
-
文件
sum.cpp
#include&lt; boost/config.hpp&gt; #include&lt; boost/dll/alias.hpp&gt; #include&lt; boost/dll/import.hpp&gt; #include“ ioperation.hpp” #include&lt; iostream&gt; 名称空间sum_namespace { 班级总和:公共ioperation { 民众: sum(){std :: cout&lt;&lt; “ [sum_constructor]”&lt;&lt; std :: endl; } std :: string name()const {返回“ sum”; } float计算(float x,float y){返回x + y; } 〜sum(){std :: cout&lt;&lt; “ [〜sum_destructor]”&lt;&lt; std :: endl; } //工厂方法 static op_ptr create_sum(){return op_ptr(new sum()); } }; } //名称空间sum_namespace BOOST_DLL_ALIAS( sum_namespace :: sum :: create_sum,//&lt; - 此函数由...导出... create_sum //&lt; - ...这个别名名称 )
-
文件
sum.hpp
#pragma一次 #include“ ioperation.hpp” #include“ ioperation.hpp” 名称空间sum_namespace { 结构总和:ioperation { 和(); 〜sum()覆盖; std :: string name()const覆盖; 浮点计算(浮动,浮点)覆盖; static op_ptr create_sum(); }; } //名称空间sum_namespace
-
文件
dot_product.cpp
#include“ dot_product.h” #include&lt; boost/config.hpp&gt; #include&lt; boost/dll/alias.hpp&gt; #include&lt; boost/dll/import.hpp&gt; #include&lt; iostream&gt; 命名空间dot_product_namespace { dot_product :: dot_product(op_ptr&amp; arg){ sum_ptr = arg; std :: cout&lt;&lt; “ [dot_product_constructor]”&lt;&lt; std :: endl; } std :: String dot_product :: name()const {返回“ dot_product”; } float dot_product ::计算(float a1,float a2){ //与给定矢量的点产品 //公式:AB = A1*B1 + A2*B2 返回sum_ptr-&gt;计算(a1 * a1,a2 * a2); } //工厂方法 /*static*/ op_ptr dot_product :: create_dot_product(op_ptr sum_ptr){ return op_ptr(new Dot_product(sum_ptr)); } dot_product :: 〜dot_product(){ std :: cout&lt;&lt; “ [〜DOT_PRODUCT_DESTRUCTOR]”&lt;&lt; std :: endl; } }; //名称空间dot_product_namespace BOOST_DLL_ALIAS(dot_product_namespace :: dot_product :: create_dot_product,//&lt; - 此功能由...导出 create_dot_product //&lt; - ...此别名名称 )
-
文件
dot_product.h
#pragma一次 #include“ ioperation.hpp” 命名空间dot_product_namespace { struct dot_product:ioperation { dot_product(op_ptr&amp;); 〜dot_product()覆盖; std :: string name()const覆盖; 浮点计算(浮动,浮点)覆盖; static op_ptr create_dot_product(op_ptr sum_ptr); 私人的: op_ptr sum_ptr; }; }; //名称空间dot_product_namespace
-
文件
application_di.cpp
#include“ boost/function.hpp” #include“ ioperation.hpp” #include&lt; boost/di.hpp&gt; #include&lt; boost/dll/import.hpp&gt; #include&lt; iostream&gt; 命名空间di = boost :: di; 命名空间dll = boost :: dll; 类应用程序{ 私人的: op_ptr ptr_; 民众: app(boost :: shared_ptr&lt; ioperation&gt; ptr) :ptr_(ptr) { std :: cout&lt;&lt; “名称:”&lt;&lt; ptr _--&gt; name()&lt;&lt;&lt; std :: endl; } }; 使用boost :: filesystem :: path; int main(int argc,char ** argv){ //设置通往库(.so)文件的路径 路径lib_path(argc&gt; 1?argv [1]:“。”), child_library_path = lib_path /“ dot_product”, parent_library_path = lib_path /“ sum”; //定义LIB构造函数的功能类型 使用sum_create_t = op_ptr(); 使用dot_product_create_t = op_ptr(op_ptr); //进口总和工厂 auto sum_creator = boost :: dll :: import_alias&lt; sum_create_t&gt;( parent_library_path, “ create_sum”, dll :: load_mode :: append_decorations); //导入dot_product lib工厂 auto dot_product_creator = boost :: dll :: import_alias&lt; dot_product_create_t&gt;( child_library_path, “ create_dot_product”, dll :: load_mode :: append_decorations); auto use_sum = true; const auto注射器= di :: make_injector(di :: bind&lt; ioperation&gt;()。 [=,&amp; use_sum](const auto&amp;喷油器) - &gt; OP_PTR { 返回use_sum ? sum_creator() :dot_product_creator(sum_creator()); })// ); use_sum = argc&gt; 2; 注射器。 }
-
文件
application_main.cpp
#include“ boost/shared_ptr.hpp” #include&lt; boost/dll/import.hpp&gt; #include“ boost/function.hpp” #include&lt; iostream&gt; #include“ ioperation.hpp” 命名空间dll = boost :: dll; 使用boost :: filesystem :: path; int main(int argc,char ** argv) { //设置通往库(.so)文件的路径 路径lib_path(argc&gt; 1?argv [1]:“。”), child_library_path = lib_path /“ dot_product”, parent_library_path = lib_path /“ sum”; //定义LIB构造函数的功能类型 使用sum_create_t = op_ptr(); 使用dot_product_create_t = op_ptr(op_ptr); //进口总和工厂 auto sum_creator = dll :: import_alias&lt; sum_create_t&gt;( parent_library_path, “ create_sum”, dll :: load_mode :: append_decorations); //导入dot_product lib工厂 auto dot_product_creator = dll :: import_alias&lt; dot_product_create_t&gt;( child_library_path, “ create_dot_product”, dll :: load_mode :: append_decorations); auto sum_ptr = sum_creator(); auto dot_product_ptr = dot_product_creator(sum_ptr); //执行计算对象PTR的方法 for(op_ptr op:{sum_creator(),dot_product_creator(sum_creator())}){ std :: cout&lt;&lt; “ \ nplugin名称:”&lt;&lt; op-&gt; name()&lt;&lt; “ \ n”; std :: cout&lt;&lt; “计算(1,2):”&lt;&lt; op-&gt;计算(1,2)&lt;&lt;&lt; “ \ n”; } }
-
文件
compile_n_run.sh
#!/bin/bash 设置-e -x -u ./cleanup.sh echo“ =&gt;现在编译...” cppflags =“ - std = c ++ 14 -fpic -i/home/sehe/sehe/custom/boost -di/include/include/” ldflags =“” #在Sehe的机器上编译所需: #cppflags =“ $ cppflags -i/home/sehe/sehe/custom/boost -di/include/include/' #cppflags =“ $ cppflags -isystem/home/sehe/sehe/custom/superboost/”; #ldflags =“ $ ldflags -l/home/sehe/sehe/custom/superboost/stage/lib” g ++ $ cppflags sum.cpp -shared -o libsum.so $ ldflags g ++ $ cppflags dot_product.cpp -shared -o libdot_product.so $ ldflags #添加应用程序库 ldflags =“ $ ldflags -lboost_filesystem -lboost_system -ldl” g ++ $ cppflags application_main.cpp -o application_main $ ldflags g ++ $ cppflags application_di.cpp -o application_di $ ldflags ./application_main。 ./application_di。 use_sum ./application_di。 #使用dot_product
使用
compile_n_run.sh
:
+ ./cleanup.sh
removed 'application_main'
removed 'libdot_product.so'
removed 'libsum.so'
=> cleaned up!
+ echo '=> Compiling now...'
=> Compiling now...
+ CPPFLAGS='-std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/'
+ LDFLAGS=
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ sum.cpp -shared -o libsum.so
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ dot_product.cpp -shared -o libdot_product.so
+ LDFLAGS=' -lboost_filesystem -lboost_system -ldl'
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ application_main.cpp -o application_main -lboost_filesystem -lboost_system -ldl
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ application_di.cpp -o application_di -lboost_filesystem -lboost_system -ldl
+ ./application_main .
[sum_constructor]
[dot_product_constructor]
[sum_constructor]
[sum_constructor]
[dot_product_constructor]
Plugin Name: sum
calculate(1, 2): 3
Plugin Name: dot_product
calculate(1, 2): 5
[~dot_product_destructor]
[~sum_destructor]
[~sum_destructor]
[~dot_product_destructor]
[~sum_destructor]
+ ./application_di . use_sum
[sum_constructor]
name: sum
[~sum_destructor]
+ ./application_di .
[sum_constructor]
[dot_product_constructor]
name: dot_product
[~dot_product_destructor]
[~sum_destructor]
user.fromsnap
中的 snap
在其某些值上返回 null
。要解决此问题,您应该执行以下操作:
- 首先,您应该确保来自API/DB/的值不是
null
。 - 对于
null
为,将它们默认为下面的另一个值,例如 ??有条件表达式的操作员;
static User fromSnap(DocumentSnapshot snap) {
var snapshot = snap.data() as Map<String, dynamic>;
return User(
username: snapshot['username'] ?? 'Unknown',
uid: snapshot['uid'] ?? '0000000000',
email: snapshot['email'] ?? '',
photoUrl: snapshot['photoUrl'] ?? '',
bio: snapshot['bio'] ?? '',
followers: snapshot['followers'] ?? [],
following: snapshot['following'] ?? [],
);
}
当您在搜索中运行Profiler时,查询的总时间将比通常运行高得多,检查总时间的最佳方法是在没有profiler的情况下运行查询,并将时间与每个节点进行比较。
当我从RESTTEMPLATE更改为httpurlconnection时,它的工作
.container div
选择A div
class container 。
它没有针对HTML中的任何元素,因为 condure> container
类中没有 div
。
也许您的意思是,
.Container P
“我发现的主要麻烦是如何在两个不同时间之间标记时间,例如上午11点至5:59,而不是仅仅是晚上11点。”
添加一个列H2 = G2 + 1/24
然后,您的范围为0至7/24、7/24至19/24和19/24至24/24,因此您没有将时钟重置为零的间隔分开。
尝试增加请求的尺寸限制,
在您的项目中添加WebConfig并添加此代码
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<security>
<requestFiltering>
<!-- This will handle requests up to 50MB -->
<requestLimits maxAllowedContentLength="52428800" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
您可以尝试使用视图的 contextualtitle
属性。根据发布时的文档,它应该满足您的需求:
用于扩展作者,贡献视图或查看容器
当围绕工作台周围移动视图时,如果它们不在默认位置,则有时需要以图标或额外的上下文来不同。当贡献观点时,作者现在可以提供图标属性和上下文属性。如果未提供,这些将默认为构造其贡献的视图容器的图标和标题。
从那时起,我不确定他们是否更新了API或更新了行为,但是,如果没有,您可能会在尝试使用它时遇到的相同问题。我什至为VS代码团队打开了问题( https://githbithub.com/microsoft/microsoft/vscscode /eskoes/102447 ),但他们将问题标记为设计,我放弃了使用它。
希望这会有所帮助
在coc-settings中。
{
"prettier.singleQuote":true
}
您可以使用“ 线性”,而不是“ radialgradient ”
更换梯度属性,在您的boxdecoration内部:
LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.white.withOpacity(0.0),
const Color(0xFFFF7F37),
],
),
除了意图之外,别无其他。连接到LDS时,您可能期望在调用
FindServers
时,可能会为其他非LDS服务器提供多个条目,但是在连接到非LDDS服务器时只有一个条目。是的,它必须使用LDS的URL配置以注册,尽管LDS的最初意图是它在LocalHost上运行,并且具有
opc.tcp.tcp:// localhost:4840/的规范地址uadiscovery
带有规范的端点URLopc.tcp:// localhost:4840/uadiscovery/registration
用于服务器将使用的端点。我认为要做的正确的事情是为服务器提供注册地址,但实际上可能并不重要。
是的。在许多情况下,发现URL和端点URL是相同的,但是如果您获得的发现URL不同,则应使用它。
FindServers
应实现,registerserver
和registerserver2
不需要,不需要。实施LDS是一项非平凡的事业,由于规格中LDS的文献不足,因此更加困难,因为这是在现实世界中从未真正脱过来的东西。
除非您只是想了解这个OPC UA概念,否则我认为您可能会浪费时间。
Nothing other than perhaps intention. Connecting to an LDS you might expect to get multiple entries for other non-LDS servers when you call
FindServers
, but only one when connecting to a non-LDS server.Yes, it has to be configured with the URL of the LDS to register with, though the original intention for an LDS would be that it runs on localhost and has a canonical address of
opc.tcp://localhost:4840/UADiscovery
with a canonical endpoint URL ofopc.tcp://localhost:4840/UADiscovery/registration
for the endpoint that servers will use to register with.I think the correct thing to do would be provide the server with the registration address, but it may not matter in practice.
Yes. In many cases the discovery URL and endpoint URL are the same, but if you're given a discovery URL that is different then you should use it.
FindServers
should be implemented,RegisterServer
andRegisterServer2
are not required and should not be.Implementing an LDS is a non-trivial undertaking, made more difficult by the fact that LDS in general is under-documented in the spec because it's something that never really took off in the real world.
Unless you're just trying to learn about this OPC UA concept I think you may be wasting your time.
如何使用Eclipse Milo实施OPC UA LD?