Skip to content

Instantly share code, notes, and snippets.

View benhar-dev's full-sized avatar

Ben benhar-dev

View GitHub Profile
$route = get-adsroute -local;
$session = New-TcSession -Route $route -Port 851;
Write-Host $session;
$v1 = Read-TcValue -Session $session -Path "Main.bChange";
Write-TcValue -Session $session -Path "MAIN.fbPing.bEnable" -value $true -Force ;
Do
{
if (Test-Connection -ComputerName 127.0.0.1 -Quiet) {
Write-TcValue -Session $session -Path "Main.bChange" -value $true -Force;
} else {
@benhar-dev
benhar-dev / ADS IO Link Writer
Last active July 6, 2020 00:04
Example of using ADSWRITE to change parameters in an IO Link master.
PROGRAM MAIN
VAR
eventLogger : FB_TcEventLogger; // requires the TC3_EventLogger Library.
END_VAR
// code ------------------------------------------------------------------------------
eventLogger.ClearAllAlarms(nTimeStamp:=0,bResetConfirmation:=TRUE);
CSS --
/*All Datagrid List*/
/*Removes background styling and focus*/
tr.focused {
color: inherit;
}
.tchmi-datagrid-template-data-scroll tr.focused td:not(.focused)::before {
background: white;
// Declaration
myObject : T_MyObject; // implements I_Counter
iCounter : I_Counter;
rCounter : REFERENCE TO I_Counter;
rCounter2 : REFERENCE TO I_Counter;
iCounter2 : I_Counter;
// Program
@benhar-dev
benhar-dev / registerTnZipAsZip.reg
Last active August 11, 2020 05:20
This small reg file will allow you to double click on .tnzip files and have windows treat them as any other .zip. This is a mini time saving tip when working with TwinCAT archives.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.tnzip]
@="CompressedFolder"
"Content Type"="application/x-zip-compressed"
"DontCompressInPackage"=""
"PerceivedType"="compressed"
[HKEY_CLASSES_ROOT\.tnzip\OpenWithProgids]
"CompressedFolder"=""
@benhar-dev
benhar-dev / ProxyWebsocket.js
Created September 2, 2020 05:20
Proxy a Websocket
// proxy the window.WebSocket object
var WebSocketProxy = new Proxy(window.WebSocket, {
construct: function(target, args) {
// create WebSocket instance
const instance = new target(...args);
// WebSocket "onopen" handler
const openHandler = (event) => {
console.log('Open', event);
};
<script>
function redirect () {
window.location.replace("http://www.google.com");
}
var currentTimeoutInterval = window.setTimeout(redirect, 5000);
function currentWebsocket() {
if (window.location.protocol == "https:") {
@benhar-dev
benhar-dev / ReturnStringBeforeCharacter.js
Created October 14, 2020 03:30
Returns the string before the "." character. Useful for TcHmi Ids of UserControls
var componentName=componentFullName.substr(0, componentFullName.indexOf('.'));
@benhar-dev
benhar-dev / BaseStyle.css
Created October 16, 2020 04:06
How to implement a custom class with a TcHmi class
/* keyboard-modal--animate added to Themes>Base.theme>Control Classes equaits to the follow... (also added standard animate css)*/
.tchmi-class-keyboard-modal--animate
{
transition: all 0.3s;
}