add websocket fake server
This commit is contained in:
		
							
								
								
									
										458
									
								
								websocket/d.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										458
									
								
								websocket/d.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,458 @@
 | 
			
		||||
推送火向,剩余换火时间,压力,换火时间等信息
 | 
			
		||||
 | 
			
		||||
目前缺少四个温度
 | 
			
		||||
循环水温
 | 
			
		||||
 | 
			
		||||
熔化温度
 | 
			
		||||
 | 
			
		||||
碹顶温度
 | 
			
		||||
 | 
			
		||||
支通路温度
 | 
			
		||||
{
 | 
			
		||||
  "data": {
 | 
			
		||||
    "waterFlow": "99.0m³/h",
 | 
			
		||||
    "fireChangeTime": "46.0S",
 | 
			
		||||
    "compressedAirPressure": "95.0MPa",
 | 
			
		||||
    "combustionAirPressure": "73.0Pa",
 | 
			
		||||
    "waterPressure": "29.0MPa",
 | 
			
		||||
    "lastFireChangeTime": "10分20秒",
 | 
			
		||||
    "combustionAirPressureArr": [
 | 
			
		||||
      "1.0m³/h",
 | 
			
		||||
      "16.0m³/h",
 | 
			
		||||
      "23.0m³/h",
 | 
			
		||||
      "65.0m³/h",
 | 
			
		||||
      "70.0m³/h",
 | 
			
		||||
      "78.0m³/h",
 | 
			
		||||
      "9.0m³/h",
 | 
			
		||||
      "94.0m³/h"
 | 
			
		||||
    ],
 | 
			
		||||
    "kilnPressure": "99.0Pa",
 | 
			
		||||
    "fireDirection": "东火"
 | 
			
		||||
  },
 | 
			
		||||
  "type": "RunData"
 | 
			
		||||
}左右投料机信息{"rightFeeder":"运行","leftFeeder":"运行"}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
天然气流量历史趋势
 | 
			
		||||
{
 | 
			
		||||
  "kilnGasT1": {
 | 
			
		||||
    "FE111R": [
 | 
			
		||||
      53.02,
 | 
			
		||||
      69.84,
 | 
			
		||||
      99.33,
 | 
			
		||||
      17.21,
 | 
			
		||||
      1.17,
 | 
			
		||||
      27.84,
 | 
			
		||||
      95.44,
 | 
			
		||||
      30.72,
 | 
			
		||||
      32.24,
 | 
			
		||||
      64.16,
 | 
			
		||||
      59.65,
 | 
			
		||||
      14.59,
 | 
			
		||||
      78.58,
 | 
			
		||||
      99.15,
 | 
			
		||||
      58.91,
 | 
			
		||||
      34.13,
 | 
			
		||||
      99.62,
 | 
			
		||||
      2.23,
 | 
			
		||||
      28.31,
 | 
			
		||||
      91.17,
 | 
			
		||||
      97.15,
 | 
			
		||||
      60.62,
 | 
			
		||||
      94.12,
 | 
			
		||||
      23.24
 | 
			
		||||
    ],
 | 
			
		||||
    "FE113R": [
 | 
			
		||||
      22.04,
 | 
			
		||||
      40.78,
 | 
			
		||||
      75.62,
 | 
			
		||||
      61.01,
 | 
			
		||||
      72.7,
 | 
			
		||||
      48.46,
 | 
			
		||||
      32.44,
 | 
			
		||||
      42.51,
 | 
			
		||||
      59.61,
 | 
			
		||||
      22.86,
 | 
			
		||||
      32.95,
 | 
			
		||||
      21.32,
 | 
			
		||||
      23.59,
 | 
			
		||||
      84.16,
 | 
			
		||||
      55.14,
 | 
			
		||||
      55.71,
 | 
			
		||||
      10.81,
 | 
			
		||||
      56.53,
 | 
			
		||||
      75.51,
 | 
			
		||||
      2.85,
 | 
			
		||||
      27.77,
 | 
			
		||||
      52.42,
 | 
			
		||||
      43.34,
 | 
			
		||||
      22.04
 | 
			
		||||
    ],
 | 
			
		||||
    "FE112R": [
 | 
			
		||||
      77.02,
 | 
			
		||||
      13.83,
 | 
			
		||||
      1.71,
 | 
			
		||||
      53.99,
 | 
			
		||||
      4.03,
 | 
			
		||||
      1,
 | 
			
		||||
      22.17,
 | 
			
		||||
      61.73,
 | 
			
		||||
      11.25,
 | 
			
		||||
      31.69,
 | 
			
		||||
      90.31,
 | 
			
		||||
      69.26,
 | 
			
		||||
      68.72,
 | 
			
		||||
      80.79,
 | 
			
		||||
      3.08,
 | 
			
		||||
      39.17,
 | 
			
		||||
      12.6,
 | 
			
		||||
      35.31,
 | 
			
		||||
      97.2,
 | 
			
		||||
      38.77,
 | 
			
		||||
      27.5,
 | 
			
		||||
      11.78,
 | 
			
		||||
      72.32,
 | 
			
		||||
      23.13
 | 
			
		||||
    ],
 | 
			
		||||
    "FE115R": [
 | 
			
		||||
      28.31,
 | 
			
		||||
      10.16,
 | 
			
		||||
      13.22,
 | 
			
		||||
      41.44,
 | 
			
		||||
      97.19,
 | 
			
		||||
      60.08,
 | 
			
		||||
      34.13,
 | 
			
		||||
      16.75,
 | 
			
		||||
      92.7,
 | 
			
		||||
      79.48,
 | 
			
		||||
      3.08,
 | 
			
		||||
      14.71,
 | 
			
		||||
      4.4,
 | 
			
		||||
      0.88,
 | 
			
		||||
      77.6,
 | 
			
		||||
      57,
 | 
			
		||||
      31,
 | 
			
		||||
      86.14,
 | 
			
		||||
      44.31,
 | 
			
		||||
      45.7,
 | 
			
		||||
      6.85,
 | 
			
		||||
      65.62,
 | 
			
		||||
      77.97,
 | 
			
		||||
      49.2
 | 
			
		||||
    ],
 | 
			
		||||
    "FE114R": [
 | 
			
		||||
      17.72,
 | 
			
		||||
      32.45,
 | 
			
		||||
      1.42,
 | 
			
		||||
      24.51,
 | 
			
		||||
      68.57,
 | 
			
		||||
      61.48,
 | 
			
		||||
      2.08,
 | 
			
		||||
      3.1,
 | 
			
		||||
      38.27,
 | 
			
		||||
      20.07,
 | 
			
		||||
      25.71,
 | 
			
		||||
      85.58,
 | 
			
		||||
      48.31,
 | 
			
		||||
      78.14,
 | 
			
		||||
      22.43,
 | 
			
		||||
      87.47,
 | 
			
		||||
      83.78,
 | 
			
		||||
      17.66,
 | 
			
		||||
      72.36,
 | 
			
		||||
      19,
 | 
			
		||||
      20.69,
 | 
			
		||||
      33.92,
 | 
			
		||||
      25.66,
 | 
			
		||||
      91.28
 | 
			
		||||
    ],
 | 
			
		||||
    "FE117R": [
 | 
			
		||||
      47.8,
 | 
			
		||||
      62.27,
 | 
			
		||||
      90.23,
 | 
			
		||||
      28.31,
 | 
			
		||||
      73.09,
 | 
			
		||||
      34.04,
 | 
			
		||||
      9.03,
 | 
			
		||||
      44.69,
 | 
			
		||||
      32.62,
 | 
			
		||||
      25.78,
 | 
			
		||||
      27.79,
 | 
			
		||||
      25.42,
 | 
			
		||||
      28.96,
 | 
			
		||||
      56.52,
 | 
			
		||||
      75.43,
 | 
			
		||||
      50.56,
 | 
			
		||||
      90.22,
 | 
			
		||||
      11.85,
 | 
			
		||||
      4.56,
 | 
			
		||||
      39.9,
 | 
			
		||||
      9.83,
 | 
			
		||||
      65.98,
 | 
			
		||||
      91.22,
 | 
			
		||||
      92.43
 | 
			
		||||
    ],
 | 
			
		||||
    "FE116R": [
 | 
			
		||||
      64.79,
 | 
			
		||||
      46.14,
 | 
			
		||||
      58.67,
 | 
			
		||||
      54.46,
 | 
			
		||||
      15.67,
 | 
			
		||||
      72.02,
 | 
			
		||||
      15.06,
 | 
			
		||||
      5.88,
 | 
			
		||||
      38.19,
 | 
			
		||||
      66.98,
 | 
			
		||||
      89.24,
 | 
			
		||||
      33.13,
 | 
			
		||||
      87.57,
 | 
			
		||||
      43.95,
 | 
			
		||||
      55.06,
 | 
			
		||||
      93.26,
 | 
			
		||||
      96.91,
 | 
			
		||||
      56.5,
 | 
			
		||||
      20.75,
 | 
			
		||||
      83.76,
 | 
			
		||||
      60.88,
 | 
			
		||||
      62.04,
 | 
			
		||||
      22.34,
 | 
			
		||||
      82.43
 | 
			
		||||
    ],
 | 
			
		||||
    "FE118R": [
 | 
			
		||||
      94.32,
 | 
			
		||||
      86.26,
 | 
			
		||||
      5.13,
 | 
			
		||||
      47.33,
 | 
			
		||||
      40.01,
 | 
			
		||||
      34.97,
 | 
			
		||||
      18.69,
 | 
			
		||||
      81.81,
 | 
			
		||||
      87.37,
 | 
			
		||||
      96.47,
 | 
			
		||||
      16.04,
 | 
			
		||||
      23.33,
 | 
			
		||||
      0.66,
 | 
			
		||||
      16.86,
 | 
			
		||||
      13.19,
 | 
			
		||||
      67.32,
 | 
			
		||||
      37.63,
 | 
			
		||||
      13.74,
 | 
			
		||||
      22.85,
 | 
			
		||||
      78.89,
 | 
			
		||||
      9.52,
 | 
			
		||||
      75.46,
 | 
			
		||||
      0.2,
 | 
			
		||||
      1.51
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  "kilnGasT2": {
 | 
			
		||||
    "FE124R": [
 | 
			
		||||
      53.02,
 | 
			
		||||
      69.84,
 | 
			
		||||
      99.33,
 | 
			
		||||
      17.21,
 | 
			
		||||
      1.17,
 | 
			
		||||
      27.84,
 | 
			
		||||
      95.44,
 | 
			
		||||
      30.72,
 | 
			
		||||
      32.24,
 | 
			
		||||
      64.16,
 | 
			
		||||
      59.65,
 | 
			
		||||
      14.59,
 | 
			
		||||
      78.58,
 | 
			
		||||
      99.15,
 | 
			
		||||
      58.91,
 | 
			
		||||
      34.13,
 | 
			
		||||
      99.62,
 | 
			
		||||
      2.23,
 | 
			
		||||
      28.31,
 | 
			
		||||
      91.17,
 | 
			
		||||
      97.15,
 | 
			
		||||
      60.62,
 | 
			
		||||
      94.12,
 | 
			
		||||
      23.24
 | 
			
		||||
    ],
 | 
			
		||||
    "FE123aR": [
 | 
			
		||||
      17.72,
 | 
			
		||||
      32.45,
 | 
			
		||||
      1.42,
 | 
			
		||||
      24.51,
 | 
			
		||||
      68.57,
 | 
			
		||||
      61.48,
 | 
			
		||||
      2.08,
 | 
			
		||||
      3.1,
 | 
			
		||||
      38.27,
 | 
			
		||||
      20.07,
 | 
			
		||||
      25.71,
 | 
			
		||||
      85.58,
 | 
			
		||||
      48.31,
 | 
			
		||||
      78.14,
 | 
			
		||||
      22.43,
 | 
			
		||||
      87.47,
 | 
			
		||||
      83.78,
 | 
			
		||||
      17.66,
 | 
			
		||||
      72.36,
 | 
			
		||||
      19,
 | 
			
		||||
      20.69,
 | 
			
		||||
      33.92,
 | 
			
		||||
      25.66,
 | 
			
		||||
      91.28
 | 
			
		||||
    ],
 | 
			
		||||
    "FE123R": [
 | 
			
		||||
      77.02,
 | 
			
		||||
      13.83,
 | 
			
		||||
      1.71,
 | 
			
		||||
      53.99,
 | 
			
		||||
      4.03,
 | 
			
		||||
      1,
 | 
			
		||||
      22.17,
 | 
			
		||||
      61.73,
 | 
			
		||||
      11.25,
 | 
			
		||||
      31.69,
 | 
			
		||||
      90.31,
 | 
			
		||||
      69.26,
 | 
			
		||||
      68.72,
 | 
			
		||||
      80.79,
 | 
			
		||||
      3.08,
 | 
			
		||||
      39.17,
 | 
			
		||||
      12.6,
 | 
			
		||||
      35.31,
 | 
			
		||||
      97.2,
 | 
			
		||||
      38.77,
 | 
			
		||||
      27.5,
 | 
			
		||||
      11.78,
 | 
			
		||||
      72.32,
 | 
			
		||||
      23.13
 | 
			
		||||
    ],
 | 
			
		||||
    "FE124aR": [
 | 
			
		||||
      22.04,
 | 
			
		||||
      40.78,
 | 
			
		||||
      75.62,
 | 
			
		||||
      61.01,
 | 
			
		||||
      72.7,
 | 
			
		||||
      48.46,
 | 
			
		||||
      32.44,
 | 
			
		||||
      42.51,
 | 
			
		||||
      59.61,
 | 
			
		||||
      22.86,
 | 
			
		||||
      32.95,
 | 
			
		||||
      21.32,
 | 
			
		||||
      23.59,
 | 
			
		||||
      84.16,
 | 
			
		||||
      55.14,
 | 
			
		||||
      55.71,
 | 
			
		||||
      10.81,
 | 
			
		||||
      56.53,
 | 
			
		||||
      75.51,
 | 
			
		||||
      2.85,
 | 
			
		||||
      27.77,
 | 
			
		||||
      52.42,
 | 
			
		||||
      43.34,
 | 
			
		||||
      22.04
 | 
			
		||||
    ],
 | 
			
		||||
    "FE126R": [
 | 
			
		||||
      64.79,
 | 
			
		||||
      46.14,
 | 
			
		||||
      58.67,
 | 
			
		||||
      54.46,
 | 
			
		||||
      15.67,
 | 
			
		||||
      72.02,
 | 
			
		||||
      15.06,
 | 
			
		||||
      5.88,
 | 
			
		||||
      38.19,
 | 
			
		||||
      66.98,
 | 
			
		||||
      89.24,
 | 
			
		||||
      33.13,
 | 
			
		||||
      87.57,
 | 
			
		||||
      43.95,
 | 
			
		||||
      55.06,
 | 
			
		||||
      93.26,
 | 
			
		||||
      96.91,
 | 
			
		||||
      56.5,
 | 
			
		||||
      20.75,
 | 
			
		||||
      83.76,
 | 
			
		||||
      60.88,
 | 
			
		||||
      62.04,
 | 
			
		||||
      22.34,
 | 
			
		||||
      82.43
 | 
			
		||||
    ],
 | 
			
		||||
    "FE125aR": [
 | 
			
		||||
      47.8,
 | 
			
		||||
      62.27,
 | 
			
		||||
      90.23,
 | 
			
		||||
      28.31,
 | 
			
		||||
      73.09,
 | 
			
		||||
      34.04,
 | 
			
		||||
      9.03,
 | 
			
		||||
      44.69,
 | 
			
		||||
      32.62,
 | 
			
		||||
      25.78,
 | 
			
		||||
      27.79,
 | 
			
		||||
      25.42,
 | 
			
		||||
      28.96,
 | 
			
		||||
      56.52,
 | 
			
		||||
      75.43,
 | 
			
		||||
      50.56,
 | 
			
		||||
      90.22,
 | 
			
		||||
      11.85,
 | 
			
		||||
      4.56,
 | 
			
		||||
      39.9,
 | 
			
		||||
      9.83,
 | 
			
		||||
      65.98,
 | 
			
		||||
      91.22,
 | 
			
		||||
      92.43
 | 
			
		||||
    ],
 | 
			
		||||
    "FE125R": [
 | 
			
		||||
      28.31,
 | 
			
		||||
      10.16,
 | 
			
		||||
      13.22,
 | 
			
		||||
      41.44,
 | 
			
		||||
      97.19,
 | 
			
		||||
      60.08,
 | 
			
		||||
      34.13,
 | 
			
		||||
      16.75,
 | 
			
		||||
      92.7,
 | 
			
		||||
      79.48,
 | 
			
		||||
      3.08,
 | 
			
		||||
      14.71,
 | 
			
		||||
      4.4,
 | 
			
		||||
      0.88,
 | 
			
		||||
      77.6,
 | 
			
		||||
      57,
 | 
			
		||||
      31,
 | 
			
		||||
      86.14,
 | 
			
		||||
      44.31,
 | 
			
		||||
      45.7,
 | 
			
		||||
      6.85,
 | 
			
		||||
      65.62,
 | 
			
		||||
      77.97,
 | 
			
		||||
      49.2
 | 
			
		||||
    ],
 | 
			
		||||
    "FE126aR": [
 | 
			
		||||
      94.32,
 | 
			
		||||
      86.26,
 | 
			
		||||
      5.13,
 | 
			
		||||
      47.33,
 | 
			
		||||
      40.01,
 | 
			
		||||
      34.97,
 | 
			
		||||
      18.69,
 | 
			
		||||
      81.81,
 | 
			
		||||
      87.37,
 | 
			
		||||
      96.47,
 | 
			
		||||
      16.04,
 | 
			
		||||
      23.33,
 | 
			
		||||
      0.66,
 | 
			
		||||
      16.86,
 | 
			
		||||
      13.19,
 | 
			
		||||
      67.32,
 | 
			
		||||
      37.63,
 | 
			
		||||
      13.74,
 | 
			
		||||
      22.85,
 | 
			
		||||
      78.89,
 | 
			
		||||
      9.52,
 | 
			
		||||
      75.46,
 | 
			
		||||
      0.2,
 | 
			
		||||
      1.51
 | 
			
		||||
    ]
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										112
									
								
								websocket/response-example.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								websocket/response-example.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,112 @@
 | 
			
		||||
[
 | 
			
		||||
	/** 窑炉信息下的8个字段 **/
 | 
			
		||||
	{
 | 
			
		||||
		"type": "kiln-info",
 | 
			
		||||
		"data": {
 | 
			
		||||
			/** 窑炉压力 **/
 | 
			
		||||
			"kilnPressure": "***Kpa",
 | 
			
		||||
			/** 循环水温度 **/
 | 
			
		||||
			"waterLoopTemperature": "...℃",
 | 
			
		||||
			/** 循环水流量 **/
 | 
			
		||||
			"waterLoopFlow": "+++m³/h",
 | 
			
		||||
			/** 循环水压力 **/
 | 
			
		||||
			"waterLoopPressure": "***Kpa",
 | 
			
		||||
			/** 助燃风压力 **/
 | 
			
		||||
			"windPressure": "***Kpa",
 | 
			
		||||
			/** 压缩气压力 **/
 | 
			
		||||
			"gasPressure": "***Kpa",
 | 
			
		||||
			/** 碹顶加权温度 **/
 | 
			
		||||
			"topTemperature": "...℃",
 | 
			
		||||
			/** 融化加权温度 **/
 | 
			
		||||
			"meltTemperature": "...℃"
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/** 运行状态数据 **/
 | 
			
		||||
	{
 | 
			
		||||
		"type": "run-state",
 | 
			
		||||
		"data": {
 | 
			
		||||
			/** 剩余时间 **/
 | 
			
		||||
			"lastFireChangeTime": "3分28秒",
 | 
			
		||||
			/** 换火时间 **/
 | 
			
		||||
			"fireChangeTime": "20:00",
 | 
			
		||||
			/** 当前火向 **/
 | 
			
		||||
			"fireDirection": "东火"
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/** 能源数据 **/
 | 
			
		||||
	{
 | 
			
		||||
		"type": "energy-cost",
 | 
			
		||||
		"data": {
 | 
			
		||||
			/** 余热发电 **/
 | 
			
		||||
			"restHeat": "***kWh",
 | 
			
		||||
			/** 水耗量 **/
 | 
			
		||||
			"water": "+++Km³",
 | 
			
		||||
			/** 电耗量 **/
 | 
			
		||||
			"electricity": "+++kWh",
 | 
			
		||||
			/** 天然气I **/
 | 
			
		||||
			"gasi": "...m³",
 | 
			
		||||
			/** 天然气II **/
 | 
			
		||||
			"gasii": "...m³"
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/** 实时数据 gasii 代表天然气流量实时数据, wind 代表助燃风实时数据 **/
 | 
			
		||||
	{
 | 
			
		||||
		"type": "realtime",
 | 
			
		||||
		"data": {
 | 
			
		||||
			/** 天然气 **/
 | 
			
		||||
			"gasii": [
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h"
 | 
			
		||||
			],
 | 
			
		||||
			/** 助燃风 **/
 | 
			
		||||
			"wind": [
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h",
 | 
			
		||||
				"...m³/h"
 | 
			
		||||
			]
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/** 历史趋势数据 gas 代表天然气流量历史趋势数据, wind 代表助燃风历史趋势数据 **/
 | 
			
		||||
	{
 | 
			
		||||
		"type": "his-trend",
 | 
			
		||||
		"data": {
 | 
			
		||||
			/** 天然气 **/
 | 
			
		||||
			"gas": {
 | 
			
		||||
				"FE111R": [],
 | 
			
		||||
				"FE113R": [],
 | 
			
		||||
				"FE112R": [],
 | 
			
		||||
				"FE115R": [],
 | 
			
		||||
				"FE116R": [],
 | 
			
		||||
				"FE117R": [],
 | 
			
		||||
				"FE114R": [],
 | 
			
		||||
				"FE118R": []
 | 
			
		||||
			},
 | 
			
		||||
			/** 助燃风 **/
 | 
			
		||||
			"wind": {
 | 
			
		||||
				"FE124R": [],
 | 
			
		||||
				"FE124aR": [],
 | 
			
		||||
				"FE123R": [],
 | 
			
		||||
				"FE123aR": [],
 | 
			
		||||
				"FE125R": [],
 | 
			
		||||
				"FE125aR": [],
 | 
			
		||||
				"FE126R": [],
 | 
			
		||||
				"FE126aR": []
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										133
									
								
								websocket/server.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								websocket/server.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,133 @@
 | 
			
		||||
import { WebSocket, WebSocketServer } from 'ws';
 | 
			
		||||
import template from './template.json';
 | 
			
		||||
import utils from './utils';
 | 
			
		||||
 | 
			
		||||
const wss = new WebSocketServer({ port: 9800 });
 | 
			
		||||
const frequency = 10; // seconds
 | 
			
		||||
const frequency1 = 1200; // seconds
 | 
			
		||||
wss.on('connection', function (ws, req) {
 | 
			
		||||
	// console.log("ws", ws);
 | 
			
		||||
	console.log(
 | 
			
		||||
		'Client in: ',
 | 
			
		||||
		req.socket.remoteAddress,
 | 
			
		||||
		'current users:',
 | 
			
		||||
		wss.clients.size,
 | 
			
		||||
	);
 | 
			
		||||
	// ws.on("error", console.error);
 | 
			
		||||
	// ws.emit("message", "connected");
 | 
			
		||||
	ws.on('open', function () {
 | 
			
		||||
		console.log('connected');
 | 
			
		||||
		ws.send('connected');
 | 
			
		||||
	});
 | 
			
		||||
	ws.on('message', function (msg) {
 | 
			
		||||
		console.log('message from client', msg);
 | 
			
		||||
		ws.send('echo ' + msg.toString());
 | 
			
		||||
	});
 | 
			
		||||
	ws.on('error', console.error);
 | 
			
		||||
 | 
			
		||||
	const timer = setInterval(() => {
 | 
			
		||||
		sendMsg(ws, 'kiln-info'); // 窑炉信息
 | 
			
		||||
		sendMsg(ws, 'energy-cost'); // 运行状态
 | 
			
		||||
		sendMsg(ws, 'run-state'); // 运行状态
 | 
			
		||||
		sendMsg(ws, 'realtime');
 | 
			
		||||
		sendMsg(ws, 'his-trend');
 | 
			
		||||
		// sendMsg(ws, 'gas');
 | 
			
		||||
		// sendMsg(ws, 'kiln-top');
 | 
			
		||||
		// sendMsg(ws, 'kiln-bottom');
 | 
			
		||||
	}, frequency * 1000);
 | 
			
		||||
 | 
			
		||||
	const timer1 = setInterval(() => {
 | 
			
		||||
		// sendMsg(ws, 'run-state'); // 运行状态
 | 
			
		||||
	}, frequency1 * 1000);
 | 
			
		||||
 | 
			
		||||
	ws.on('close', function () {
 | 
			
		||||
		console.log('停止监听');
 | 
			
		||||
		clearInterval(timer);
 | 
			
		||||
		clearInterval(timer1);
 | 
			
		||||
	});
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
type MsgType =
 | 
			
		||||
	| 'kiln-info'
 | 
			
		||||
	| 'run-state'
 | 
			
		||||
	| 'energy-cost'
 | 
			
		||||
	| 'realtime'
 | 
			
		||||
	| 'his-trend'
 | 
			
		||||
	| 'fan'
 | 
			
		||||
	| 'gas'
 | 
			
		||||
	| 'kiln-top'
 | 
			
		||||
	| 'kiln-bottom';
 | 
			
		||||
 | 
			
		||||
type ResponseData = {
 | 
			
		||||
	[key: string]: string | string[];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
type ResponseDataComplex = {
 | 
			
		||||
	[key: string]: ResponseData;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function sendMsg(ws: WebSocket, type: MsgType) {
 | 
			
		||||
	let data: ResponseData | ResponseDataComplex = {};
 | 
			
		||||
	switch (type) {
 | 
			
		||||
		case 'kiln-info':
 | 
			
		||||
			for (const key in template.kilnInfo) {
 | 
			
		||||
				data[key] = utils.getRandom(
 | 
			
		||||
					template.kilnInfo[key as keyof typeof template.kilnInfo],
 | 
			
		||||
				);
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		case 'energy-cost':
 | 
			
		||||
			for (const key in template.energyCost) {
 | 
			
		||||
				data[key] = utils.getRandom(
 | 
			
		||||
					template.energyCost[key as keyof typeof template.energyCost],
 | 
			
		||||
				);
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		case 'run-state':
 | 
			
		||||
			data = template.runState;
 | 
			
		||||
			data.fireDirection =
 | 
			
		||||
				Math.floor(Math.random() * 10) % 2 === 0 ? '南火' : '北火';
 | 
			
		||||
			break;
 | 
			
		||||
		case 'realtime':
 | 
			
		||||
			/** 天然气 实时流量 */
 | 
			
		||||
			data.gasii = template.realtime.gasii.map((v) => utils.getRandom(v));
 | 
			
		||||
			/** 助燃风 实时流量 */
 | 
			
		||||
			data.wind = template.realtime.wind.map((v) => utils.getRandom(v));
 | 
			
		||||
			break;
 | 
			
		||||
		case 'his-trend':
 | 
			
		||||
			const hisTrend: {
 | 
			
		||||
				gas: ResponseData;
 | 
			
		||||
				wind: ResponseData;
 | 
			
		||||
			} = {
 | 
			
		||||
				gas: {},
 | 
			
		||||
				wind: {},
 | 
			
		||||
			};
 | 
			
		||||
			Object.keys(template.hisTrend.gas).forEach((key) => {
 | 
			
		||||
				hisTrend.gas[key] = template.hisTrend.gas[
 | 
			
		||||
					key as keyof typeof template.hisTrend.gas
 | 
			
		||||
				].map((v) => utils.getRandom(v));
 | 
			
		||||
			});
 | 
			
		||||
			Object.keys(template.hisTrend.wind).forEach((key) => {
 | 
			
		||||
				hisTrend.wind[key] = template.hisTrend.wind[
 | 
			
		||||
					key as keyof typeof template.hisTrend.wind
 | 
			
		||||
				].map((v) => utils.getRandom(v));
 | 
			
		||||
			});
 | 
			
		||||
			data = hisTrend;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'gas':
 | 
			
		||||
			// data = template.gas;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'kiln-top':
 | 
			
		||||
			// data = template.kilnTop;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'kiln-bottom':
 | 
			
		||||
			// data = template.kilnBottom;
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			// data = 'You are connected!';
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
	// console.log("sendMsg: ", ws);
 | 
			
		||||
	// ws.emit("message", JSON.stringify(data));
 | 
			
		||||
	ws.send(JSON.stringify({ type, data }));
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										570
									
								
								websocket/template.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										570
									
								
								websocket/template.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,570 @@
 | 
			
		||||
{
 | 
			
		||||
	"kilnInfo": {
 | 
			
		||||
		"kilnPressure": "***Kpa",
 | 
			
		||||
		"waterLoopTemperature": "...℃",
 | 
			
		||||
		"waterLoopFlow": "+++m³/h",
 | 
			
		||||
		"waterLoopPressure": "***Kpa",
 | 
			
		||||
		"windPressure": "***Kpa",
 | 
			
		||||
		"gasPressure": "***Kpa",
 | 
			
		||||
		"topTemperature": "...℃",
 | 
			
		||||
		"meltTemperature": "...℃"
 | 
			
		||||
	},
 | 
			
		||||
	"energyCost": {
 | 
			
		||||
		"restHeat": "***kWh",
 | 
			
		||||
		"water": "+++Km³",
 | 
			
		||||
		"electricity": "+++kWh",
 | 
			
		||||
		"gasi": "...m³",
 | 
			
		||||
		"gasii": "...m³"
 | 
			
		||||
	},
 | 
			
		||||
	"runState": {
 | 
			
		||||
		"lastFireChangeTime": "19分28秒",
 | 
			
		||||
		"fireChangeTime": "19:56",
 | 
			
		||||
		"fireDirection": "南火"
 | 
			
		||||
	},
 | 
			
		||||
	"fan": [
 | 
			
		||||
		["8#压延冷却风机", "4373Hz", "正常"],
 | 
			
		||||
		["7#压延冷却风机", "4772Hz", "正常"],
 | 
			
		||||
		["6#压延冷却风机", "1704Hz", "正常"],
 | 
			
		||||
		["5#压延冷却风机", "3109Hz", "正常"],
 | 
			
		||||
		["4#压延冷却风机", "2595Hz", "正常"],
 | 
			
		||||
		["3#压延冷却风机", "8903Hz", "正常"],
 | 
			
		||||
		["2#压延冷却风机", "3741Hz", "正常"],
 | 
			
		||||
		["1#压延冷却风机", "9035Hz", "正常"],
 | 
			
		||||
		["4#熔化部风机", "5223Hz", "正常"],
 | 
			
		||||
		["3#熔化部风机", "9722Hz", "正常"],
 | 
			
		||||
		["2#熔化部风机", "9617Hz", "正常"],
 | 
			
		||||
		["1#熔化部风机", "7135Hz", "正常"],
 | 
			
		||||
		["4#澄清部风机", "1699Hz", "正常"],
 | 
			
		||||
		["3#澄清部风机", "2511Hz", "正常"],
 | 
			
		||||
		["2#澄清部风机", "9780Hz", "正常"],
 | 
			
		||||
		["1#澄清部风机", "3809Hz", "正常"],
 | 
			
		||||
		["2#助燃风机", "435Hz", "正常"],
 | 
			
		||||
		["1#助燃风机", "6270Hz", "正常"],
 | 
			
		||||
		["2#L吊墙风机", "8181Hz", "正常"],
 | 
			
		||||
		["1#L吊墙风机", "5587Hz", "正常"],
 | 
			
		||||
		["2#钢碹碴池壁风机", "6652Hz", "正常"],
 | 
			
		||||
		["1#钢碹碴池壁风机", "2000Hz", "正常"],
 | 
			
		||||
		["2#池壁拐角风机", "1972Hz", "正常"],
 | 
			
		||||
		["1#池壁拐角风机", "7730Hz", "正常"]
 | 
			
		||||
	],
 | 
			
		||||
	"realtime": {
 | 
			
		||||
		"gasii": [
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h"
 | 
			
		||||
		],
 | 
			
		||||
		"wind": [
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h",
 | 
			
		||||
			"...m³/h"
 | 
			
		||||
		]
 | 
			
		||||
	},
 | 
			
		||||
	"hisTrend": {
 | 
			
		||||
		"gas": {
 | 
			
		||||
			"FE111R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE113R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE112R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE115R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE114R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE117R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE116R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE118R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			]
 | 
			
		||||
		},
 | 
			
		||||
		"wind": {
 | 
			
		||||
			"FE124R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE123aR": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE123R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE124aR": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE126R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE125aR": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE125R": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			],
 | 
			
		||||
			"FE126aR": [
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$",
 | 
			
		||||
				"$$$"
 | 
			
		||||
			]
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	"kilnBottom": {
 | 
			
		||||
		"kilnTempBottomT1": {
 | 
			
		||||
			"TE316": [
 | 
			
		||||
				44, 49, 20, 29, 96, 76, 20, 82, 28, 86, 69, 18, 23, 58, 83, 84, 94, 99,
 | 
			
		||||
				36, 51, 32
 | 
			
		||||
			],
 | 
			
		||||
			"TE315": [
 | 
			
		||||
				84, 61, 87, 82, 33, 9, 20, 23, 81, 0, 16, 81, 9, 78, 30, 16, 49, 16, 95,
 | 
			
		||||
				53, 19
 | 
			
		||||
			],
 | 
			
		||||
			"TE314": [
 | 
			
		||||
				45, 93, 11, 47, 27, 69, 91, 17, 0, 67, 60, 15, 84, 36, 89, 30, 36, 90,
 | 
			
		||||
				38, 94, 87
 | 
			
		||||
			],
 | 
			
		||||
			"TE313": [
 | 
			
		||||
				60, 9, 59, 15, 43, 41, 83, 93, 99, 91, 29, 47, 2, 40, 65, 39, 12, 20,
 | 
			
		||||
				57, 64, 95
 | 
			
		||||
			],
 | 
			
		||||
			"TE312": [
 | 
			
		||||
				22, 46, 93, 69, 44, 3, 62, 49, 4, 18, 87, 76, 36, 16, 50, 36, 54, 90, 1,
 | 
			
		||||
				66, 68
 | 
			
		||||
			]
 | 
			
		||||
		},
 | 
			
		||||
		"kilnTempBottomT2": {
 | 
			
		||||
			"TE319": [
 | 
			
		||||
				48, 56, 40, 44, 31, 82, 35, 36, 0, 84, 49, 38, 28, 34, 98, 60, 4, 69,
 | 
			
		||||
				15, 86, 19
 | 
			
		||||
			],
 | 
			
		||||
			"TE318": [
 | 
			
		||||
				7, 30, 57, 78, 47, 99, 1, 98, 47, 86, 55, 10, 98, 27, 97, 85, 54, 41,
 | 
			
		||||
				27, 85, 44
 | 
			
		||||
			],
 | 
			
		||||
			"TE317": [
 | 
			
		||||
				72, 13, 7, 69, 77, 36, 6, 34, 97, 48, 75, 29, 75, 4, 70, 80, 31, 10, 39,
 | 
			
		||||
				86, 52
 | 
			
		||||
			],
 | 
			
		||||
			"TE321": [
 | 
			
		||||
				6, 60, 32, 19, 79, 99, 98, 81, 82, 68, 3, 94, 7, 29, 48, 52, 36, 59, 28,
 | 
			
		||||
				77, 17
 | 
			
		||||
			],
 | 
			
		||||
			"TE320": [
 | 
			
		||||
				23, 47, 4, 15, 7, 74, 75, 60, 78, 89, 15, 95, 74, 85, 20, 48, 79, 51,
 | 
			
		||||
				63, 82, 68
 | 
			
		||||
			]
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	"kilnTop": {
 | 
			
		||||
		"kilnTempTopT2": {
 | 
			
		||||
			"TE215": [
 | 
			
		||||
				81, 12, 86, 55, 50, 59, 20, 67, 66, 29, 17, 74, 11, 12, 63, 23, 34, 86,
 | 
			
		||||
				9, 38, 99, 3, 33, 77
 | 
			
		||||
			],
 | 
			
		||||
			"TE214": [
 | 
			
		||||
				51, 12, 49, 60, 3, 67, 95, 62, 22, 89, 69, 14, 41, 79, 77, 27, 26, 34,
 | 
			
		||||
				69, 44, 89, 86, 92, 1
 | 
			
		||||
			],
 | 
			
		||||
			"TE213": [
 | 
			
		||||
				76, 14, 35, 1, 36, 67, 40, 5, 53, 98, 46, 29, 71, 12, 43, 42, 53, 56, 9,
 | 
			
		||||
				17, 34, 42, 82, 73
 | 
			
		||||
			]
 | 
			
		||||
		},
 | 
			
		||||
		"kilnTempTopT1": {
 | 
			
		||||
			"TE209": [
 | 
			
		||||
				51, 12, 49, 60, 3, 67, 95, 62, 22, 89, 69, 14, 41, 79, 77, 27, 26, 34,
 | 
			
		||||
				69, 44, 89, 86, 92, 1
 | 
			
		||||
			],
 | 
			
		||||
			"TE208": [
 | 
			
		||||
				76, 14, 35, 1, 36, 67, 40, 5, 53, 98, 46, 29, 71, 12, 43, 42, 53, 56, 9,
 | 
			
		||||
				17, 34, 42, 82, 73
 | 
			
		||||
			],
 | 
			
		||||
			"TE210": [
 | 
			
		||||
				81, 12, 86, 55, 50, 59, 20, 67, 66, 29, 17, 74, 11, 12, 63, 23, 34, 86,
 | 
			
		||||
				9, 38, 99, 3, 33, 77
 | 
			
		||||
			]
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										109
									
								
								websocket/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								websocket/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,109 @@
 | 
			
		||||
{
 | 
			
		||||
	"compilerOptions": {
 | 
			
		||||
		/* Visit https://aka.ms/tsconfig to read more about this file */
 | 
			
		||||
 | 
			
		||||
		/* Projects */
 | 
			
		||||
		// "incremental": true,                              /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
 | 
			
		||||
		// "composite": true,                                /* Enable constraints that allow a TypeScript project to be used with project references. */
 | 
			
		||||
		// "tsBuildInfoFile": "./.tsbuildinfo",              /* Specify the path to .tsbuildinfo incremental compilation file. */
 | 
			
		||||
		// "disableSourceOfProjectReferenceRedirect": true,  /* Disable preferring source files instead of declaration files when referencing composite projects. */
 | 
			
		||||
		// "disableSolutionSearching": true,                 /* Opt a project out of multi-project reference checking when editing. */
 | 
			
		||||
		// "disableReferencedProjectLoad": true,             /* Reduce the number of projects loaded automatically by TypeScript. */
 | 
			
		||||
 | 
			
		||||
		/* Language and Environment */
 | 
			
		||||
		"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
 | 
			
		||||
		// "lib": [],                                        /* Specify a set of bundled library declaration files that describe the target runtime environment. */
 | 
			
		||||
		// "jsx": "preserve",                                /* Specify what JSX code is generated. */
 | 
			
		||||
		// "experimentalDecorators": true,                   /* Enable experimental support for legacy experimental decorators. */
 | 
			
		||||
		// "emitDecoratorMetadata": true,                    /* Emit design-type metadata for decorated declarations in source files. */
 | 
			
		||||
		// "jsxFactory": "",                                 /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
 | 
			
		||||
		// "jsxFragmentFactory": "",                         /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
 | 
			
		||||
		// "jsxImportSource": "",                            /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
 | 
			
		||||
		// "reactNamespace": "",                             /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
 | 
			
		||||
		// "noLib": true,                                    /* Disable including any library files, including the default lib.d.ts. */
 | 
			
		||||
		// "useDefineForClassFields": true,                  /* Emit ECMAScript-standard-compliant class fields. */
 | 
			
		||||
		// "moduleDetection": "auto",                        /* Control what method is used to detect module-format JS files. */
 | 
			
		||||
 | 
			
		||||
		/* Modules */
 | 
			
		||||
		"module": "commonjs" /* Specify what module code is generated. */,
 | 
			
		||||
		// "rootDir": "./",                                  /* Specify the root folder within your source files. */
 | 
			
		||||
		// "moduleResolution": "node10",                     /* Specify how TypeScript looks up a file from a given module specifier. */
 | 
			
		||||
		// "baseUrl": "./",                                  /* Specify the base directory to resolve non-relative module names. */
 | 
			
		||||
		// "paths": {},                                      /* Specify a set of entries that re-map imports to additional lookup locations. */
 | 
			
		||||
		// "rootDirs": [],                                   /* Allow multiple folders to be treated as one when resolving modules. */
 | 
			
		||||
		// "typeRoots": [],                                  /* Specify multiple folders that act like './node_modules/@types'. */
 | 
			
		||||
		// "types": [],                                      /* Specify type package names to be included without being referenced in a source file. */
 | 
			
		||||
		// "allowUmdGlobalAccess": true,                     /* Allow accessing UMD globals from modules. */
 | 
			
		||||
		// "moduleSuffixes": [],                             /* List of file name suffixes to search when resolving a module. */
 | 
			
		||||
		// "allowImportingTsExtensions": true,               /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
 | 
			
		||||
		// "resolvePackageJsonExports": true,                /* Use the package.json 'exports' field when resolving package imports. */
 | 
			
		||||
		// "resolvePackageJsonImports": true,                /* Use the package.json 'imports' field when resolving imports. */
 | 
			
		||||
		// "customConditions": [],                           /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
 | 
			
		||||
		"resolveJsonModule": true /* Enable importing .json files. */,
 | 
			
		||||
		// "allowArbitraryExtensions": true,                 /* Enable importing files with any extension, provided a declaration file is present. */
 | 
			
		||||
		// "noResolve": true,                                /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
 | 
			
		||||
 | 
			
		||||
		/* JavaScript Support */
 | 
			
		||||
		// "allowJs": true,                                  /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
 | 
			
		||||
		// "checkJs": true,                                  /* Enable error reporting in type-checked JavaScript files. */
 | 
			
		||||
		// "maxNodeModuleJsDepth": 1,                        /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
 | 
			
		||||
 | 
			
		||||
		/* Emit */
 | 
			
		||||
		// "declaration": true,                              /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
 | 
			
		||||
		// "declarationMap": true,                           /* Create sourcemaps for d.ts files. */
 | 
			
		||||
		// "emitDeclarationOnly": true,                      /* Only output d.ts files and not JavaScript files. */
 | 
			
		||||
		// "sourceMap": true,                                /* Create source map files for emitted JavaScript files. */
 | 
			
		||||
		// "inlineSourceMap": true,                          /* Include sourcemap files inside the emitted JavaScript. */
 | 
			
		||||
		// "outFile": "./",                                  /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
 | 
			
		||||
		// "outDir": "./",                                   /* Specify an output folder for all emitted files. */
 | 
			
		||||
		// "removeComments": true,                           /* Disable emitting comments. */
 | 
			
		||||
		// "noEmit": true,                                   /* Disable emitting files from a compilation. */
 | 
			
		||||
		// "importHelpers": true,                            /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
 | 
			
		||||
		// "importsNotUsedAsValues": "remove",               /* Specify emit/checking behavior for imports that are only used for types. */
 | 
			
		||||
		// "downlevelIteration": true,                       /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
 | 
			
		||||
		// "sourceRoot": "",                                 /* Specify the root path for debuggers to find the reference source code. */
 | 
			
		||||
		// "mapRoot": "",                                    /* Specify the location where debugger should locate map files instead of generated locations. */
 | 
			
		||||
		// "inlineSources": true,                            /* Include source code in the sourcemaps inside the emitted JavaScript. */
 | 
			
		||||
		// "emitBOM": true,                                  /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
 | 
			
		||||
		// "newLine": "crlf",                                /* Set the newline character for emitting files. */
 | 
			
		||||
		// "stripInternal": true,                            /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
 | 
			
		||||
		// "noEmitHelpers": true,                            /* Disable generating custom helper functions like '__extends' in compiled output. */
 | 
			
		||||
		// "noEmitOnError": true,                            /* Disable emitting files if any type checking errors are reported. */
 | 
			
		||||
		// "preserveConstEnums": true,                       /* Disable erasing 'const enum' declarations in generated code. */
 | 
			
		||||
		// "declarationDir": "./",                           /* Specify the output directory for generated declaration files. */
 | 
			
		||||
		// "preserveValueImports": true,                     /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
 | 
			
		||||
 | 
			
		||||
		/* Interop Constraints */
 | 
			
		||||
		// "isolatedModules": true,                          /* Ensure that each file can be safely transpiled without relying on other imports. */
 | 
			
		||||
		// "verbatimModuleSyntax": true,                     /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
 | 
			
		||||
		// "allowSyntheticDefaultImports": true,             /* Allow 'import x from y' when a module doesn't have a default export. */
 | 
			
		||||
		"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
 | 
			
		||||
		// "preserveSymlinks": true,                         /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
 | 
			
		||||
		"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
 | 
			
		||||
 | 
			
		||||
		/* Type Checking */
 | 
			
		||||
		"strict": true /* Enable all strict type-checking options. */,
 | 
			
		||||
		// "noImplicitAny": true,                            /* Enable error reporting for expressions and declarations with an implied 'any' type. */
 | 
			
		||||
		// "strictNullChecks": true,                         /* When type checking, take into account 'null' and 'undefined'. */
 | 
			
		||||
		// "strictFunctionTypes": true,                      /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
 | 
			
		||||
		// "strictBindCallApply": true,                      /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
 | 
			
		||||
		// "strictPropertyInitialization": true,             /* Check for class properties that are declared but not set in the constructor. */
 | 
			
		||||
		// "noImplicitThis": true,                           /* Enable error reporting when 'this' is given the type 'any'. */
 | 
			
		||||
		// "useUnknownInCatchVariables": true,               /* Default catch clause variables as 'unknown' instead of 'any'. */
 | 
			
		||||
		// "alwaysStrict": true,                             /* Ensure 'use strict' is always emitted. */
 | 
			
		||||
		// "noUnusedLocals": true,                           /* Enable error reporting when local variables aren't read. */
 | 
			
		||||
		// "noUnusedParameters": true,                       /* Raise an error when a function parameter isn't read. */
 | 
			
		||||
		// "exactOptionalPropertyTypes": true,               /* Interpret optional property types as written, rather than adding 'undefined'. */
 | 
			
		||||
		// "noImplicitReturns": true,                        /* Enable error reporting for codepaths that do not explicitly return in a function. */
 | 
			
		||||
		// "noFallthroughCasesInSwitch": true,               /* Enable error reporting for fallthrough cases in switch statements. */
 | 
			
		||||
		// "noUncheckedIndexedAccess": true,                 /* Add 'undefined' to a type when accessed using an index. */
 | 
			
		||||
		// "noImplicitOverride": true,                       /* Ensure overriding members in derived classes are marked with an override modifier. */
 | 
			
		||||
		// "noPropertyAccessFromIndexSignature": true,       /* Enforces using indexed accessors for keys declared using an indexed type. */
 | 
			
		||||
		// "allowUnusedLabels": true,                        /* Disable error reporting for unused labels. */
 | 
			
		||||
		// "allowUnreachableCode": true,                     /* Disable error reporting for unreachable code. */
 | 
			
		||||
 | 
			
		||||
		/* Completeness */
 | 
			
		||||
		// "skipDefaultLibCheck": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */
 | 
			
		||||
		"skipLibCheck": true /* Skip type checking all .d.ts files. */
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										48
									
								
								websocket/utils.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								websocket/utils.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
export default {
 | 
			
		||||
	// 生成随机数
 | 
			
		||||
	randomNum({ min, max }: { min: number; max: number }, isFloat = false) {
 | 
			
		||||
		if (isFloat) return (Math.random() * (max - min) + min).toFixed(2);
 | 
			
		||||
		return Math.floor(Math.random() * (max - min + 1) + min);
 | 
			
		||||
	},
 | 
			
		||||
	getMinmax(type: '*' | '.' | '+' | '$') {
 | 
			
		||||
		let min: number, max: number;
 | 
			
		||||
		switch (type) {
 | 
			
		||||
			case '*':
 | 
			
		||||
				min = 30;
 | 
			
		||||
				max = 150;
 | 
			
		||||
				break;
 | 
			
		||||
			case '.':
 | 
			
		||||
				min = 60;
 | 
			
		||||
				max = 200;
 | 
			
		||||
				break;
 | 
			
		||||
			case '+':
 | 
			
		||||
				min = 20;
 | 
			
		||||
				max = 70;
 | 
			
		||||
				break;
 | 
			
		||||
			case '$':
 | 
			
		||||
				min = 1;
 | 
			
		||||
				max = 100;
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
		return { min, max };
 | 
			
		||||
	},
 | 
			
		||||
	getRandom(value: string) {
 | 
			
		||||
		value = value.replace(
 | 
			
		||||
			'***',
 | 
			
		||||
			'' + this.randomNum({ ...this.getMinmax('*') }),
 | 
			
		||||
		);
 | 
			
		||||
		value = value.replace(
 | 
			
		||||
			'...',
 | 
			
		||||
			'' + this.randomNum({ ...this.getMinmax('.') }),
 | 
			
		||||
		);
 | 
			
		||||
		value = value.replace(
 | 
			
		||||
			'+++',
 | 
			
		||||
			'' + this.randomNum({ ...this.getMinmax('+') }),
 | 
			
		||||
		);
 | 
			
		||||
		value = value.replace(
 | 
			
		||||
			'$$$',
 | 
			
		||||
			'' + this.randomNum({ ...this.getMinmax('$') }, true),
 | 
			
		||||
		);
 | 
			
		||||
		return value;
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user