From: rearman Date: Wed, 5 Feb 2025 20:33:15 +0000 (-0500) Subject: Cleanup, add some conversions, make plc factored like my forth.f X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=a47931dd66eac3d323dbc77801fb33b170479551;p=emacsinit.git Cleanup, add some conversions, make plc factored like my forth.f --- diff --git a/re/re-org.el b/re/re-org.el index abcebc8..24ecb8b 100644 --- a/re/re-org.el +++ b/re/re-org.el @@ -3,9 +3,8 @@ ;;; Code: -(setq org-startup-indented t) - -(setq org-M-RET-may-split-line nil +(setq org-startup-indented t + org-M-RET-may-split-line nil org-return-follows-link t org-table-export-default-format "orgtbl-to-csv" org-export-backends '(ascii html latex md) @@ -39,23 +38,23 @@ org-refile-allow-creating-parent-nodes 'confirm) (setq org-todo-keywords '((sequence "TODO(t)" - "WAITING(w@/!)" - "IN-PROGRESS(i!)" - "APPT(a!)" - "ORDERED(o!)" - "QUOTED(q!)" - "|" - "RECEIVED(r!/@)" - "DELEGATED(l@)" - "DONE(d!/@)" - "CANCELLED(c@)"))) + "WAITING(w@/!)" + "IN-PROGRESS(i!)" + "APPT(a!)" + "ORDERED(o!)" + "QUOTED(q!)" + "|" + "RECEIVED(r!/@)" + "DELEGATED(l@)" + "DONE(d!/@)" + "CANCELLED(c@)"))) (setq org-tag-alist '((:startgroup . nil) - ("licenses" . ?l) - ("need" . ?n) - ("standard" . ?s) - ("wisdom" . ?w) - (:endgroup . nil))) + ("licenses" . ?l) + ("need" . ?n) + ("standard" . ?s) + ("wisdom" . ?w) + (:endgroup . nil))) (setq org-agenda-restore-windows-after-quit t org-agenda-start-on-weekday 0 @@ -64,24 +63,24 @@ org-agenda-window-setup 'current-window org-agenda-remove-tags t org-agenda-prefix-format '((agenda . " %:c %b %?-12t% s") - (todo . " %:c % b") - (tags . " %:c % b") - (search . " %:c % b"))) + (todo . " %:c % b") + (tags . " %:c % b") + (search . " %:c % b"))) (setq org-agenda-custom-commands '((" " "Agenda" - ((tags "need" - ((org-agenda-overriding-header "Needed Items"))) - (tags-todo "-REFILE+TODO=\"IN-PROGRESS\"" - ((org-agenda-overriding-header "In Progress"))) - (tags "REFILE" - ((org-agenda-overriding-header "Tasks to Refile"))) - (tags-todo "-TODO=\"WAITING\"-TODO=\"IN-PROGRESS\"-standard-REFILE" - ((org-agenda-overriding-header "Filed Tasks"))) - (tags-todo "TODO=\"WAITING\"-REFILE" - ((org-agenda-overriding-header "Holding"))) - (tags-todo "standard" - ((org-agenda-overriding-header "Changes to Standard"))))))) + ((tags "need" + ((org-agenda-overriding-header "Needed Items"))) + (tags-todo "-REFILE+TODO=\"IN-PROGRESS\"" + ((org-agenda-overriding-header "In Progress"))) + (tags "REFILE" + ((org-agenda-overriding-header "Tasks to Refile"))) + (tags-todo "-TODO=\"WAITING\"-TODO=\"IN-PROGRESS\"-standard-REFILE" + ((org-agenda-overriding-header "Filed Tasks"))) + (tags-todo "TODO=\"WAITING\"-REFILE" + ((org-agenda-overriding-header "Holding"))) + (tags-todo "standard" + ((org-agenda-overriding-header "Changes to Standard"))))))) (setq org-columns-default-format "%50ITEM(Task) %10CLOCKSUM %16TIMESTAMP_IA" org-agenda-start-with-log-mode t) @@ -95,36 +94,36 @@ org-pretty-entities t) (setq org-capture-templates '(("n" "Note" entry - (file org-default-notes-file) - "* %?" - :clock-in t - :clock-resume t) - ("t" "TODO" entry - (file org-default-notes-file) - "* TODO %?\n%U\n" - :clock-in t - :clock-resume t) - ("l" "Purchase Licenses" entry - (file org-default-notes-file) - "* TODO Get Licenses :licenses:\n%U\n** TODO Wonderware\n** TODO TOPServer\n" - :clock-in t - :clock-resume t) - ("m" "Meeting" entry - (file+olp+datetree org-journal-file) - "* %? :meeting:\n%t\n** Notes\n** Action Items" - :time-prompt t) - ("s" "Semi-Weekly PLC Meeting" entry - (file+olp+datetree org-journal-file) - "* Semi-Weekly PLC Meeting :plc:semiweekly:meeting:%^g \n%t\n** Notes\n** Action Items" - :clock-in t - :clock-resume t) - ("a" "Appointment" entry - (file+olp+datetree org-journal-file) - "* %? :appt:\n%t" - :time-prompt t) - ("j" "Journal" entry - (file+olp+datetree org-journal-file) - "* %?\n%U\n"))) + (file org-default-notes-file) + "* %?" + :clock-in t + :clock-resume t) + ("t" "TODO" entry + (file org-default-notes-file) + "* TODO %?\n%U\n" + :clock-in t + :clock-resume t) + ("l" "Purchase Licenses" entry + (file org-default-notes-file) + "* TODO Get Licenses :licenses:\n%U\n** TODO Wonderware\n** TODO TOPServer\n" + :clock-in t + :clock-resume t) + ("m" "Meeting" entry + (file+olp+datetree org-journal-file) + "* %? :meeting:\n%t\n** Notes\n** Action Items" + :time-prompt t) + ("s" "Semi-Weekly PLC Meeting" entry + (file+olp+datetree org-journal-file) + "* Semi-Weekly PLC Meeting :plc:semiweekly:meeting:%^g \n%t\n** Notes\n** Action Items" + :clock-in t + :clock-resume t) + ("a" "Appointment" entry + (file+olp+datetree org-journal-file) + "* %? :appt:\n%t" + :time-prompt t) + ("j" "Journal" entry + (file+olp+datetree org-journal-file) + "* %?\n%U\n"))) (setq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id) diff --git a/re/re-plc-defuns.el b/re/re-plc-defuns.el index 4212f15..8a2fbc5 100644 --- a/re/re-plc-defuns.el +++ b/re/re-plc-defuns.el @@ -5,57 +5,74 @@ (require 're-electronics-defuns) +(defvar *plc-resolution* 16) +(defvar *plc-max-voltage* 10.0) + +(defun P3K () + (setq *plc-resolution* 16 + *plc-max-voltage* 10.0)) + +(defun SLC () + (setq *plc-resolution* 16 + *plc-max-voltage* 10.0)) + +(defun P1K () + (setq *plc-resolution* 16 + *plc-max-voltage* 10.0)) + +(defun DL4 () + (setq *plc-resolution* 13 + *plc-max-voltage* 10.0)) + (defun max-counts (resolution) "Calculate the max count for a PLC analog, given card's bit-resolution." (1- (^ 2 resolution))) -(defun volts->counts (vmax vin resolution) +(defun volts->counts (vin) "Convert a voltage signal to a PLC count. Calculates a ratio of vin/vmax, then scales by `max-counts'." - (* (/ (float vin) vmax) (max-counts resolution))) + (* (/ vin *plc-max-voltage*) (max-counts *plc-resolution*))) -(defun counts->volts (vmax cin resolution) +(defun counts->volts (cin) "Convert a PLC count to a voltage. Calculates a ratio of cin/`max-counts', then multiplies by vmax." - (* (/ (float cin) (max-counts resolution)) vmax)) + (* (/ cin (max-counts *plc-resolution*)) *plc-max-voltage*)) -(defun amps->counts (vmax amps resolution r1 &optional r2) +(defun amps->counts (amps r1 &optional r2) "Convert a current signal to PLC Counts. Converts the amperage to a voltage using `amps->volts' (with r1 and optional r2), then applies `volts->counts' to the resulting voltage, vmax, and resolution." - (volts->counts vmax (amps->volts amps r1 r2) resolution)) - -(defun count-range (upper lower vmax resolution &optional r1 r2) - "Given an upper and lower signal, return the list of upper and lower PLC counts. -With a current signal, use r1 and maybe r2 to -calculate `amps->counts'. Otherwise ignore r1/r2 and calculate -`volts->counts'." - (if (eq nil r1) - (list (volts->counts vmax upper resolution) - (volts->counts vmax lower resolution)) - (list (amps->counts vmax upper resolution r1 r2) - (amps->counts vmax lower resolution r1 r2)))) + (volts->counts *plc-max-voltage* (amps->volts amps r1 r2) *plc-resolution*)) + +(defun count-range (upper lower) + "Given an upper and lower voltage, return the list of upper and lower PLC counts." + (list (volts->counts upper) (volts->counts lower))) + +(defun volt-range (upper lower) + "Given an upper and lower PLC count, return the list of upper and lower voltage." + (list (counts->volts upper) (counts->volts lower))) (defun divisor (raw-max raw-min scaled-max scaled-min) "Calculate 1/slope given PLC Max/Min and Eng. Max/Min." (/ (float (- raw-max raw-min)) (- scaled-max scaled-min))) -(defun offset (raw-max raw-min scaled-max scaled-min) - "Calculate offset given PLC Max/Min and Eng. Max/Min." - (- scaled-min (/ raw-min (divisor raw-max raw-min scaled-max scaled-min)))) +(defun offset (divisor scaled-min raw-min) + "Calculate offset given Divisor and both minimums." + (- scaled-min (/ raw-min divisor))) + +(defun scale (raw-max raw-min scaled-max scaled-min) + "Calculate the divisor and offset, given the parameters." + (let* ((div (divisor raw-max raw-min scaled-max scaled-min))) + (list div (offset div scaled-min raw-min)))) (defun final (analog-input divisor offset) "Calculate the scaled value of an input." (+ (/ analog-input divisor) offset)) -(defun scale (raw-max raw-min scaled-max scaled-min &optional analog-input) - "Calculate the divisor, offset, and maybe final value, given the parameters." - (let* ((div (divisor raw-max raw-min scaled-max scaled-min)) - (os (offset raw-max raw-min scaled-max scaled-min))) - (if (eq nil analog-input) - (list div os) - (list div os (final analog-input div os))))) +(defun input (scaled-value divisor offset) + "Calculate the input counts from a scaled value." + (* divisor (- scaled-value offset))) (provide 're-plc-defuns) ;;; re-plc-defuns.el ends here diff --git a/re/re-refrigeration-defuns.el b/re/re-refrigeration-defuns.el index 92d7245..50cc14f 100644 --- a/re/re-refrigeration-defuns.el +++ b/re/re-refrigeration-defuns.el @@ -6,6 +6,8 @@ (require 're-math-defuns) ;; Unit wendings + +;;; Leŋþ (defun mm->in (mm) "Convert milimeters to inches." (/ mm 25.4)) @@ -14,6 +16,7 @@ "Convert inches to milimeters." (* in 25.4)) +;;; Heat (defun k->c (tempk) "Convert degrees Kelvin to degrees Celsius." (- tempk 273.15)) @@ -40,16 +43,66 @@ Applies `c->f' to `k->c'." Applies `c->k' to `f->c'." (c->k (f->c tempf))) +;;; Pressure +(defun bar->psi (bar) + "Convert bar to psi." + (* 14.5 bar)) + +(defun psi->bar (psi) + "Convert psi to bar." + (/ psi 14.5)) + +(defun kpa->psi (kpa) + "Convert kpa to psi." + (* 6.89 kpa)) + +(defun psi->kpa (psi) + "Convert psi to kpa." + (/ psi 6.89)) + +(defun mmhg->psi (mmhg) + "Convert mmhg to psi." + (/ mmhg 51.71)) + +(defun psi->mmhg (psi) + "Convert psi to mmhg." + (* 51.71 psi)) + +(defun inhg->psi (inhg) + "Convert inhg to psi." + (mmhg->psi (in->mm inhg))) + +(defun psi->inhg (psi) + "Convert psi to inhg." + (mm->in (psi->mmhg psi))) + +;;; Weight +(defun g->oz (grams) + "Convert grams to ounces." + (/ grams 28.34)) + +(defun oz->g (ounces) + "Convert ounces to grams." + (* ounces 28.34)) + +(defun kg->lb (kilograms) + "Convert kilograms to pounds." + (* kilograms 2.2)) + +(defun lb->kg (pounds) + "Convert pounds to kilograms." + (/ pounds 2.2)) + ;; Cooling (defun cfm-circ (fpm radius) "Calculate the CFM of a circular duct. -Inputs are feet/minute and radius (in)." - (* float-pi fpm (square (/ radius 12.0)))) +Inputs are feet/minute and radius (ft)." + (* float-pi fpm (square radius))) (defun cfm-rect (fpm width height) "Calculate the CFM of a rectangular duct. -Inputs are feet/minute, width (in) and height (in)." - (* fpm (/ width 12.0) (/ height 12.0))) +Inputs are feet/minute, width (ft) and height (ft)." + (* (float fpm) width height)) (defun sat-water-press (temp) "Calculate the saturated water pressure at a temp (F)." diff --git a/re/re-skeletons.el b/re/re-skeletons.el index d5ba346..c88eadf 100644 --- a/re/re-skeletons.el +++ b/re/re-skeletons.el @@ -22,7 +22,6 @@ "** " _ - \n "*** System Notes\n" - "*** Expirements\n" "*** PLC [/]\n" "*** Wonderware [/]\n" "*** Commissioning [/]\n"