Skip to content

Commit f54304d

Browse files
committed
1 parent 8594b44 commit f54304d

File tree

11 files changed

+154
-166
lines changed

11 files changed

+154
-166
lines changed

.pre-commit-config.yaml

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
# These are some pretty standard general pre-commit hooks
44
repos:
5-
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
66
rev: v3.2.0
77
hooks:
8-
- id: trailing-whitespace # Removes trailing white spaces
9-
- id: check-yaml # checks yaml files for parseable syntax.
10-
- id: check-added-large-files # prevents giant files from being committed.
8+
- id: trailing-whitespace # Removes trailing white spaces
9+
- id: check-yaml # checks yaml files for parseable syntax.
10+
- id: check-added-large-files # prevents giant files from being committed.
1111

12-
13-
# These hooks are made specifically for TwinCAT by the people of the Photon Controls and Data Systems at SLAC
14-
- repo: https://github.com/pcdshub/pre-commit-hooks
12+
# These hooks are made specifically for TwinCAT by the people of the Photon Controls and Data Systems at SLAC
13+
- repo: https://github.com/pcdshub/pre-commit-hooks
1514
rev: v1.1.0
1615
hooks:
17-
- id: twincat-leading-tabs-remover # Replaces all leading tabs with spaces
18-
- id: twincat-lineids-remover # Removes line ids. See point 4 of the link for why you don't need them https://cookncode.com/twincat/2021/06/07/tc-source-control-tips#2-creating-independent-files
19-
- id: twincat-xml-format # Formats .tmc and .tpy files
16+
- id: twincat-leading-tabs-remover # Replaces all leading tabs with spaces
17+
- id: twincat-lineids-remover # Removes line ids. See point 4 of the link for why you don't need them https://cookncode.com/twincat/2021/06/07/tc-source-control-tips#2-creating-independent-files
18+
- id: twincat-xml-format # Formats .tmc and .tpy files
2019

21-
# # Doesnt work for me yet: https://github.com/pre-commit/mirrors-prettier/issues/18
22-
# - repo: https://github.com/pre-commit/mirrors-prettier
23-
# rev: v2.6.0 # Use the sha / tag you want to point at
24-
# hooks:
25-
# - id: prettier
20+
# Doesnt work for me yet: https://github.com/pre-commit/mirrors-prettier/issues/18
21+
- repo: https://github.com/pre-commit/mirrors-prettier
22+
rev: v2.6.0 # Use the sha / tag you want to point at
23+
hooks:
24+
- id: prettier
25+
exclude_types: [json]

Datagrid/Datagrid/Fonts/Fonts.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@font-face {
2-
font-family: RobotoCondensed;
3-
src: url(Roboto-Condensed-webfont.woff);
2+
font-family: RobotoCondensed;
3+
src: url(Roboto-Condensed-webfont.woff);
44
}
55

66
/**

Datagrid/Datagrid/RowClassesProvider.js

+28-25
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@
88
/// <reference path="C:\TwinCAT\Functions\TE2000-HMI-Engineering\Infrastructure\TcHmiFramework\Latest\TcHmi.js" />
99

1010
(function (TcHmi) {
11-
12-
var RowClassesProvider = function (rowData, rowIndex, rowNumber) {
13-
var cssStyles = []; // Collected CSS styles which will be returned at the end
14-
15-
if (!rowData.Test1) { // If the first column (Test1) is empty
16-
cssStyles.push('missing-input'); // add the missing-input style to the array
17-
}
18-
19-
if (rowData.Test2 < 0) { // If the value of the second column is negative
20-
cssStyles.push('below-zero'); // add the below-zero style
21-
}
22-
23-
if (!rowData.Test3) { // If the checkbox in the third column is not checked
24-
cssStyles.push('not-checked');
25-
}
26-
27-
if (rowData.Test4 == "cookncode") { // if the text in the fourth column is cookncode
28-
cssStyles.push('bold');
29-
}
30-
31-
return cssStyles;
32-
};
33-
34-
TcHmi.Functions.registerFunction('RowClassesProvider', RowClassesProvider);
35-
})(TcHmi);
11+
var RowClassesProvider = function (rowData, rowIndex, rowNumber) {
12+
var cssStyles = []; // Collected CSS styles which will be returned at the end
13+
14+
if (!rowData.Test1) {
15+
// If the first column (Test1) is empty
16+
cssStyles.push("missing-input"); // add the missing-input style to the array
17+
}
18+
19+
if (rowData.Test2 < 0) {
20+
// If the value of the second column is negative
21+
cssStyles.push("below-zero"); // add the below-zero style
22+
}
23+
24+
if (!rowData.Test3) {
25+
// If the checkbox in the third column is not checked
26+
cssStyles.push("not-checked");
27+
}
28+
29+
if (rowData.Test4 == "cookncode") {
30+
// if the text in the fourth column is cookncode
31+
cssStyles.push("bold");
32+
}
33+
34+
return cssStyles;
35+
};
36+
37+
TcHmi.Functions.registerFunction("RowClassesProvider", RowClassesProvider);
38+
})(TcHmi);

Datagrid/Datagrid/Style.css

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
/*Change the background color of the first column to orange*/
22
#TcHmiDatagrid tr.missing-input td[data-column-name="Test1"] {
3-
background-color: #F76D16;
3+
background-color: #f76d16;
44
}
55

66
/*Change the second column's background to orange*/
77
#TcHmiDatagrid tr.below-zero td[data-column-name="Test2"] {
8-
background-color: #F76D16;
8+
background-color: #f76d16;
99
}
1010

1111
/*A default background color for the second column*/
1212
#TcHmiDatagrid tr td[data-column-name="Test2"] {
13-
background-color: #A0D5E8;
13+
background-color: #a0d5e8;
1414
}
1515

1616
/*Change the background color of an entire row if a check box' state is changed*/
1717
#TcHmiDatagrid tr.not-checked td::after {
18-
content: '';
19-
position: absolute;
20-
top: 0;
21-
right: 0;
22-
bottom: 0;
23-
left: 0;
24-
width: 100%;
25-
height: 10000px;
26-
pointer-events: none;
27-
z-index: 1;
28-
background-color: rgba(215, 249, 251, 0.5);
18+
content: "";
19+
position: absolute;
20+
top: 0;
21+
right: 0;
22+
bottom: 0;
23+
left: 0;
24+
width: 100%;
25+
height: 10000px;
26+
pointer-events: none;
27+
z-index: 1;
28+
background-color: rgba(215, 249, 251, 0.5);
2929
}
3030

3131
/*Make the text in the fourth column bold and change the color*/
3232
#TcHmiDatagrid tr.bold td[data-column-name="Test4"] {
33-
font-weight: bold;
34-
color: #F76D16;
33+
font-weight: bold;
34+
color: #f76d16;
3535
}

Datagrid/Datagrid/Themes/Base/Style.css

+8-14
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@
1616
*/
1717

1818
html {
19-
font-family:RobotoCondensed,
20-
'Microsoft YaHei', '微软雅黑',
21-
'Hiragino Sans GB', '冬青黑体',
22-
'STXihei', '华文细黑',
23-
'WenQuanYi Micro Hei',
24-
'Meiryo', 'メイリオ',
25-
'Hiragino Kaku Gothic Pro', 'ヒラギノ角ゴ ProN',
26-
'Noto Sans CJK SC', 'Noto Sans CJK TC', 'Noto Sans CJK JP', 'Noto Sans CJK KR',
27-
28-
sans-serif
29-
;
30-
font-size: 12px;
31-
font-style: normal;
32-
font-weight: normal;
19+
font-family: RobotoCondensed, "Microsoft YaHei", "微软雅黑",
20+
"Hiragino Sans GB", "冬青黑体", "STXihei", "华文细黑", "WenQuanYi Micro Hei",
21+
"Meiryo", "メイリオ", "Hiragino Kaku Gothic Pro", "ヒラギノ角ゴ ProN",
22+
"Noto Sans CJK SC", "Noto Sans CJK TC", "Noto Sans CJK JP",
23+
"Noto Sans CJK KR", sans-serif;
24+
font-size: 12px;
25+
font-style: normal;
26+
font-weight: normal;
3327
}

DigitalTwin/Oven/HmiProject/Fonts/Fonts.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@font-face {
2-
font-family: RobotoCondensed;
3-
src: url(Roboto-Condensed-webfont.woff);
2+
font-family: RobotoCondensed;
3+
src: url(Roboto-Condensed-webfont.woff);
44
}
55

66
/**

DigitalTwin/Oven/HmiProject/Themes/Base/Style.css

+8-14
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@
1616
*/
1717

1818
html {
19-
font-family:RobotoCondensed,
20-
'Microsoft YaHei', '微软雅黑',
21-
'Hiragino Sans GB', '冬青黑体',
22-
'STXihei', '华文细黑',
23-
'WenQuanYi Micro Hei',
24-
'Meiryo', 'メイリオ',
25-
'Hiragino Kaku Gothic Pro', 'ヒラギノ角ゴ ProN',
26-
'Noto Sans CJK SC', 'Noto Sans CJK TC', 'Noto Sans CJK JP', 'Noto Sans CJK KR',
27-
28-
sans-serif
29-
;
30-
font-size: 12px;
31-
font-style: normal;
32-
font-weight: normal;
19+
font-family: RobotoCondensed, "Microsoft YaHei", "微软雅黑",
20+
"Hiragino Sans GB", "冬青黑体", "STXihei", "华文细黑", "WenQuanYi Micro Hei",
21+
"Meiryo", "メイリオ", "Hiragino Kaku Gothic Pro", "ヒラギノ角ゴ ProN",
22+
"Noto Sans CJK SC", "Noto Sans CJK TC", "Noto Sans CJK JP",
23+
"Noto Sans CJK KR", sans-serif;
24+
font-size: 12px;
25+
font-style: normal;
26+
font-weight: normal;
3327
}

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Twincat tutorials
2+
23
Collection of TwinCAT projects used for my blog posts.
34

45
- [Eventlogger PLC part](https://cookncode.com/twincat/2020/11/03/twincat-eventlogger-plc-part.html)

TwinCatEventLogger/HmiPart/EventGridSample/AlarmPopUps.js

+64-62
Original file line numberDiff line numberDiff line change
@@ -8,72 +8,74 @@
88
/// <reference path="C:\TwinCAT\Functions\TE2000-HMI-Engineering\Infrastructure\TcHmiFramework\Latest\TcHmi.js" />
99

1010
(function (TcHmi) {
11-
// If you want to unregister an event outside the event code you need to use the return value of the method register()
12-
var destroyOnInitialized = TcHmi.EventProvider.register('onInitialized', function (e, data) {
13-
// This event will be raised only once, so we can free resources.
14-
// It's best practice to use destroy function of the event object within the callback function to avoid conflicts.
15-
e.destroy();
11+
// If you want to unregister an event outside the event code you need to use the return value of the method register()
12+
var destroyOnInitialized = TcHmi.EventProvider.register(
13+
"onInitialized",
14+
function (e, data) {
15+
// This event will be raised only once, so we can free resources.
16+
// It's best practice to use destroy function of the event object within the callback function to avoid conflicts.
17+
e.destroy();
1618

17-
function composeHtmlPopUpElement(event) {
18-
return $(
19-
'<div style="background:white;padding:10px;max-width:400px;">'
20-
+ event.text + '<br><br>'
21-
+ '<button type="button" onclick = '
22-
+ '"var topLayer=document.getElementsByClassName(\'tchmi-in-topmostlayer\');'
23-
+ 'var currentTop=topLayer[topLayer.length - 1];'
24-
+ 'TcHmi.TopMostLayer.removeEx($(currentTop));"> OK'
25-
+ '</button> '
26-
+ '</div>');
27-
}
28-
29-
function showPopUp(event) {
30-
var newPopUp = composeHtmlPopUpElement(event)
31-
TcHmi.TopMostLayer.addEx(newPopUp, {
32-
centerHorizontal: true,
33-
centerVertical: true,
34-
removecb: (data) => {
35-
if (data.canceled) {
36-
// user clicked on the background
37-
TcHmi.TopMostLayer.removeEx(newPopUp);
38-
}
39-
}
40-
});
41-
}
19+
function composeHtmlPopUpElement(event) {
20+
return $(
21+
'<div style="background:white;padding:10px;max-width:400px;">' +
22+
event.text +
23+
"<br><br>" +
24+
'<button type="button" onclick = ' +
25+
"\"var topLayer=document.getElementsByClassName('tchmi-in-topmostlayer');" +
26+
"var currentTop=topLayer[topLayer.length - 1];" +
27+
'TcHmi.TopMostLayer.removeEx($(currentTop));"> OK' +
28+
"</button> " +
29+
"</div>"
30+
);
31+
}
4232

43-
// subscripton that is called if an event inside the list changes his state
44-
function subscriptionCallback(data) {
45-
// check if the callback object is valid
46-
if (data.error === TcHmi.Errors.NONE) {
47-
// check if the alarm type is raised
48-
if (data.changeType === TcHmi.Server.Events.ChangeType.AlarmRaised) {
49-
showPopUp(data.event);
50-
}
33+
function showPopUp(event) {
34+
var newPopUp = composeHtmlPopUpElement(event);
35+
TcHmi.TopMostLayer.addEx(newPopUp, {
36+
centerHorizontal: true,
37+
centerVertical: true,
38+
removecb: (data) => {
39+
if (data.canceled) {
40+
// user clicked on the background
41+
TcHmi.TopMostLayer.removeEx(newPopUp);
5142
}
43+
},
44+
});
45+
}
46+
47+
// subscripton that is called if an event inside the list changes his state
48+
function subscriptionCallback(data) {
49+
// check if the callback object is valid
50+
if (data.error === TcHmi.Errors.NONE) {
51+
// check if the alarm type is raised
52+
if (data.changeType === TcHmi.Server.Events.ChangeType.AlarmRaised) {
53+
showPopUp(data.event);
54+
}
5255
}
56+
}
5357

54-
let allActiveAlarmsFilter = [
55-
{
56-
path: 'type',
57-
comparator: '==',
58-
value: TcHmi.Server.Events.Type.Alarm
59-
},
60-
{
61-
logic: 'AND'
62-
},
63-
{
64-
path: 'timeConfirmed',
65-
comparator: '==',
66-
value: new Date(null)
67-
}
68-
];
58+
let allActiveAlarmsFilter = [
59+
{
60+
path: "type",
61+
comparator: "==",
62+
value: TcHmi.Server.Events.Type.Alarm,
63+
},
64+
{
65+
logic: "AND",
66+
},
67+
{
68+
path: "timeConfirmed",
69+
comparator: "==",
70+
value: new Date(null),
71+
},
72+
];
6973

70-
// register an event consumer with the Server Event API with a filter
71-
// See HMI manual section 15.1.1.16.21.2 registerConsumer
72-
TcHmi.Server.Events.registerConsumer(
73-
allActiveAlarmsFilter,
74-
{
75-
subscription: subscriptionCallback
76-
}
77-
);
78-
});
74+
// register an event consumer with the Server Event API with a filter
75+
// See HMI manual section 15.1.1.16.21.2 registerConsumer
76+
TcHmi.Server.Events.registerConsumer(allActiveAlarmsFilter, {
77+
subscription: subscriptionCallback,
78+
});
79+
}
80+
);
7981
})(TcHmi);

TwinCatEventLogger/HmiPart/EventGridSample/Fonts/Fonts.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@font-face {
2-
font-family: RobotoCondensed;
3-
src: url(Roboto-Condensed-webfont.woff);
2+
font-family: RobotoCondensed;
3+
src: url(Roboto-Condensed-webfont.woff);
44
}
55

66
/**

0 commit comments

Comments
 (0)