浏览代码

before new example

Will 3 月之前
父节点
当前提交
fbd1989c7a
共有 3 个文件被更改,包括 22 次插入40 次删除
  1. 1 27
      st.k
  2. 16 0
      tempDT.k
  3. 5 13
      tempST.k

+ 1 - 27
st.k

@@ -1,27 +1 @@
-/ evalST
-/ pass the data generated
-/ by the compiled function
-/ to evalST to get an
-/ action that can be called
-
-// condition vec, actions vec, transition table, table args
-evalST: {[c;a;t;args] eidx:*&c[args]; ts: t[0;eidx]; (a[ts[0]];ts[1])};
-
-/ Actions
-A1: {[] "fan low"};
-A2: {[] "fan med"};
-A3: {[] "fan hig"};
-A4: {[] "heat on"};
-A5: {[] "acpw on"};
-A6: {[] "allp of"};
-
-c: {[args] T:args[0]; isOff:args[1]; (isOff;T<18;T<22;T<26;T<30;T>30)};
-a: (A1;A2;A3;A4;A5;A6);
-t: (((0N;1);(4;5);(1;2);(2;3);(3;4);(5;6));((6;1);(4;5);(0N;2);(2;3);(3;4);(5;6));((6;1);(4;5);(1;2);(0N;3);(3;4);(5;6));((6;1);(4;5);(1;2);(2;3);(0N;4);(5;6));((6;1);(0N;5);(1;2);(2;3);(3;4);(5;6));((6;1);(4;5);(1;2);(2;3);(3;4);(0N;6)));
-s: ("Off";"FanLow";"FanMedium";"FanHigh";"Heating";"Cooling");
-at: (`i;`i;`i); / T, isOff, current state - see c
-
-state: 0;
-(action;state): evalST[c;a;t;(20;0;state)];
-:action
-:s[state]
+evalST: {[args] (c;a;t;args):args; eidx:*&c[args]; ts: t[0;eidx]; (a[ts[0]];ts[1])};

+ 16 - 0
tempDT.k

@@ -0,0 +1,16 @@
+/ tempDT.k.csv compiled
+tempDTat: `i`i
+
+tempDT: {[args]
+ cr:((1 0N 0 0N 0);(0 1 0 0N 0);(0 0 1 0 0N);(1 1 1 0 0);(1 0 0 1 0);(0 0 1 0 1);(0 0 0 0 0));
+ R1:{heater[1];ac[0];};
+ R2:{heater[0];ac[0];};
+ R3:{heater[0];ac[1];};
+ R4:{heater[1];ac[0];};
+ R5:{heater[0];ac[1];};
+ r:(R1;R2;R3;R4;R5);
+ c:(args[0]<20;args[0]<26;args[0]>25;args[1]=0;args[1]=1;args[1]=2);
+ cr@&c
+};
+
+tempDT[(0 0)]

+ 5 - 13
tempST.k

@@ -1,16 +1,8 @@
 / tempST.k.csv compiled
+tempSTs:(("Off");("FanLow");("FanMedium");("FanHigh");("Heating"));
+tempSTat:`i`i;
+tempSTstate: 0;
 
-A1:{"setFan[`l]"};
-A2:{"setFan[`m]"};
-A3:{"setFan[`h]"};
-A4:{"heaterPower[1]"};
-A5:{"ACPower[1]"};
-A6:{"allPower[0]"};
-A7:{"next"};
-A8:{"exit"};
-a:(A1;A2;A3;A4;A5;A6;A7;A8);
-c:{[args]isOff:args[0];T:args[1];((isOff);(T < 18);(T < 22);(T < 26);(T < 30))};
-s:(("Off");("FanLow");("FanMedium");("FanHigh");("Heating"));
-t:(((0N 1);(4 5);(1 2);(2 3);(3 4);(5 6));((6 1);(4 5);(0N 2);(2 3);(3 4);(5 6));((6 1);(4 5);(1 2);(0N 3);(3 4);(5 6));((6 1);(4 5);(1 2);(2 3);(0N 4);(5 6));((6 1);(0N 5);(1 2);(2 3);(3 4);(5 6)));
-at:`i`i;
+tempST: {[args] isOff:args[0]; T:args[1]; c:((isOff);(T < 18);(T < 22);(T < 26);(T < 30)); a:("fan low";"fan med";"fan hig";"heat on"; "ac on"; "all off"; "next"; "exit"; "err"); t:(((0N 1);(4 5);(1 2);(2 3);(3 4);(5 6));((6 1);(4 5);(0N 2);(2 3);(3 4);(5 6));((6 1);(4 5);(1 2);(0N 3);(3 4);(5 6));((6 1);(4 5);(1 2);(2 3);(0N 4);(5 6));((6 1);(0N 5);(1 2);(2 3);(3 4);(5 6))); eidx: *&c; ts: t[args[2];eidx]; (a[ts[0]];ts[1])};
 
+tempST[(0;0;tempSTstate)]