signalr test
This commit is contained in:
1 parent
a87e5e5ff9
commit
d250bca681
16 files changed
+8779
-62
No files matched your search
@@ -5,6 +5,9 @@ using IoTClient.Clients.PLC;
|
||||
using IoTClient.Common.Enums;
|
||||
using IoTClient.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Query.Expressions.Internal;
|
||||
using NPOI.XSSF.Streaming.Values;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
|
||||
@@ -26,24 +29,30 @@ namespace HHWMS.Web.Controllers
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
SiemensClient client = new SiemensClient(SiemensVersion.S7_1500, "127.0.0.1", 102);
|
||||
client.Write("V2209", 33);
|
||||
|
||||
Dictionary<string, DataTypeEnum> addresses = new Dictionary<string, DataTypeEnum>();
|
||||
addresses.Add("DB4.24", DataTypeEnum.Float);
|
||||
addresses.Add("DB1.434.0", DataTypeEnum.Bool);
|
||||
addresses.Add("V4109", DataTypeEnum.Byte);
|
||||
var result = client.BatchRead(addresses);
|
||||
var tt = result.Value.First(x => x.Key.Equals("DB1.434.0")).Value;
|
||||
|
||||
var inv = _unitWork
|
||||
.Find<Inventory>(x => x.TaskStatus != InventoryTaskStatus.任务中)
|
||||
.ToList()
|
||||
.GroupBy(x => x.ContainerCode);
|
||||
var vm = Wtm.CreateVM<ContainerListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
#endregion Search
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Test()
|
||||
{
|
||||
SiemensClient client = new SiemensClient(SiemensVersion.S7_1500, "127.0.0.1", 102);
|
||||
|
||||
// 声明设备列表
|
||||
Dictionary<string, DataTypeEnum> addresses = new Dictionary<string, DataTypeEnum>();
|
||||
addresses.Add("V2207", DataTypeEnum.Float);
|
||||
addresses.Add("V2307", DataTypeEnum.Float);
|
||||
addresses.Add("V2407", DataTypeEnum.Float);
|
||||
var result = client.BatchRead(addresses);
|
||||
if(result.IsSucceed)
|
||||
{
|
||||
var re = result.Value.ToList();
|
||||
return JsonMore(re);
|
||||
}
|
||||
return JsonMore(null);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,106 @@
|
||||
<div id="app">
|
||||
<a-button @@click="handleClick">
|
||||
<template #icon>
|
||||
@* <template #icon>
|
||||
<icon-plus />
|
||||
</template>
|
||||
</template> *@
|
||||
{{ message }}
|
||||
</a-button>
|
||||
{{ result }}
|
||||
|
||||
<a-form :model="form" :style="{ width: '600px' }" @@submit="handleSubmit">
|
||||
<a-form-item field="name" tooltip="Please enter username" label="Username">
|
||||
<a-input v-model="form.name"
|
||||
placeholder="please enter your username..." />
|
||||
</a-form-item>
|
||||
<a-form-item field="post" label="Post">
|
||||
<a-input v-model="form.post" placeholder="please enter your post..." />
|
||||
</a-form-item>
|
||||
<a-form-item field="isRead">
|
||||
<a-checkbox v-model="form.isRead"> I have read the manual </a-checkbox>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button html-type="submit">Submit</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
{{ form }}
|
||||
<a-table :columns="columns" :data="datat" />
|
||||
</div>
|
||||
|
||||
<script src="/front/signalr.min.js"></script>
|
||||
<script>
|
||||
const { createApp } = Vue
|
||||
|
||||
createApp({
|
||||
const { createApp, reactive } = Vue
|
||||
|
||||
const app = createApp({
|
||||
data() {
|
||||
return {
|
||||
message: 'Hello Vue!',
|
||||
form: {
|
||||
name: '',
|
||||
post: '',
|
||||
isRead: false,
|
||||
}
|
||||
result: 'Hello Vue!',
|
||||
columns: [
|
||||
{
|
||||
title: '地址',
|
||||
dataIndex: 'Key',
|
||||
},
|
||||
{
|
||||
title: '值',
|
||||
dataIndex: 'Value',
|
||||
}
|
||||
],
|
||||
datat: reactive([])
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
console.log(1);
|
||||
this.$message.info('This is an info message')
|
||||
var _this = this;
|
||||
axios.post("/configs/Print/Test", {})
|
||||
.then(function (json) {
|
||||
_this.result = json.data.Data;
|
||||
_this.datat = [];
|
||||
_this.result.forEach((item) => {
|
||||
_this.datat.push(item);
|
||||
})
|
||||
|
||||
// _this.datat.forEach((item,index) => {
|
||||
// if (item.Key == "DB4.24") {
|
||||
// _this.datat[index].Value = "3";
|
||||
// }
|
||||
// })
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
handleSubmit(data) {
|
||||
handleSubmit(data) {
|
||||
console.log(data);
|
||||
this.$message.info('This is an info message')
|
||||
}
|
||||
}
|
||||
})
|
||||
.use(ArcoVue)
|
||||
.use(ArcoVueIcon)
|
||||
.mount('#app')
|
||||
});
|
||||
app
|
||||
.use(ArcoVue)
|
||||
.use(ArcoVueIcon)
|
||||
.mount('#app');
|
||||
|
||||
console.log(app._instance.data);
|
||||
|
||||
let connection = new signalR.HubConnectionBuilder()
|
||||
.withAutomaticReconnect()
|
||||
.withUrl("/stocks")
|
||||
.build();
|
||||
connection.start().then(function () {
|
||||
connection.invoke("GetAllStocks").then(function (stocks) {
|
||||
for (let i = 0; i < stocks.length; i++) {
|
||||
app._instance.data.datat.push({ Key: stocks[i].dbName, Value: stocks[i].dbValue });
|
||||
}
|
||||
});
|
||||
|
||||
connection.invoke("GetMarketState").then(function (state) {
|
||||
console.log(state);
|
||||
// if (state === 'Open') {
|
||||
startStreaming();
|
||||
// }
|
||||
});
|
||||
|
||||
connection.invoke("OpenMarket");
|
||||
});
|
||||
|
||||
function startStreaming() {
|
||||
connection.stream("StreamStocks").subscribe({
|
||||
close: false,
|
||||
next: displayStock,
|
||||
error: function (err) {
|
||||
logger.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function displayStock(stock) {
|
||||
app._instance.data.datat.forEach((item,index) => {
|
||||
if (item.Key == stock.dbName) {
|
||||
app._instance.data.datat[index].Value = stock.dbValue;
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user