This commit is contained in:
CortexCore 2023-06-13 14:43:03 +08:00
parent 983cf15fa2
commit eaa5650823
5 changed files with 99 additions and 44 deletions

View File

@ -1,14 +1,13 @@
[gd_scene load_steps=25 format=3 uid="uid://vlopmythikrl"]
[gd_scene load_steps=24 format=3 uid="uid://vlopmythikrl"]
[ext_resource type="Environment" uid="uid://jt4uyj7mecg4" path="res://Maps/new_environment.tres" id="1_4lshp"]
[ext_resource type="PackedScene" uid="uid://b2kkx25rbmq5q" path="res://Services/Framework.tscn" id="1_wdha4"]
[ext_resource type="PackedScene" uid="uid://df10ceig3k8xr" path="res://Models/BaseGround.dae" id="2_ih8qi"]
[ext_resource type="Script" path="res://Scripts/Camera/CameraService.cs" id="3_l7a6m"]
[ext_resource type="Script" path="res://Scripts/Factory/DeviceComponent.cs" id="5_55cao"]
[ext_resource type="Script" path="res://Scripts/Factory/IdComponent.cs" id="5_55cao"]
[ext_resource type="Script" path="res://Scripts/ECS/Entity.cs" id="5_e331s"]
[ext_resource type="Script" path="res://Scripts/Factory/RotationComponent.cs" id="8_605k2"]
[ext_resource type="Script" path="res://Scripts/Camera/VirtualCamera.cs" id="9_dg2nh"]
[ext_resource type="Script" path="res://Scripts/Core/ReferenceNode.cs" id="10_bymi1"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nhcin"]
resource_name = "Material_White"
@ -247,11 +246,10 @@ script = ExtResource("3_l7a6m")
[node name="BaseGround" parent="." instance=ExtResource("2_ih8qi")]
[node name="Assembly Unit" type="Node3D" parent="." node_paths=PackedStringArray("root")]
[node name="Assembly Unit" type="Node3D" parent="."]
script = ExtResource("5_e331s")
root = NodePath(".")
[node name="DeviceComponent" type="Node3D" parent="Assembly Unit"]
[node name="IdCompoment" type="Node3D" parent="Assembly Unit"]
script = ExtResource("5_55cao")
Id = "PLC-ZK"
@ -290,8 +288,8 @@ skeleton = NodePath("")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000885574, 0.436716, -0.071)
script = ExtResource("8_605k2")
Path = "ZP-A3"
Weight = Vector3(0, 0, 1)
Offset = Vector3(0, 0, -90)
Weight = Vector3(0, 0, -1)
Offset = Vector3(0, 0, 90)
[node name="Mesh022" type="MeshInstance3D" parent="Assembly Unit/Models/Model_SR7CL11/SR7CL11_Root/SR7CL11_Axis_1/SR7CL11_Axis_2/SR7CL11_Axis_3"]
mesh = SubResource("ArrayMesh_1q61h")
@ -303,12 +301,12 @@ Path = "ZP-A4"
Weight = Vector3(0, 1, 0)
[node name="Mesh013" type="MeshInstance3D" parent="Assembly Unit/Models/Model_SR7CL11/SR7CL11_Root/SR7CL11_Axis_1/SR7CL11_Axis_2/SR7CL11_Axis_3/SR7CL11_Axis_4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000555572, 0.331249, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0348583, 0.434378, 0)
mesh = SubResource("ArrayMesh_mve4j")
skeleton = NodePath("")
[node name="SR7CL11_Axis_5" type="Node3D" parent="Assembly Unit/Models/Model_SR7CL11/SR7CL11_Root/SR7CL11_Axis_1/SR7CL11_Axis_2/SR7CL11_Axis_3/SR7CL11_Axis_4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000555571, 0.331249, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0373534, 0.437793, 0)
script = ExtResource("8_605k2")
Path = "ZP-A5"
Weight = Vector3(0, 0, 1)
@ -331,8 +329,4 @@ script = ExtResource("9_dg2nh")
fov = 75
isEnabled = true
[node name="Refencer" type="Node" parent="." node_paths=PackedStringArray("Proxy")]
script = ExtResource("10_bymi1")
Proxy = NodePath(".")
[editable path="Framework"]

View File

@ -1,4 +1,73 @@
# iFactory.Godot
基于Godot的iFactory客户端
正在从Unity一步一步移植到Godot中
![](https://img.shields.io/badge/Dev-0.32-green)
基于Godot的iFactory客户端(网络服务和服务端已定义接口,预计使用[KCP](https://github.com/skywind3000/kcp)实现)
正在从Unity版[内网链接](http://192.168.1.50:3000/cn-intelli/iFactory.git)一步一步移植到Godot中
该项目主要使用[ECS](https://zhuanlan.zhihu.com/p/30538626)架构,[BITKit](http://server.bitfall.icu:3000/root/BITKit.git)作为基本的dotnet框架
## Installation 安装过程
1.首先你需要安装 **Godot4.0.3 Net** 👉[GodotEngine.Net](https://godotengine.org/download/windows/)
2.通过Git Clone两个仓库到与该仓库相同路径的文件夹,文件结构看起来像这样:
> GitHub (你的项目文件夹的上一级)
> >iFactory.Godot [外网仓库链接](http://server.bitfall.icu:3000/root/iFactory.Godot.git)
>
> >BITKit [外网仓库链接](http://server.bitfall.icu:3000/root/BITKit.git)
>
> >AGV_System [内网仓库链接](http://192.168.1.50:3000/cn-intelli/AGV_System.git)
3.最后在**Godot**中导入**iFactory.Godot**
4.⭐ 安装完成
## Features 功能与模块
### 功能介绍
#### 机位同步
* 超炫酷`零延迟`机位同步(可能需要一些硬件支持)
* 基于角度的`Loopback`算法,解决了同步角度和位置时0>1>0的值被线性插值解析为0>0.7414>0的问题
* 基于物理`PBR`的三维模型,确保和现实中的设备看起来几乎一致
* 基于`Lancer.SCADA`返回数据的物料同步(例如`SR7C1L`夹着物料`多功能笔记本`放进`交付气缸夹`)
#### 数据回放
* 录制生产时的数据,可离线播放生产过程
* 支持数据追溯,收集和录制重要数据,可对数据进行加工、提炼和分析,找到可能存在的重要数据
#### 布局规划
* 拖放`模型库`/`预制件`到场景中,快速完成场景的基础规划
* 选中`实体`并编辑数值或节点,可快速定制`模型`,例如
* 自定义围墙,围栏,输送带的尺寸,如 长`4096mm`,宽`256mm`
* 编辑贝塞尔曲线,标记`AGV`或其他可运动设备的`路线`
* 快速替换预览设备的型号,例如将`KUKA.AGV`替换为`Intelli.AGV`
#### 多终端实时同步场景
* `PC客户端`进行布局规划,`Mixed Reality`客户端(例如`AR`)可直接在现场看到设备规划的位置和生产路线
* 虚拟化生产过程,用户可通过`手机AR`或者`AR眼睛`在现场预览生产过程并对过程进行评估
* `AGV`夹起`物料`放入`装配单元`
* `AGV`向`装配单元`提供`物料`
* `装配单元`进行虚拟化装配
* `AGV`从`装配单元`取走产品,并放入`交付单元`
* `所有客户端`可对现实坐标进行标记(`文字消息` `图像消息`)
* 标记需要改进的工序或移动的位置
* 标记用户希望的生产路线
#### 智能诊断
* 基于`Lancer.SCADA`提供的数据,自动分析重要数据的值并返回异常和诊断数据
* 可通过`WebAPI`接口下发异常
* 与`微信`紧密绑定
### 功能清单
- [x] 基于`Lancer.SCADA`的基本数据请求服务`WebApi/GetInfos`——请求json,处理json嵌套,向内部提交数据
- [x] 基于`Lancer.SCADA`基本的角度和位置同步
- [ ] 基于`AI`算法的零延迟同步
- [ ] 基于`硬件本身的api`提供的零延迟同步
- [ ] 全平台通用网络通讯接口(基于KCP的基本网络服务)`NetProvider` `NetClient` `NetServer`
- [ ] 基于`Camera3D`的虚拟相机服务`观察场景` 例如`移动视角` `拖动视角` `缩放视角` `保存与加载预设视角`
- [ ] `Android`支持
- [ ] `WebGL` 支持
- [ ] 回放录制器——录制`Lancer.SCADA`返回的数据,
- [ ] 场景编辑器——拖动预制件到场景中,完成组合场景,可用于对现场规划进行三维浏览和布局评估
- [ ] 网络场景——多个平台和客户端同步场景例如在PC上更改场景在`Mixed Reality`中可实时看到场景的更改
- [ ] 自诊断服务——通过解析数据,找到`空值`或`null`的数据并向指定接口(例如`微信推送` `数据库日志`)提交异常
## Getting Started 使用指南

View File

@ -11,14 +11,7 @@ namespace BITKit;
/// </summary>
public partial class BITAppForGodot : Node
{
/// <summary>
/// 依赖服务集合
/// </summary>
public static ServiceCollection ServiceCollection { get; private set; } = new();
/// <summary>
/// 依赖服务提供接口
/// </summary>
public static ServiceProvider ServiceProvider { get; private set; }
/// <summary>
/// 在构造函数中注册Logger
/// </summary>
@ -34,16 +27,15 @@ public partial class BITAppForGodot : Node
BIT4Log.Log<BITAppForGodot>("已创建BITApp");
}
public override async void _Ready()
public override void _Ready()
{
BIT4Log.Log<BITAppForGodot>("正在创建BITWebApp");
//添加测试用HttpClient
ServiceCollection.AddSingleton<HttpClient>();
BITApp.ServiceCollection.AddSingleton<HttpClient>();
//构造依赖服务提供接口
ServiceProvider = ServiceCollection.BuildServiceProvider();
BITApp.BuildService();
}
protected override void Dispose(bool disposing)
{

View File

@ -15,7 +15,7 @@ public class IntervalTimer
/// <summary>
/// 在构造函数中声明间隔时间
/// </summary>
/// <param name="interval"></param>
/// <param name="interval">间隔(秒)</param>
public IntervalTimer(ulong interval)
{
this.interval = interval;

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using BITKit.Core.Entites;
using BITKit.Packages.Core.LazyLoad;
using Cysharp.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
@ -20,7 +21,7 @@ public partial class SCADAService : Node
/// </summary>
public SCADAService()
{
BITAppForGodot.ServiceCollection.AddSingleton(this);
BITApp.ServiceCollection.AddSingleton(this);
}
/// <summary>
/// 获取json的Url
@ -39,7 +40,7 @@ public partial class SCADAService : Node
/// <summary>
/// 最大并行请求数量
/// </summary>
private readonly LimitTimes requestRate =new (1);
private readonly LimitTimes limitConcurrent =new (1);
/// <summary>
/// 请求数据的间隔
/// </summary>
@ -51,7 +52,7 @@ public partial class SCADAService : Node
/// <summary>
/// http客户端
/// </summary>
private System.Net.Http.HttpClient httpClient;
private readonly ServiceLoader<System.Net.Http.HttpClient> httpClient=new();
/// <summary>
/// 获取Entity并加载依赖
/// </summary>
@ -62,7 +63,6 @@ public partial class SCADAService : Node
await UniTask.Yield();
LoadAllEntities();
BIT4Log.Log<SCADAService>($"已加载{_entities.Count}个设备");
httpClient = BITAppForGodot.ServiceProvider.GetService<System.Net.Http.HttpClient>();
}
/// <summary>
/// 内部方法从EntityService加载所有Entity
@ -83,14 +83,14 @@ public partial class SCADAService : Node
/// <param name="delta"></param>
public override void _PhysicsProcess(double delta)
{
//依赖加载
httpClient ??= BITAppForGodot.ServiceProvider.GetService<System.Net.Http.HttpClient>();
//请求间隔控制+请求并发控制+检查依赖是否为Null
if (_intervalTimer.Allow && requestRate && httpClient is not null)
{
//发送请求
Request();
}
//等待依赖加载
//请求间隔控制+请求并发控制
if (_intervalTimer.Allow is false || httpClient.IsLoaded is false) return;
if (!limitConcurrent.AllowOnly) return;
//提交并发
limitConcurrent.CanUpdate();
//发送请求
Request();
}
/// <summary>
/// 从http请求json
@ -98,7 +98,7 @@ public partial class SCADAService : Node
private async void Request()
{
//获取json
var json =await httpClient.GetStringAsync(url, _cancellationToken);
var json =await httpClient.Value.GetStringAsync(url, _cancellationToken);
try
{
//取消执行,如果已取消令牌
@ -107,11 +107,11 @@ public partial class SCADAService : Node
catch (OperationCanceledException)
{
//返回并发数量
requestRate.Release();
limitConcurrent.Release();
return;
}
//返回并发数量
requestRate.Release();
limitConcurrent.Release();
//处理json
ProcessJson(json);
}